curl -H "x-customer-id: 77a1c9561c8d47fb8036c970a4f2ee73" "https://peter.backend.com/ui/appliances/?start=1736680946&applianceId=974bf535-7930-474e-8da6-780cafff284d" curl -H "x-customer-id: 77a1c9561c8d47fb8036c970a4f2ee73" "https://peter.backend.com/ui/appliances/?start=1736680946" curl https://peter.backend.com/ui/appliances/image/ curl -X DELETE https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/ curl -X POST https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/upgrade/ curl https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/settings/ curl -X POST https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/settings/ curl https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/storage/ curl -X POST https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/storage/ curl -X POST https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/log/ curl https://peter.backend.com/ui/appliances/974bf535-7930-474e-8da6-780cafff284d/services/
curl -X POST https://peter.backend.com/ui/services/squid/install/ curl -X POST https://peter.backend.com/ui/services/squid/974bf535-7930-474e-8da6-780cafff284d/toggle/ curl https://peter.backend.com/ui/services/squid/974bf535-7930-474e-8da6-780cafff284d/settings/ curl -X POST https://peter.backend.com/ui/services/squid/974bf535-7930-474e-8da6-780cafff284d/settings/
curl https://peter.backend.com/ui/tasks/12345/
API for VA
1 2 3 4 5 6
curl -X POST -H "Authorization: Bearer $token" -i https://peter.backend.com/va/register/ curl -X POST https://peter.backend.com/va/register/ curl -X POST https://peter.backend.com/va/974bf535-7930-474e-8da6-780cafff284d/tasks/ curl https://peter.backend.com/va/974bf535-7930-474e-8da6-780cafff284d/healthz/ curl -X POST https://peter.backend.com/va/974bf535-7930-474e-8da6-780cafff284d/log/ curl -X POST https://peter.backend.com/va/974bf535-7930-474e-8da6-780cafff284d/squid/metrics/
backend Design
Database Design
Customer表
1 2 3 4 5 6 7 8 9
desc app_customer; +----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+-------+ | id | char(32) | NO | PRI | NULL | | | register_token | longtext | NO | | NULL | | | created_at | datetime(6) | NO | | NULL | | | updated_at | datetime(6) | NO | | NULL | | +----------------+-------------+------+-----+---------+-------+
ApplianceInfo表
1 2 3 4 5 6 7 8 9 10 11 12 13
desc app_applianceinfo; +--------------------+-------------+------+-----+----------------+-------------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+-------------+------+-----+----------------+-------------------+ | id | char(32) | NO | PRI | NULL | | | customer_id | char(32) | NO | MUL | NULL | | | created_at | datetime(6) | NO | | NULL | | | updated_at | datetime(6) | NO | | NULL | | | version | varchar(16) | NO | | NULL | | | status | varchar(16) | NO | | NULL | | | appliance_settings | json | NO | | NULL | | | capacity | json | NO | | _utf8mb3\'{}\' | DEFAULT_GENERATED | +--------------------+-------------+------+-----+----------------+-------------------+
IotTask表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
> desc app_iottask; +---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | id | char(32) | NO | PRI | NULL | | | created_at | datetime(6) | NO | MUL | NULL | | | updated_at | datetime(6) | NO | | NULL | | | task_type | varchar(50) | NO | MUL | NULL | | | appliance_id | char(32) | NO | MUL | NULL | | | customer_id | char(32) | NO | | NULL | | | message | json | NO | | NULL | | | status | varchar(16) | NO | MUL | NULL | | | retry_count | int | NO | | NULL | | | result | json | NO | | NULL | | | error_message | longtext | NO | | NULL | | +---------------+-------------+------+-----+---------+-------+
ApplianceVersion表
1 2 3 4 5 6 7 8 9 10 11 12 13 14
mysql> desc app_applianceversion; +------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+-------------+------+-----+---------+-------+ | version | varchar(32) | NO | PRI | NULL | | | created_at | datetime(6) | NO | | NULL | | | updated_at | datetime(6) | NO | | NULL | | | version_major | int | NO | | NULL | | | version_minor | int | NO | | NULL | | | version_revision | int | NO | | NULL | | | version_build | int | NO | | NULL | | | display_version | varchar(32) | NO | | NULL | | | firmware_info | json | NO | | NULL | | +------------------+-------------+------+-----+---------+-------+
HeartbeatIotTask表
1 2 3 4 5 6 7 8 9 10 11 12 13 14
desc app_heartbeatiottask; +---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+----------------+ | id | bigint | NO | PRI | NULL | auto_increment | | created_at | datetime(6) | NO | MUL | NULL | | | updated_at | datetime(6) | NO | | NULL | | | appliance_id | char(32) | NO | MUL | NULL | | | customer_id | char(32) | NO | | NULL | | | message | json | NO | | NULL | | | status | varchar(16) | NO | MUL | NULL | | | result | json | NO | | NULL | | | error_message | longtext | NO | | NULL | | +---------------+-------------+------+-----+---------+----------------+