* WIP: alarms service
* fix(alarms): remove rule entity since it is not stored here
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* test(alarms): add tests cases for invalid alarms
* feat(alarms): add authorization
* feat(alarms): add docker deployment files
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix: update go mod file
* feat(alarms): support filtering by resolved_by, updated_by and severity
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* style: fix linter errors
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): provide correct otel naming for create alarm
Fixes https://github.com/absmach/magistrala/pull/106#discussion_r2030151971
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): group routes appropriately
Resolves https://github.com/absmach/magistrala/pull/106#discussion_r2030160891
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): extract alarm id from url path rather than query params
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): add all status to help in decoding
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* style(alarms): maintain consistent import as naming for supermq api package
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* refactor(alarms): update supermq dependecy to the latest
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): Add domains gRPC service config to alarms service
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* test(alarms): all CRUD operations from the service
Return empty results instead of nil
This standardizes error responses across alarm endpoints to return empty
result structs rather than nil. Also renames entityReq to alarmReq and
adds HTTP status codes for created/deleted alarms.
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* test(alarms): fix failing tests due to introduction of context on sdk
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): remove channel id
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): standardize error handling across CRUD operations
Updated error responses to use specific repository errors for consistency
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): add assignment fields to Alarm model and database
Introduced AssignedAt and AssignedBy fields to the Alarm struct and updated the database schema accordingly. Enhanced the UpdateAlarm function to handle these new fields, ensuring proper assignment tracking in the alarms system.
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): enhance Alarm model with measurement attributes
Updated the Alarm struct to include Measurement, Value, Unit, and Cause fields. Modified the validation logic to ensure these fields are present. Adjusted logging and tracing middleware to reflect the new attributes. Updated database schema and related functions to accommodate these changes, ensuring comprehensive alarm data management.
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): consume events from pubsub for creation of alarms
Removed session dependencies from CreateAlarm method and enhanced alarm validation to ensure all required fields are present
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* style(alarms): add newline at the end of docker compose
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): Add assignee id and metadata fields when consuming messages
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): add acknowledged field
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): Add threshold value for the specific measurement
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): Add channel, thing, and subtopic fields to Alarm model
This change adds required fields for tracking alarm sources and reorganizes
alarm-related fields for better grouping. Alarms now track the channel,
thing, and subtopic that triggered them, along with domain and rule info.
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* test(alarms): add service layer tests
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): consume created at from message rather than creating it
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): ready alarm as a gob encoded object
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): read alarms from alarms queue and remove transformer
g
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): update version of supermq
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* feat(alarms): add gob transformer
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): rename thing id to client id
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): create alarms stream
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): check on logic to create new alarm
create new alarm if severity, status, subtopic changes
enhance logging with additional details for alarms management
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* remove conusmer and use pubsub
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* fix(alarms): use build tags for rabbitmq and nats
* fix(alarms): add health and metrics endpoint
* fix(magistrala): use supermq as build flags to see version and commit
* fix(alarms): use js config
* fix(alarms): remove validation when updating an alarm
fix authorization too
---------
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
* refactor: aligh bootstrap with new supermq architecture
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* feat: add sdk and update api docs
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* refactor: rename env variables
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* style: add empty line to config files and bootstrap docker compose file
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* refactor: add supermq sdk to magistrala sdk
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* refactor: extend supermq sdk in magistrala sdk
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* reafctor: update responses
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* ci: update api docs dir in swagger-ui deployment
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
---------
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
* fix(errors): Fix nil pointer error in NewSDKError
In the NewSDKError function, a check is added to handle the case where the input error is nil. Previously, if the error was nil, the function would panic. This fix ensures that the function returns nil instead of panicking when the input error is nil.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(sdk-mock): Add mock functions for SDK testing
This commit adds a set of mock functions for the software development kit (SDK) to facilitate testing. These functions simulate the behavior of the actual functions in the SDK and have defined input parameters and return values. The code also includes error handling logic and checks for different return types.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* test: use sdk mocked interface
* feat(workflow): check for generated files
The commit modifies the check-proto GitHub workflow to check-generated files. It checks for changes in specific paths and verifies the protobuf files and generated mocks. The code also includes checking if the SDK mock is up to date, installing a tool, generating mocks, and displaying an error message if the mocks are different. The tool we use is: https://github.com/vektra/mockery.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(mocks): Add copyright notice to mocks.go
Added a copyright notice to the mocks.go file in the pkg/sdk/go directory for clarity and attribution.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(build): Add target for generating mocks
Added a new target to the Makefile for generating mocks using the mockery tool. The target checks if the mockery tool is installed and then runs the "go generate" command to generate mocks for the codebase..
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Improve error messages in check-generated-files.yml
In this commit, I have made changes to the check-generated-files.yml file. Specifically, I have updated the error messages to provide more information about the issue. Instead of simply stating that the proto file and generated Go file are out of sync, the error message now includes a more detailed explanation and a suggestion for resolving the issue. Additionally, I have also added error messages for the generated mocks for the SDK. These error messages provide information about the sync issue and suggest running the necessary commands to resolve it. This commit aims to improve the clarity of error messages and help developers quickly identify and fix sync issues in the codebase.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(service): Add new "invitations" service
This commit adds a new service called "invitations" to the existing file. The service includes the necessary imports and initializes components for its functionality. It also includes configuration settings and a Docker Compose file. Additionally, instructions for deploying and using the service are provided, along with a function to create an HTTP handler.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* docs(api): invitation api
The commit adds documentation for an API that allows users to manage invitations. It includes information about the endpoints, parameters, data types, and components used in the API. The documentation also outlines the properties and specifications of the Invitation object. This commit provides a comprehensive overview of the API's functionality and structure.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: accept invitation to take in domain
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* refactor(invitations): rename domain to domainID
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Authorize on id(domain+user) rather than user
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>