Mainflux.mainflux/twins/mocks/states.go

123 lines
2.6 KiB
Go
Raw Normal View History

MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package mocks
import (
"context"
"sort"
"strconv"
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
"strings"
"sync"
"github.com/mainflux/mainflux/twins"
)
var _ twins.StateRepository = (*stateRepositoryMock)(nil)
type stateRepositoryMock struct {
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
mu sync.Mutex
states map[string]twins.State
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
}
// NewStateRepository creates in-memory twin repository.
func NewStateRepository() twins.StateRepository {
return &stateRepositoryMock{
states: make(map[string]twins.State),
}
}
MF-1506 - Group-based Access Control (#1716) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update Add and Delete Policies (#1792) * Remove Policy Action Ranks Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Rebase Issues Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix CI Test Errors Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Adding Check on Subject For Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Check Client Exists Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check When Sharing Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Only Add User to Group When Sharing Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove clientType Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Minor Fix on ShareClient and Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Clean Up Things Authorization Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests on RetrieveAll Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Test ShareThing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Merge Conflicts Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Adding Policies. Only Use Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check If Subject is same as Object Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Move Back To Union As Sometimes Policy is Empty and Fails to Evaluate on Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Entity Type For Failing Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix BUG in policy evaluation Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Comments Regarding checkAdmin Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Combine Authorize For Things and Users Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Error on Things SVC `unsupported protocol scheme` Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix Bug on Things Authorization Cache (#1810) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use Password instead of username in MQTT handler Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Simplify MQTT authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix MQTT tests Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add More Functions to SDK (#1811) * Add More Functions to SDK Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to GoDoc Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Update Unassign Interface Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Pass Subject as ID and Not Token on List Channels By Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Bootstrap Errors For Element Check Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add empty line Before Return Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Reorder URLS in things mux Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Listing Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Share Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to CLI Docs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Identity To Update Another User Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Identify an Update Policies on Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix GoDocs on Disconnect Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Change Authorize To Use AccessRequest Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * For Evaluate Policy Use AccessRequest (#1814) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add SDK Tests (#1812) * Add Things Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Channel Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Certs Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Consumer Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enrich Group Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Health Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Tokens Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename SDK for Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Linter Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Make Variable Defination Inline Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Make Cache Key Duration Configurable (#1815) * Make Cache Key Duration Configurable Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename ENV Var Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update GoDocs (#1816) * Add GoDocs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Missing GoDoc Files Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enable godot Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add License Information Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add Call Home Client to Mainflux services (#1751) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> * collect and send data package Signed-off-by: SammyOina <sammyoina@gmail.com> * create telemetry migrations Signed-off-by: SammyOina <sammyoina@gmail.com> * add telemetry endpoints Signed-off-by: SammyOina <sammyoina@gmail.com> * add transport Signed-off-by: SammyOina <sammyoina@gmail.com> * create service Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing server Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to adapters Signed-off-by: SammyOina <sammyoina@gmail.com> * add last seen Signed-off-by: SammyOina <sammyoina@gmail.com> * rename logger Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing client Signed-off-by: SammyOina <sammyoina@gmail.com> * use unmerged repo Signed-off-by: SammyOina <sammyoina@gmail.com> * use renamed module Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home version Signed-off-by: SammyOina <sammyoina@gmail.com> * edit documentation Signed-off-by: SammyOina <sammyoina@gmail.com> * align table Signed-off-by: SammyOina <sammyoina@gmail.com> * use alias for call home client Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home pkg Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home Signed-off-by: SammyOina <sammyoina@gmail.com> * fix modules Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * restore default Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home for users and things Signed-off-by: SammyOina <sammyoina@gmail.com> * enable opting on call home Signed-off-by: SammyOina <sammyoina@gmail.com> * remove full stops Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome client Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to all services Signed-off-by: SammyOina <sammyoina@gmail.com> * fix build Signed-off-by: SammyOina <sammyoina@gmail.com> * restore sdk tests Signed-off-by: SammyOina <sammyoina@gmail.com> * remove unnecessary changes Signed-off-by: SammyOina <sammyoina@gmail.com> * restore health_test.go Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Sammy Kerata Oina <44265300+SammyOina@users.noreply.github.com>
2023-06-14 18:40:37 +08:00
// SaveState persists the state.
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
func (srm *stateRepositoryMock) Save(ctx context.Context, st twins.State) error {
srm.mu.Lock()
defer srm.mu.Unlock()
srm.states[key(st.TwinID, strconv.FormatInt(st.ID, 10))] = st
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
return nil
}
MF-1506 - Group-based Access Control (#1716) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update Add and Delete Policies (#1792) * Remove Policy Action Ranks Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Rebase Issues Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix CI Test Errors Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Adding Check on Subject For Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Check Client Exists Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check When Sharing Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Only Add User to Group When Sharing Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove clientType Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Minor Fix on ShareClient and Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Clean Up Things Authorization Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests on RetrieveAll Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Test ShareThing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Merge Conflicts Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Adding Policies. Only Use Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check If Subject is same as Object Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Move Back To Union As Sometimes Policy is Empty and Fails to Evaluate on Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Entity Type For Failing Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix BUG in policy evaluation Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Comments Regarding checkAdmin Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Combine Authorize For Things and Users Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Error on Things SVC `unsupported protocol scheme` Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix Bug on Things Authorization Cache (#1810) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use Password instead of username in MQTT handler Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Simplify MQTT authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix MQTT tests Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add More Functions to SDK (#1811) * Add More Functions to SDK Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to GoDoc Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Update Unassign Interface Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Pass Subject as ID and Not Token on List Channels By Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Bootstrap Errors For Element Check Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add empty line Before Return Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Reorder URLS in things mux Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Listing Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Share Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to CLI Docs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Identity To Update Another User Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Identify an Update Policies on Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix GoDocs on Disconnect Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Change Authorize To Use AccessRequest Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * For Evaluate Policy Use AccessRequest (#1814) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add SDK Tests (#1812) * Add Things Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Channel Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Certs Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Consumer Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enrich Group Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Health Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Tokens Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename SDK for Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Linter Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Make Variable Defination Inline Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Make Cache Key Duration Configurable (#1815) * Make Cache Key Duration Configurable Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename ENV Var Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update GoDocs (#1816) * Add GoDocs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Missing GoDoc Files Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enable godot Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add License Information Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add Call Home Client to Mainflux services (#1751) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> * collect and send data package Signed-off-by: SammyOina <sammyoina@gmail.com> * create telemetry migrations Signed-off-by: SammyOina <sammyoina@gmail.com> * add telemetry endpoints Signed-off-by: SammyOina <sammyoina@gmail.com> * add transport Signed-off-by: SammyOina <sammyoina@gmail.com> * create service Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing server Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to adapters Signed-off-by: SammyOina <sammyoina@gmail.com> * add last seen Signed-off-by: SammyOina <sammyoina@gmail.com> * rename logger Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing client Signed-off-by: SammyOina <sammyoina@gmail.com> * use unmerged repo Signed-off-by: SammyOina <sammyoina@gmail.com> * use renamed module Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home version Signed-off-by: SammyOina <sammyoina@gmail.com> * edit documentation Signed-off-by: SammyOina <sammyoina@gmail.com> * align table Signed-off-by: SammyOina <sammyoina@gmail.com> * use alias for call home client Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home pkg Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home Signed-off-by: SammyOina <sammyoina@gmail.com> * fix modules Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * restore default Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home for users and things Signed-off-by: SammyOina <sammyoina@gmail.com> * enable opting on call home Signed-off-by: SammyOina <sammyoina@gmail.com> * remove full stops Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome client Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to all services Signed-off-by: SammyOina <sammyoina@gmail.com> * fix build Signed-off-by: SammyOina <sammyoina@gmail.com> * restore sdk tests Signed-off-by: SammyOina <sammyoina@gmail.com> * remove unnecessary changes Signed-off-by: SammyOina <sammyoina@gmail.com> * restore health_test.go Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Sammy Kerata Oina <44265300+SammyOina@users.noreply.github.com>
2023-06-14 18:40:37 +08:00
// UpdateState updates the state.
func (srm *stateRepositoryMock) Update(ctx context.Context, st twins.State) error {
srm.mu.Lock()
defer srm.mu.Unlock()
srm.states[key(st.TwinID, strconv.FormatInt(st.ID, 10))] = st
return nil
}
MF-1506 - Group-based Access Control (#1716) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update Add and Delete Policies (#1792) * Remove Policy Action Ranks Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Rebase Issues Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix CI Test Errors Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Adding Check on Subject For Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Check Client Exists Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check When Sharing Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Only Add User to Group When Sharing Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove clientType Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Minor Fix on ShareClient and Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Clean Up Things Authorization Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests on RetrieveAll Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Test ShareThing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Merge Conflicts Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Adding Policies. Only Use Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check If Subject is same as Object Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Move Back To Union As Sometimes Policy is Empty and Fails to Evaluate on Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Entity Type For Failing Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix BUG in policy evaluation Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Comments Regarding checkAdmin Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Combine Authorize For Things and Users Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Error on Things SVC `unsupported protocol scheme` Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix Bug on Things Authorization Cache (#1810) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use Password instead of username in MQTT handler Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Simplify MQTT authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix MQTT tests Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add More Functions to SDK (#1811) * Add More Functions to SDK Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to GoDoc Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Update Unassign Interface Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Pass Subject as ID and Not Token on List Channels By Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Bootstrap Errors For Element Check Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add empty line Before Return Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Reorder URLS in things mux Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Listing Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Share Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to CLI Docs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Identity To Update Another User Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Identify an Update Policies on Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix GoDocs on Disconnect Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Change Authorize To Use AccessRequest Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * For Evaluate Policy Use AccessRequest (#1814) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add SDK Tests (#1812) * Add Things Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Channel Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Certs Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Consumer Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enrich Group Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Health Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Tokens Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename SDK for Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Linter Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Make Variable Defination Inline Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Make Cache Key Duration Configurable (#1815) * Make Cache Key Duration Configurable Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename ENV Var Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update GoDocs (#1816) * Add GoDocs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Missing GoDoc Files Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enable godot Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add License Information Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add Call Home Client to Mainflux services (#1751) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> * collect and send data package Signed-off-by: SammyOina <sammyoina@gmail.com> * create telemetry migrations Signed-off-by: SammyOina <sammyoina@gmail.com> * add telemetry endpoints Signed-off-by: SammyOina <sammyoina@gmail.com> * add transport Signed-off-by: SammyOina <sammyoina@gmail.com> * create service Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing server Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to adapters Signed-off-by: SammyOina <sammyoina@gmail.com> * add last seen Signed-off-by: SammyOina <sammyoina@gmail.com> * rename logger Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing client Signed-off-by: SammyOina <sammyoina@gmail.com> * use unmerged repo Signed-off-by: SammyOina <sammyoina@gmail.com> * use renamed module Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home version Signed-off-by: SammyOina <sammyoina@gmail.com> * edit documentation Signed-off-by: SammyOina <sammyoina@gmail.com> * align table Signed-off-by: SammyOina <sammyoina@gmail.com> * use alias for call home client Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home pkg Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home Signed-off-by: SammyOina <sammyoina@gmail.com> * fix modules Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * restore default Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home for users and things Signed-off-by: SammyOina <sammyoina@gmail.com> * enable opting on call home Signed-off-by: SammyOina <sammyoina@gmail.com> * remove full stops Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome client Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to all services Signed-off-by: SammyOina <sammyoina@gmail.com> * fix build Signed-off-by: SammyOina <sammyoina@gmail.com> * restore sdk tests Signed-off-by: SammyOina <sammyoina@gmail.com> * remove unnecessary changes Signed-off-by: SammyOina <sammyoina@gmail.com> * restore health_test.go Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Sammy Kerata Oina <44265300+SammyOina@users.noreply.github.com>
2023-06-14 18:40:37 +08:00
// CountStates returns the number of states related to twin.
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
func (srm *stateRepositoryMock) Count(ctx context.Context, tw twins.Twin) (int64, error) {
return int64(len(srm.states)), nil
}
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
func (srm *stateRepositoryMock) RetrieveAll(ctx context.Context, offset uint64, limit uint64, twinID string) (twins.StatesPage, error) {
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
srm.mu.Lock()
defer srm.mu.Unlock()
if limit <= 0 {
return twins.StatesPage{}, nil
}
var items []twins.State
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
for k, v := range srm.states {
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
if (uint64)(len(items)) >= limit {
break
}
if !strings.HasPrefix(k, twinID) {
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
continue
}
id := uint64(v.ID)
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
if id >= offset && id < offset+limit {
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
items = append(items, v)
}
}
sort.SliceStable(items, func(i, j int) bool {
return items[i].ID < items[j].ID
})
page := twins.StatesPage{
States: items,
PageMetadata: twins.PageMetadata{
Total: srm.total(twinID),
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
Offset: offset,
Limit: limit,
},
}
return page, nil
}
func (srm *stateRepositoryMock) total(twinID string) uint64 {
var total uint64
for k := range srm.states {
if strings.HasPrefix(k, twinID) {
total++
}
}
return total
}
MF-1506 - Group-based Access Control (#1716) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update Add and Delete Policies (#1792) * Remove Policy Action Ranks Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Rebase Issues Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix CI Test Errors Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Adding Check on Subject For Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Check Client Exists Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check When Sharing Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Only Add User to Group When Sharing Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove clientType Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Minor Fix on ShareClient and Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Clean Up Things Authorization Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests on RetrieveAll Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Test ShareThing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Merge Conflicts Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Adding Policies. Only Use Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check If Subject is same as Object Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Move Back To Union As Sometimes Policy is Empty and Fails to Evaluate on Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Entity Type For Failing Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix BUG in policy evaluation Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Comments Regarding checkAdmin Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Combine Authorize For Things and Users Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Error on Things SVC `unsupported protocol scheme` Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix Bug on Things Authorization Cache (#1810) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use Password instead of username in MQTT handler Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Simplify MQTT authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix MQTT tests Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add More Functions to SDK (#1811) * Add More Functions to SDK Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to GoDoc Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Update Unassign Interface Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Pass Subject as ID and Not Token on List Channels By Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Bootstrap Errors For Element Check Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add empty line Before Return Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Reorder URLS in things mux Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Listing Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Share Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to CLI Docs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Identity To Update Another User Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Identify an Update Policies on Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix GoDocs on Disconnect Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Change Authorize To Use AccessRequest Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * For Evaluate Policy Use AccessRequest (#1814) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add SDK Tests (#1812) * Add Things Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Channel Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Certs Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Consumer Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enrich Group Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Health Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Tokens Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename SDK for Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Linter Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Make Variable Defination Inline Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Make Cache Key Duration Configurable (#1815) * Make Cache Key Duration Configurable Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename ENV Var Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update GoDocs (#1816) * Add GoDocs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Missing GoDoc Files Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enable godot Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add License Information Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add Call Home Client to Mainflux services (#1751) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> * collect and send data package Signed-off-by: SammyOina <sammyoina@gmail.com> * create telemetry migrations Signed-off-by: SammyOina <sammyoina@gmail.com> * add telemetry endpoints Signed-off-by: SammyOina <sammyoina@gmail.com> * add transport Signed-off-by: SammyOina <sammyoina@gmail.com> * create service Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing server Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to adapters Signed-off-by: SammyOina <sammyoina@gmail.com> * add last seen Signed-off-by: SammyOina <sammyoina@gmail.com> * rename logger Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing client Signed-off-by: SammyOina <sammyoina@gmail.com> * use unmerged repo Signed-off-by: SammyOina <sammyoina@gmail.com> * use renamed module Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home version Signed-off-by: SammyOina <sammyoina@gmail.com> * edit documentation Signed-off-by: SammyOina <sammyoina@gmail.com> * align table Signed-off-by: SammyOina <sammyoina@gmail.com> * use alias for call home client Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home pkg Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home Signed-off-by: SammyOina <sammyoina@gmail.com> * fix modules Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * restore default Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home for users and things Signed-off-by: SammyOina <sammyoina@gmail.com> * enable opting on call home Signed-off-by: SammyOina <sammyoina@gmail.com> * remove full stops Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome client Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to all services Signed-off-by: SammyOina <sammyoina@gmail.com> * fix build Signed-off-by: SammyOina <sammyoina@gmail.com> * restore sdk tests Signed-off-by: SammyOina <sammyoina@gmail.com> * remove unnecessary changes Signed-off-by: SammyOina <sammyoina@gmail.com> * restore health_test.go Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Sammy Kerata Oina <44265300+SammyOina@users.noreply.github.com>
2023-06-14 18:40:37 +08:00
// RetrieveLast returns the last state related to twin spec by id.
MF-1180 - Add redis based twins and states cache (#1184) * Add twins redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add connectToRedis to twins main and twinCache to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tracing to twins cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins cache mock and test setup for redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TestTwinSave to redis twins cache tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add remove twin redis cache test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add channels param to CreateDefinition helper method in mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add IDs test to redis twins cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify senml rec array and attribute creation funcs by removing unnecessary params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Align cache remove twin method with service remove twin method Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cache funcs to twins save, update and remove Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add def SaveIDs to redis cache and ref to service SaveStates Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinSaveIDs tests for redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cache related env vars desc to README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twinid bson key constant Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Update method to cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Integrate uuid unification related changes Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use named arguments in interface method declarations Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add env vars to docker-compose file Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Make parameter names in interface methods and implementations consistent Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Wrap vars and consts in var and const blocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-06-05 17:42:16 +08:00
func (srm *stateRepositoryMock) RetrieveLast(ctx context.Context, twinID string) (twins.State, error) {
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
srm.mu.Lock()
defer srm.mu.Unlock()
items := make([]twins.State, 0)
for _, v := range srm.states {
MF-1180 - Add redis based twins and states cache (#1184) * Add twins redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add connectToRedis to twins main and twinCache to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tracing to twins cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins cache mock and test setup for redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TestTwinSave to redis twins cache tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add remove twin redis cache test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add channels param to CreateDefinition helper method in mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add IDs test to redis twins cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify senml rec array and attribute creation funcs by removing unnecessary params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Align cache remove twin method with service remove twin method Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cache funcs to twins save, update and remove Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add def SaveIDs to redis cache and ref to service SaveStates Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinSaveIDs tests for redis cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cache related env vars desc to README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twinid bson key constant Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Update method to cache Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Integrate uuid unification related changes Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use named arguments in interface method declarations Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add env vars to docker-compose file Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Make parameter names in interface methods and implementations consistent Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Wrap vars and consts in var and const blocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-06-05 17:42:16 +08:00
if v.TwinID == twinID {
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
items = append(items, v)
}
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
}
sort.SliceStable(items, func(i, j int) bool {
return items[i].ID < items[j].ID
})
MF-995 - Add Twins tests for endpoint list twins and list states (#1174) * Add ListTwins test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove monotonic time from twins, definitions and attributes creation and update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Separate twins and states endpoint tests in two files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state generation helper funcs to state endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add createStateResponse() to states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add states test cases Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Simplify RetrieveAll twins and states methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service.go to mocks Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mocks.NewService to mocks.New Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add error checking to endpoint state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix method comment Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add json response decode success check Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove created and updated fields from twin and state res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove definition fields from twin req and res Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Create funcs to mocks package Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service save state tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add service list states test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-05-19 00:46:50 +08:00
if len(items) > 0 {
return items[len(items)-1], nil
}
return twins.State{}, nil
MF-730 - Add digital twin service for things (#855) * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add starter kit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add http Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add cmd/main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove reference to things from README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename kit to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add docker compose related files Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Dockerfile to mfxkit Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin service to docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db connection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add TwinRepository mockup Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix docker env vars Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twins repo mongodb routines Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mongo db docker test suite Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add idp and toDBTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add test cases to repo twin save test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add users grpc Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for udpate and update key Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add methods and tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add svc methods to loggin and metrics Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add AddTwin endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add update endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add view and remove endpoints Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add twin repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add owner arg to twins repo methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock idp service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mock users service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt client to twins service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add protocol to mqtt string var Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add time and attributes related data to Twin struct Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish JSON serialized twin to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for save and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for update key and view thing Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix test error for view twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add endpoint tests for remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add NATS client Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add normalizer to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Refactor nats publish() and remove normalizer Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListThingsByChannel() and RetrieveByChannel() Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Twin struct directly in mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change limit type to uint64 Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Compose nats subject from msg ch and subtopic Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt notifs for thing creation and key update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveAll to twinRepository and ListTwins to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add tests for RetrieveAll and ListTwins Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix Service interface error Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove test Ping endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt topic to service config Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove UpdateKey request and add fields to Twin related requests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Attributes and State add and view Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwins endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service and database tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add ListTwinsByThing endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove twin directory Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add States and Definitions to Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add defer publish to AddTwin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add refactored and deferred mqtt client publish to Service methods Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho subservice Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add paho client to nats Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add mqtt publish and state update Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use paho Publish wrapper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Save states in separate collection Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace []byte payload by []map[string]interface{} Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add offset to PageMetadata Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename TwinsPage to Page Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add StateRepository, mongodb StateRepository adapter and ListStates endpoint Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add RetrieveLast twin to states repository Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Parse def in nats to update state attrib Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add prepareState() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace list things by id by view thing by id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add state repo mock Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix service tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from RetrieveByID params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mongo twins repo tests and remove owner from Remove params Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace ChannelID in Attribute by Channel Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for add and update twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests for view and remove twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use new auth service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix mocks auth and mongodb tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix licensing info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix 'for for' Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Replace short dec by var for default vals and add string map for mqtt op info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Use Record from mainflux/senml and rename broker to nats in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove Key from Twin Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove redundant id uniqueness check from mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add attrib name to attrib update info Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix typos and remove isZeroOfUnderlyingType() helper Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename paho to mqtt Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix env vars in main.go and README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins/api/twins to twins/api and rename twins- prefix to tw- in main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove flows for manual testing and revert to master docker-compose.yml Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove publish from nats and fix tests by updating package names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename users.go to authn.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix crud op names Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Change id to twinID Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Inline if err != nil and change <prefix>ID to <prefix>_id Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix metadata db search test Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Rename mqtt and nats related files to publisher and subscriber respectively Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move save state logic from nats to service Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Fix endpoint tests Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove close check from main.go Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Complete deploy section Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add unit tests for states Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove debugging artefacts and unneeded comments to exported funcs Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add port num to defAuthnURL Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-01-11 00:25:36 +08:00
}