### Integrate Hummingbird into Go Application Source: https://context7.com/winc-link/hummingbird/llms.txt This Go code demonstrates integrating Hummingbird's core functionalities into a Go application. It initializes the dependency injection container, interacts with device and product application interfaces for adding, querying, and searching, and configures, updates, and starts alert rules with specific conditions and notifications. It requires the Hummingbird internal packages for core functionality. ```go package main import ( "context" "github.com/winc-link/hummingbird/internal/hummingbird/core/container" "github.com/winc-link/hummingbird/internal/dtos" ) func main() { ctx := context.Background() // Initialize dependency injection container dic := container.NewContainer() // Get device application interface deviceApp := container.DeviceAppFrom(dic.Get) // Add a new device deviceReq := dtos.DeviceAddRequest{ Name: "Sensor-001", ProductId: "product-id", DriverInstanceId: "driver-instance-id", Platform: "LocalIot", Description: "Temperature sensor", } deviceId, err := deviceApp.AddDevice(ctx, deviceReq) if err != nil { panic(err) } // Query device by ID device, err := deviceApp.DeviceById(ctx, deviceId) if err != nil { panic(err) } // Get product application interface productApp := container.ProductAppFrom(dic.Get) // Query products with pagination productReq := dtos.ProductSearchQueryRequest{ BaseSearchConditionQuery: dtos.BaseSearchConditionQuery{ Page: 1, PageSize: 20, }, } products, total, err := productApp.ProductsSearch(ctx, productReq) if err != nil { panic(err) } // Get alert rule application interface alertApp := container.AlertRuleAppNameFrom(dic.Get) // Create alert rule ruleReq := dtos.RuleAddRequest{ Name: "High Temperature", AlertType: "device", AlertLevel: "urgent", Description: "Temperature alert", } ruleId, err := alertApp.AddAlertRule(ctx, ruleReq) if err != nil { panic(err) } // Configure rule triggers ruleUpdate := dtos.RuleUpdateRequest{ Id: ruleId, Condition: "or", SilenceTime: 300000, SubRule: []dtos.SubRule{ { Trigger: "device_data", ProductId: "product-id", Option: map[string]string{ "code": "temperature", "value_type": "original", "decide_condition": "> 100", }, }, }, Notify: []dtos.Notify{ { Name: "qyweixin", Option: map[string]string{ "webhook": "https://webhook-url", }, StartEffectTime: "00:00:00", EndEffectTime: "23:59:59", }, }, } err = alertApp.UpdateAlertRule(ctx, ruleUpdate) if err != nil { panic(err) } // Start the rule err = alertApp.AlertRulesStart(ctx, ruleId) if err != nil { panic(err) } } ``` -------------------------------- ### Get Product Details - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Fetches detailed information about a specific product, including its thing model (properties, events, actions). Requires authentication and the product ID. Returns the product details object. ```bash curl -X GET "http://localhost:8082/api/v1/product/abc123" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Get System Metrics (API) Source: https://context7.com/winc-link/hummingbird/llms.txt Fetches system resource utilization metrics, including CPU percentage, memory usage (total, used, percentage), and disk usage (total, used, percentage), as well as system uptime. Requires authentication via the 'x-token' header. ```bash # Get system metrics (CPU, Memory, Disk) curl -X GET "http://localhost:8082/api/v1/metrics/system" \ -H "x-token: YOUR_AUTH_TOKEN" # Response: # { "cpu_percent": 35.5, "memory_total": 4294967296, "memory_used": 2147483648, "memory_percent": 50.0, "disk_total": 107374182400, "disk_used": 53687091200, "disk_percent": 50.0, "uptime": 86400 } ``` -------------------------------- ### Get Homepage Statistics (API) Source: https://context7.com/winc-link/hummingbird/llms.txt Retrieves key dashboard metrics including device counts (total, online, offline), product counts, alert summaries, and rule statistics. Requires authentication via the 'x-token' header. ```bash # Get homepage statistics curl -X GET "http://localhost:8082/api/v1/home-page" \ -H "x-token: YOUR_AUTH_TOKEN" # Response: # { "deviceCount": 150, "onlineCount": 142, "offlineCount": 8, "productCount": 12, "alertCount": 28, "driverCount": 8, "ruleCount": 15, "activeRuleCount": 12, "todayAlertCount": 5, "weekAlertCount": 28 } ``` -------------------------------- ### Start and Stop Alert Rule Source: https://context7.com/winc-link/hummingbird/llms.txt Commands to start and stop an alert rule using its unique ID. These actions control the active state of the configured alert. ```bash # Start the alert rule curl -X POST "http://localhost:8082/api/v1/alert-rule/rule-id-uuid/start" \ -H "x-token: YOUR_AUTH_TOKEN" # Stop the alert rule curl -X POST "http://localhost:8082/api/v1/alert-rule/rule-id-uuid/stop" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Query Device Property History API Source: https://context7.com/winc-link/hummingbird/llms.txt Fetches historical data for a device property within a specified time range. Supports pagination and requires device ID, property code, start time, and end time. ```bash curl -X GET "http://localhost:8082/api/v1/device/device-uuid/thing-model/history-property?code=temperature&page=1&pageSize=100&startTime=1699900000000&endTime=1700000000000" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Manage Hummingbird Device Instances (API) Source: https://context7.com/winc-link/hummingbird/llms.txt These API calls are used to create, query, and update driver instances for devices. They interact with a local API server, typically running on port 8082, and require an authentication token. The operations involve sending POST, GET, and PUT requests with JSON payloads. ```bash curl -X POST "http://localhost:8082/api/v1/device-server" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Modbus-Driver-Instance-1", "deviceLibraryId": "library-uuid", "config": { "server_port": 502, "timeout": 3000, "max_connections": 10 }, "expertMode": false, "dockerParamsSwitch": true, "dockerParams": "--memory 512m --restart on-failure:10", "driverType": 1 }' ``` ```bash curl -X GET "http://localhost:8082/api/v1/device-servers?page=1&pageSize=20" \ -H "x-token: YOUR_AUTH_TOKEN" ``` ```bash curl -X PUT "http://localhost:8082/api/v1/device-server/instance-uuid" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "id": "instance-uuid", "config": { "server_port": 502, "timeout": 5000, "max_connections": 20 } }' ``` -------------------------------- ### Get Device MQTT Credentials - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Fetches MQTT authentication credentials for a specific device, enabling it to connect to the platform. Requires authentication and the device ID. Returns clientId, username, password, and MQTT host URL. ```bash curl -X GET "http://localhost:8082/api/v1/device-mqtt/device-uuid" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Create Product - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Creates a new IoT product definition in the Hummingbird platform. Requires authentication and a JSON payload with product details. Returns a success status and the generated product ID. ```bash curl -X POST "http://localhost:8082/api/v1/product" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Industrial Temperature Sensor", "key": "temp-sensor-v1", "category_template_id": "1", "protocol": "modbus", "node_type": "direct", "net_type": "wifi", "data_format": "json", "factory": "ACME Manufacturing", "description": "High-precision industrial temperature monitoring device" }' ``` -------------------------------- ### Query Products - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Retrieves a list of products with pagination and filtering capabilities. Requires authentication and accepts query parameters for page number, page size, and product name. Returns a list of products matching the criteria. ```bash curl -X GET "http://localhost:8082/api/v1/products?page=1&pageSize=20&name=temperature" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Driver Instance Management API Source: https://context7.com/winc-link/hummingbird/llms.txt Manage driver instances, including creation, retrieval, and updating configurations. ```APIDOC ## POST /api/v1/device-server ### Description Creates a new driver instance, effectively starting a new container for device communication. ### Method POST ### Endpoint /api/v1/device-server ### Parameters #### Headers - **x-token** (string) - Required - Authentication token. - **Content-Type** (string) - Required - `application/json` #### Request Body - **name** (string) - Required - The name for the driver instance. - **deviceLibraryId** (string) - Required - The ID of the device library to use. - **config** (object) - Optional - Configuration parameters for the driver instance. - **server_port** (integer) - Optional - The server port. - **timeout** (integer) - Optional - The timeout in milliseconds. - **max_connections** (integer) - Optional - The maximum number of connections. - **expertMode** (boolean) - Optional - Enables expert mode. - **dockerParamsSwitch** (boolean) - Optional - Enables Docker parameters. - **dockerParams** (string) - Optional - Parameters for Docker. - **driverType** (integer) - Optional - The type of the driver. ### Request Example ```json { "name": "Modbus-Driver-Instance-1", "deviceLibraryId": "library-uuid", "config": { "server_port": 502, "timeout": 3000, "max_connections": 10 }, "expertMode": false, "dockerParamsSwitch": true, "dockerParams": "--memory 512m --restart on-failure:10", "driverType": 1 } ``` ### Response #### Success Response (201 Created) - **id** (string) - The ID of the created driver instance. - **name** (string) - The name of the driver instance. - **deviceLibrary** (object) - Information about the device library. - **runStatus** (integer) - The current run status. - **imageExist** (boolean) - Indicates if the image exists. - **config** (object) - The configuration of the driver instance. - **create_at** (integer) - Timestamp of creation. #### Response Example ```json { "id": "instance-uuid", "name": "Modbus-Driver-Instance-1", "deviceLibrary": { "name": "Modbus TCP Driver", "version": "1.0.0" }, "runStatus": 1, "imageExist": true, "config": {"server_port": 502, "timeout": 3000}, "create_at": 1700000000000 } ``` ``` ```APIDOC ## GET /api/v1/device-servers ### Description Retrieves a list of existing driver instances. ### Method GET ### Endpoint /api/v1/device-servers ### Parameters #### Headers - **x-token** (string) - Required - Authentication token. #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. ### Response #### Success Response (200 OK) - **data** (array) - An array of driver instance objects. - **id** (string) - The ID of the driver instance. - **name** (string) - The name of the driver instance. - **deviceLibrary** (object) - Information about the device library. - **runStatus** (integer) - The current run status. - **imageExist** (boolean) - Indicates if the image exists. - **config** (object) - The configuration of the driver instance. - **create_at** (integer) - Timestamp of creation. - **total** (integer) - The total number of driver instances. #### Response Example ```json { "data": [ { "id": "instance-uuid", "name": "Modbus-Driver-Instance-1", "deviceLibrary": { "name": "Modbus TCP Driver", "version": "1.0.0" }, "runStatus": 1, "imageExist": true, "config": {"server_port": 502, "timeout": 3000}, "create_at": 1700000000000 } ], "total": 1 } ``` ``` ```APIDOC ## PUT /api/v1/device-server/{id} ### Description Updates the configuration of an existing driver instance. ### Method PUT ### Endpoint /api/v1/device-server/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the driver instance to update. #### Headers - **x-token** (string) - Required - Authentication token. - **Content-Type** (string) - Required - `application/json` #### Request Body - **id** (string) - Required - The ID of the driver instance. - **config** (object) - Required - The updated configuration parameters. - **server_port** (integer) - Optional - The server port. - **timeout** (integer) - Optional - The timeout in milliseconds. - **max_connections** (integer) - Optional - The maximum number of connections. ### Request Example ```json { "id": "instance-uuid", "config": { "server_port": 502, "timeout": 5000, "max_connections": 20 } } ``` ### Response #### Success Response (200 OK) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Driver instance updated successfully." } ``` ``` -------------------------------- ### Query Driver Libraries Source: https://context7.com/winc-link/hummingbird/llms.txt Queries available device driver libraries with pagination and filtering by protocol. Returns a list of libraries with their details such as ID, name, protocol, and status. ```bash # Query driver libraries curl -X GET "http://localhost:8082/api/v1/device-libraries?page=1&pageSize=20&protocol=modbus" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Add Driver Library Source: https://context7.com/winc-link/hummingbird/llms.txt Adds a new device driver library, specifying its name, description, protocol, version, and Docker details. It also allows for custom configurations like Docker parameters and expert mode. ```bash # Add a driver library curl -X POST "http://localhost:8082/api/v1/device-libraries" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Modbus TCP Driver", "description": "Driver for Modbus TCP protocol devices", "protocol": "modbus-tcp", "version": "1.0.0", "container_name": "modbus-driver", "docker_config_id": "docker-config-id", "docker_repo_name": "iot-drivers/modbus-tcp:1.0.0", "language": "golang", "support_version": { "is_default": true, "docker_params_switch": true, "docker_params": "--memory 512m --cpu-shares 512", "expert_mode": false, "config_json": "{\"server_port\": 502, \"timeout\": 3000}" } }' ``` -------------------------------- ### Query Historical Device Property Data (API) Source: https://context7.com/winc-link/hummingbird/llms.txt Retrieves historical property data for a specific device within a given time range. Requires deviceId, property code, start and end timestamps, and pagination parameters. Authentication is handled via the x-token header. ```curl curl -X GET "http://localhost:8082/v1.0/openapi/queryDevicePropertyData?deviceId=device-uuid&code=temperature&startTime=1699900000000&endTime=1700000000000&page=1&pageSize=100" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Hummingbird Configuration File Structure Source: https://context7.com/winc-link/hummingbird/llms.txt Defines the configuration structure for the Hummingbird platform, including settings for the service, web server, message queue (MQTT), databases (metadata and data), Docker management, and general application settings like log level and time zone. ```toml # /cmd/hummingbird-core/res/configuration.toml [Service] Host = "0.0.0.0" Port = 8082 ReadTimeout = 60000 WriteTimeout = 60000 MaxRequestSize = 10485760 [WebServer] Host = "0.0.0.0" Port = 8080 [MessageQueue] Host = "localhost" Port = 58090 Protocol = "tcp" Type = "mqtt" SubscribeTopics = [ "/sys/#", "eventbus/#" ] PublishTopicPrefix = "/sys" [Databases.Metadata] Type = "sqlite" Host = "localhost" Port = 3306 Username = "root" Password = "password" Name = "hummingbird" MaxIdle = 10 MaxOpen = 100 MaxLifetime = 3600 [Databases.Data] Type = "sqlite" Name = "hummingbird_data" [DockerManage] ContainerConfigPath = "/etc/driver/res" HostRootDir = "/opt/hummingbird" DockerApiVersion = "1.41" Privileged = false [ApplicationSettings] LogLevel = "INFO" EnableProfiler = false TimeZone = "Asia/Shanghai" ``` -------------------------------- ### OpenAPI Device Control Endpoints Source: https://context7.com/winc-link/hummingbird/llms.txt These `curl` commands demonstrate how to control devices programmatically using the OpenAPI. They cover setting device properties, invoking device services asynchronously, and querying device property data. Authentication is handled via an 'x-token' header. ```bash # Set device property value curl -X POST "http://localhost:8082/v1.0/openapi/setDeviceProperty" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "deviceId": "device-uuid", "code": "switch", "value": true }' ``` ```bash # Invoke device service curl -X POST "http://localhost:8082/v1.0/openapi/invokeThingService" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "deviceId": "device-uuid", "serviceCode": "setThreshold", "params": { "threshold": 95.0 }, "callType": "async" }' ``` ```bash # Query effective (real-time) property data curl -X GET "http://localhost:8082/v1.0/openapi/queryDeviceEffectivePropertyData?deviceId=device-uuid&code=temperature" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### MQTT Message Publishing API for Devices Source: https://context7.com/winc-link/hummingbird/llms.txt This section details how devices can publish various types of messages to the platform using MQTT. It covers property updates, events, device status, and responses to service invocations. These commands use `mosquitto_pub` and require specific topics and JSON payloads. ```bash # Device publishes property data mosquitto_pub -h localhost -p 58090 \ -u "device-username" -P "device-password" \ -t "/sys/abc123/device-uuid/thing/property/post" \ -m '{ "deviceId": "device-uuid", "messageType": "PROPERTY_REPORT", "data": { "temperature": { "value": 25.5, "time": 1700000000000 }, "humidity": { "value": 65.2, "time": 1700000000000 } } }' ``` ```bash # Device reports an event mosquitto_pub -h localhost -p 58090 \ -u "device-username" -P "device-password" \ -t "/sys/abc123/device-uuid/thing/event/post" \ -m '{ "deviceId": "device-uuid", "messageType": "EVENT_REPORT", "data": { "eventCode": "overheat", "eventType": "alert", "eventData": { "temperature": 105.5, "threshold": 100.0 }, "time": 1700000000000 } }' ``` ```bash # Device reports online/offline status mosquitto_pub -h localhost -p 58090 \ -u "device-username" -P "device-password" \ -t "/sys/abc123/device-uuid/status" \ -m '{ "deviceId": "device-uuid", "messageType": "DEVICE_STATUS", "data": { "status": "online", "time": 1700000000000 } }' ``` ```bash # Device responds to service invocation mosquitto_pub -h localhost -p 58090 \ -u "device-username" -P "device-password" \ -t "/sys/abc123/device-uuid/thing/service/response" \ -m '{ "requestId": "req-uuid", "serviceCode": "setThreshold", "result": true, "outputParams": { "result": true }, "time": 1700000000000 }' ``` -------------------------------- ### Release Product - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Releases a product, making it available for device association. Requires authentication and the product ID. This is a POST request to the product-release endpoint. ```bash curl -X POST "http://localhost:8082/api/v1/product-release/abc123" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Device Management API Source: https://context7.com/winc-link/hummingbird/llms.txt APIs for registering, monitoring, and managing IoT devices, including retrieval of MQTT authentication credentials. ```APIDOC ## POST /api/v1/device ### Description Adds a new IoT device to the platform. ### Method POST ### Endpoint /api/v1/device ### Parameters #### Request Body - **name** (string) - Required - The name of the device. - **device_id** (string) - Required - The unique identifier for the device. - **device_sn** (string) - Optional - The serial number of the device. - **product_id** (string) - Required - The ID of the product this device belongs to. - **driver_instance_id** (string) - Optional - The ID of the driver instance associated with the device. - **platform** (string) - Optional - The platform the device is associated with. - **description** (string) - Optional - A description of the device. ### Request Example ```json { "name": "Warehouse-Sensor-001", "device_id": "sensor-001", "device_sn": "SN123456789", "product_id": "abc123", "driver_instance_id": "driver-instance-id", "platform": "LocalIot", "description": "Main warehouse temperature sensor" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **code** (string) - The HTTP status code. - **data** (string) - The generated ID of the created device. #### Response Example ```json { "success": true, "code": "200", "data": "device-id-generated-uuid" } ``` ## GET /api/v1/devices ### Description Searches for devices with support for pagination and filtering by various attributes. ### Method GET ### Endpoint /api/v1/devices ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **name** (string) - Optional - Filter by device name. - **status** (string) - Optional - Filter by device status (e.g., 'online', 'offline'). ### Response #### Success Response (200) - **data** (array) - An array of device objects. - **id** (string) - The device ID. - **name** (string) - The device name. - **product_id** (string) - The ID of the associated product. - **product_name** (string) - The name of the associated product. - **status** (string) - The current status of the device. - **last_online_time** (integer) - Timestamp of the last online event. - **driver_service_name** (string) - The name of the driver service. - **created** (integer) - Timestamp of device creation. - **total** (integer) - The total number of devices found. - **page** (integer) - The current page number. - **pageSize** (integer) - The number of items per page. #### Response Example ```json { "data": [ { "id": "device-uuid", "name": "Warehouse-Sensor-001", "product_id": "abc123", "product_name": "Industrial Temperature Sensor", "status": "online", "last_online_time": 1700000000000, "driver_service_name": "modbus-driver", "created": 1699900000000 } ], "total": 1, "page": 1, "pageSize": 20 } ``` ## GET /api/v1/device-mqtt/{deviceId} ### Description Retrieves the MQTT authentication credentials for a specific device, enabling it to connect to the MQTT broker. ### Method GET ### Endpoint /api/v1/device-mqtt/{deviceId} ### Parameters #### Path Parameters - **deviceId** (string) - Required - The ID of the device for which to get MQTT credentials. ### Response #### Success Response (200) - **clientId** (string) - The MQTT client ID. - **username** (string) - The MQTT username. - **password** (string) - The generated MQTT password. - **mqttHostUrl** (string) - The URL of the MQTT broker. - **port** (integer) - The port of the MQTT broker. #### Response Example ```json { "clientId": "device-uuid", "username": "device-001", "password": "generated-password", "mqttHostUrl": "tcp://localhost", "port": 58090 } ``` ## PUT /api/v1/device/{deviceId} ### Description Updates the properties of an existing device. ### Method PUT ### Endpoint /api/v1/device/{deviceId} ### Parameters #### Path Parameters - **deviceId** (string) - Required - The ID of the device to update. #### Request Body - **id** (string) - Required - The ID of the device. - **name** (string) - Optional - The new name for the device. - **description** (string) - Optional - The updated description for the device. - **install_location** (string) - Optional - The updated installation location. ### Request Example ```json { "id": "device-uuid", "name": "Warehouse-Sensor-001-Updated", "description": "Updated description", "install_location": "Zone A, Shelf 5" } ``` ### Response #### Success Response (200) - (Details of success response can vary, typically indicates successful update) ``` -------------------------------- ### Bind Devices to a Driver Instance Source: https://context7.com/winc-link/hummingbird/llms.txt Assigns a list of devices to a specific driver instance. ```APIDOC ## PUT /api/v1/devices/bind-driver ### Description Binds a list of devices to a specified driver instance. ### Method PUT ### Endpoint `/api/v1/devices/bind-driver` ### Parameters #### Request Body - **driver_instance_id** (string) - Required - The ID of the driver instance to bind devices to. - **device_ids** (array[string]) - Required - A list of device IDs to bind. ### Request Example ```json { "driver_instance_id": "driver-instance-id", "device_ids": ["device-uuid-1", "device-uuid-2"] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the binding. #### Response Example ```json { "message": "Devices bound to driver instance successfully." } ``` ``` -------------------------------- ### Driver Management API Source: https://context7.com/winc-link/hummingbird/llms.txt This API provides endpoints for managing Docker-based device drivers, including configuring Docker registries, adding driver libraries, and querying driver information. ```APIDOC ## POST /api/v1/docker-configs ### Description Adds a Docker registry configuration. ### Method POST ### Endpoint /api/v1/docker-configs ### Parameters #### Request Body - **address** (string) - Required - The address of the Docker registry (e.g., 'registry.example.com:5000'). - **account** (string) - Required - The username for registry authentication. - **password** (string) - Required - The password for registry authentication. ### Request Example ```json { "address": "registry.example.com:5000", "account": "registry_user", "password": "registry_password" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (string) - The ID of the created Docker configuration. #### Response Example ```json { "success": true, "data": "docker-config-id" } ``` ## POST /api/v1/device-libraries ### Description Adds a new driver library. ### Method POST ### Endpoint /api/v1/device-libraries ### Parameters #### Request Body - **name** (string) - Required - The name of the driver library. - **description** (string) - Optional - A description of the driver. - **protocol** (string) - Required - The communication protocol the driver supports (e.g., 'modbus-tcp'). - **version** (string) - Required - The version of the driver. - **container_name** (string) - Required - The name of the Docker container for the driver. - **docker_config_id** (string) - Required - The ID of the Docker registry configuration. - **docker_repo_name** (string) - Required - The Docker repository and image name (e.g., 'iot-drivers/modbus-tcp:1.0.0'). - **language** (string) - Required - The programming language used for the driver (e.g., 'golang'). - **support_version** (object) - Required - Details about driver support versions. - **is_default** (boolean) - Indicates if this is the default version. - **docker_params_switch** (boolean) - Whether Docker parameters are enabled. - **docker_params** (string) - String containing Docker runtime parameters. - **expert_mode** (boolean) - Whether expert mode is enabled. - **config_json** (string) - JSON string representing default configuration. ### Request Example ```json { "name": "Modbus TCP Driver", "description": "Driver for Modbus TCP protocol devices", "protocol": "modbus-tcp", "version": "1.0.0", "container_name": "modbus-driver", "docker_config_id": "docker-config-id", "docker_repo_name": "iot-drivers/modbus-tcp:1.0.0", "language": "golang", "support_version": { "is_default": true, "docker_params_switch": true, "docker_params": "--memory 512m --cpu-shares 512", "expert_mode": false, "config_json": "{\"server_port\": 502, \"timeout\": 3000}" } } ``` ### Response (No specific success response detailed in the provided text for POST device-libraries, but assumed to be similar to other successful operations.) ## GET /api/v1/device-libraries ### Description Queries a list of available driver libraries. ### Method GET ### Endpoint /api/v1/device-libraries ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **protocol** (string) - Optional - Filter drivers by protocol (e.g., 'modbus'). ### Response #### Success Response (200) - **data** (array) - An array of driver library objects. - **id** (string) - The unique ID of the driver library. - **name** (string) - The name of the driver library. - **protocol** (string) - The communication protocol. - **version** (string) - The version of the driver. - **container_name** (string) - The name of the Docker container. - **operate_status** (string) - The operational status of the driver. - **language** (string) - The programming language. - **created** (integer) - The timestamp when the driver was created. - **total** (integer) - The total number of driver libraries matching the query. #### Response Example ```json { "data": [ { "id": "library-uuid", "name": "Modbus TCP Driver", "protocol": "modbus-tcp", "version": "1.0.0", "container_name": "modbus-driver", "operate_status": "ready", "language": "golang", "created": 1700000000000 } ], "total": 1 } ``` ``` -------------------------------- ### Product Management API Source: https://context7.com/winc-link/hummingbird/llms.txt APIs for creating, querying, retrieving, releasing, and deleting IoT product definitions. These products are defined using thing models which standardize device capabilities. ```APIDOC ## POST /api/v1/product ### Description Creates a new IoT product definition. ### Method POST ### Endpoint /api/v1/product ### Parameters #### Request Body - **name** (string) - Required - The name of the product. - **key** (string) - Required - A unique key for the product. - **category_template_id** (string) - Required - The ID of the category template. - **protocol** (string) - Required - The communication protocol used by the device. - **node_type** (string) - Required - The type of node (e.g., 'direct'). - **net_type** (string) - Required - The network type (e.g., 'wifi'). - **data_format** (string) - Required - The data format (e.g., 'json'). - **factory** (string) - Optional - The manufacturer of the product. - **description** (string) - Optional - A description of the product. ### Request Example ```json { "name": "Industrial Temperature Sensor", "key": "temp-sensor-v1", "category_template_id": "1", "protocol": "modbus", "node_type": "direct", "net_type": "wifi", "data_format": "json", "factory": "ACME Manufacturing", "description": "High-precision industrial temperature monitoring device" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **code** (string) - The HTTP status code. - **data** (string) - The generated ID of the created product. #### Response Example ```json { "success": true, "code": "200", "data": "product-id-generated-uuid" } ``` ## GET /api/v1/products ### Description Queries products with pagination and filtering capabilities. ### Method GET ### Endpoint /api/v1/products ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **name** (string) - Optional - Filter by product name. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of product objects. - **id** (string) - The product ID. - **product_id** (string) - The product identifier. - **name** (string) - The product name. - **key** (string) - The product key. - **status** (string) - The product status. - **node_type** (string) - The node type. - **platform** (string) - The associated platform. - **created_at** (integer) - Timestamp of creation. - **category_name** (string) - The name of the category. - **total** (integer) - The total number of products found. - **page** (integer) - The current page number. - **pageSize** (integer) - The number of items per page. #### Response Example ```json { "success": true, "data": [ { "id": "abc123", "product_id": "abc123", "name": "Industrial Temperature Sensor", "key": "temp-sensor-v1", "status": "unreleased", "node_type": "direct", "platform": "LocalIot", "created_at": 1700000000000, "category_name": "Custom Product" } ], "total": 1, "page": 1, "pageSize": 20 } ``` ## GET /api/v1/product/{productId} ### Description Retrieves details of a specific product, including its thing model (properties, events, actions). ### Method GET ### Endpoint /api/v1/product/{productId} ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product to retrieve. ### Response #### Success Response (200) - **id** (string) - The product ID. - **name** (string) - The product name. - **status** (string) - The product status. - **properties** (array) - List of product properties. - **events** (array) - List of product events. - **actions** (array) - List of product actions. #### Response Example ```json { "id": "abc123", "name": "Industrial Temperature Sensor", "status": "unreleased", "properties": [...], "events": [...], "actions": [...] } ``` ## POST /api/v1/product-release/{productId} ### Description Releases a product, making it available for device association. ### Method POST ### Endpoint /api/v1/product-release/{productId} ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product to release. ### Response #### Success Response (200) - (Details of success response can vary, typically indicates successful release) ## DELETE /api/v1/product/{productId} ### Description Deletes a product. This operation is only allowed if no devices are currently associated with the product. ### Method DELETE ### Endpoint /api/v1/product/{productId} ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product to delete. ### Response #### Success Response (200) - (Details of success response can vary, typically indicates successful deletion) ``` -------------------------------- ### Add Device - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Registers a new IoT device in the Hummingbird platform. Requires authentication and a JSON payload with device information, including product ID. Returns a success status and the generated device ID. ```bash curl -X POST "http://localhost:8082/api/v1/device" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Warehouse-Sensor-001", "device_id": "sensor-001", "device_sn": "SN123456789", "product_id": "abc123", "driver_instance_id": "driver-instance-id", "platform": "LocalIot", "description": "Main warehouse temperature sensor" }' ``` -------------------------------- ### Search Devices - Hummingbird API Source: https://context7.com/winc-link/hummingbird/llms.txt Retrieves a list of registered devices with support for pagination and filtering by name and status. Requires authentication and accepts query parameters. Returns a list of devices matching the criteria. ```bash curl -X GET "http://localhost:8082/api/v1/devices?page=1&pageSize=20&name=Warehouse&status=online" \ -H "x-token: YOUR_AUTH_TOKEN" ``` -------------------------------- ### Create Alert Rule Source: https://context7.com/winc-link/hummingbird/llms.txt Creates a new alert rule with specified name, type, level, and description. It returns a unique rule ID upon successful creation. This is the initial step in setting up intelligent alerting. ```bash # Step 1: Create an alert rule curl -X POST "http://localhost:8082/api/v1/alert-rule" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "High Temperature Alert", "alert_type": "device", "alert_level": "urgent", "description": "Alert when temperature exceeds 100°C" }' ``` -------------------------------- ### Add Docker Registry Configuration Source: https://context7.com/winc-link/hummingbird/llms.txt Adds a Docker registry configuration, including its address, username, and password. This is essential for pulling Docker images for device drivers from private or specific registries. ```bash # Add a Docker registry configuration curl -X POST "http://localhost:8082/api/v1/docker-configs" \ -H "x-token: YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "address": "registry.example.com:5000", "account": "registry_user", "password": "registry_password" }' ```