From 50ff575dc82ab76460c28c7fc58ebf84f1b37c53 Mon Sep 17 00:00:00 2001 From: Pavel Stratil Date: Mon, 9 Oct 2023 05:03:38 +0000 Subject: [PATCH] rewrite it like mr. propper --- .../Config/Migrations/20230625214406_init.sql | 49 ------------------- .../Migrations/20231009002534_actions.sql | 18 +++++++ .../Config/Migrations/20231009002540_logs.sql | 19 +++++++ .../Migrations/20231009002603_services.sql | 18 +++++++ glued/Config/routes.yaml | 2 +- glued/Controllers/IfController.php | 7 +++ 6 files changed, 63 insertions(+), 50 deletions(-) delete mode 100644 glued/Config/Migrations/20230625214406_init.sql create mode 100644 glued/Config/Migrations/20231009002534_actions.sql create mode 100644 glued/Config/Migrations/20231009002540_logs.sql create mode 100644 glued/Config/Migrations/20231009002603_services.sql diff --git a/glued/Config/Migrations/20230625214406_init.sql b/glued/Config/Migrations/20230625214406_init.sql deleted file mode 100644 index 216277c..0000000 --- a/glued/Config/Migrations/20230625214406_init.sql +++ /dev/null @@ -1,49 +0,0 @@ --- migrate:up - -CREATE TABLE `t_if__actions` ( - `c_svc_uuid` binary(16) NOT NULL COMMENT 'IF instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', - `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF action uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', - `c_data` json NOT NULL COMMENT 'JSON data', - `c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework action type', - `c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework action note', - `c_freq` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.freq'))) STORED COMMENT '[STORED] Interface Framework action frequency', - PRIMARY KEY (`c_uuid`), - KEY `idx_svc_uuid` (`c_svc_uuid`), - KEY `idx_type` (`c_type`), - UNIQUE KEY `uniq_svc_uuid_type` (`c_svc_uuid`, `c_type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instance actions.'; - - -CREATE TABLE `t_if__services` ( - `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF service instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', - `c_data` json NOT NULL COMMENT 'JSON data', - `c_hash` varchar(32) GENERATED ALWAYS AS (MD5(`c_data`)) STORED COMMENT '[STORED] MD5 Hash of the data json (acting as a unique index)', - `c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework service type', - `c_name` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.name'))) STORED COMMENT '[STORED] Interface Framework service deployment name', - `c_host` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.host'))) STORED COMMENT '[STORED] Interface Framework remote host', - `c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework remote note', - PRIMARY KEY (`c_uuid`), - UNIQUE (`c_hash`), - KEY `idx_type` (`c_type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instances (service / remote host / authentication).'; - - -CREATE TABLE `t_if__logs` ( - `c_act_uuid` binary(16) NOT NULL COMMENT 'IF instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', - `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF instance logline uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', - `c_data` json NOT NULL COMMENT 'JSON response body (files will be attached to stor by c_svc_uuid/c_uuid', - `c_ts_requested` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: requested', - `c_ts_responded` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: responded', - `c_ok` tinyint(1) NULL DEFAULT NULL COMMENT 'Integration run success/fail', - `c_response_hash` varchar(255) NULL COMMENT 'Response data hash', - `c_response_fid` varchar(255) NULL COMMENT 'Response foreign identifier', - PRIMARY KEY (`c_uuid`), - INDEX idx_act_uuid (`c_act_uuid`), - INDEX idx_response_hash (`c_response_hash`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service logs.'; - --- migrate:down - -DROP TABLE IF EXISTS `t_if__logs`; -DROP TABLE IF EXISTS `t_if__actions`; -DROP TABLE IF EXISTS `t_if__services`; diff --git a/glued/Config/Migrations/20231009002534_actions.sql b/glued/Config/Migrations/20231009002534_actions.sql new file mode 100644 index 0000000..6d96616 --- /dev/null +++ b/glued/Config/Migrations/20231009002534_actions.sql @@ -0,0 +1,18 @@ +-- migrate:up + +CREATE TABLE `t_if__actions` ( + `c_svc_uuid` binary(16) NOT NULL COMMENT 'IF instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', + `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF action uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', + `c_data` json NOT NULL COMMENT 'JSON data', + `c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework action type', + `c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework action note', + `c_freq` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.freq'))) STORED COMMENT '[STORED] Interface Framework action frequency', + PRIMARY KEY (`c_uuid`), + UNIQUE KEY `uniq_svc_uuid_type` (`c_svc_uuid`,`c_type`), + KEY `idx_svc_uuid` (`c_svc_uuid`), + KEY `idx_type` (`c_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instance actions.'; + +-- migrate:down + +DROP TABLE IF EXISTS `t_if__actions`; diff --git a/glued/Config/Migrations/20231009002540_logs.sql b/glued/Config/Migrations/20231009002540_logs.sql new file mode 100644 index 0000000..6bf33fa --- /dev/null +++ b/glued/Config/Migrations/20231009002540_logs.sql @@ -0,0 +1,19 @@ +-- migrate:up + +CREATE TABLE `t_if__logs` ( + `c_act_uuid` binary(16) NOT NULL COMMENT 'IF instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', + `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF instance logline uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', + `c_data` json NOT NULL COMMENT 'JSON response body (files will be attached to stor by c_svc_uuid/c_uuid', + `c_ts_requested` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: requested', + `c_ts_responded` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: responded', + `c_ok` tinyint(1) DEFAULT NULL COMMENT 'Integration run success/fail', + `c_response_hash` varchar(255) DEFAULT NULL COMMENT 'Response data hash', + `c_response_fid` varchar(255) DEFAULT NULL COMMENT 'Response foreign identifier', + PRIMARY KEY (`c_uuid`), + KEY `idx_act_uuid` (`c_act_uuid`), + KEY `idx_response_hash` (`c_response_hash`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service logs.'; + +-- migrate:down + +DROP TABLE IF EXISTS `t_if__logs`; diff --git a/glued/Config/Migrations/20231009002603_services.sql b/glued/Config/Migrations/20231009002603_services.sql new file mode 100644 index 0000000..62b591f --- /dev/null +++ b/glued/Config/Migrations/20231009002603_services.sql @@ -0,0 +1,18 @@ +-- migrate:up + +DROP TABLE IF EXISTS `t_if__services`; + +-- migrate:down + +CREATE TABLE `t_if__services` ( + `c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF service instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)', + `c_data` json NOT NULL COMMENT 'JSON data', + `c_hash` varchar(32) GENERATED ALWAYS AS (md5(`c_data`)) STORED COMMENT '[STORED] MD5 Hash of the data json (acting as a unique index)', + `c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework service type', + `c_name` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.name'))) STORED COMMENT '[STORED] Interface Framework service deployment name', + `c_host` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.host'))) STORED COMMENT '[STORED] Interface Framework remote host', + `c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework remote note', + PRIMARY KEY (`c_uuid`), + UNIQUE KEY `c_hash` (`c_hash`), + KEY `idx_type` (`c_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instances (service / remote host / authentication).'; diff --git a/glued/Config/routes.yaml b/glued/Config/routes.yaml index 7046c39..377913a 100644 --- a/glued/Config/routes.yaml +++ b/glued/Config/routes.yaml @@ -61,7 +61,7 @@ routes: be_if_logs_v1: pattern: ${routes.be_if.path}/logs/v1 path: ${routes.be_if.path}/logs/v1 - label: IF Statistics + label: IF Logs dscr: Interface logs service: if methods: diff --git a/glued/Controllers/IfController.php b/glued/Controllers/IfController.php index e4ff9a2..e1ce0f7 100644 --- a/glued/Controllers/IfController.php +++ b/glued/Controllers/IfController.php @@ -129,6 +129,13 @@ public function reg_r1(Request $request, Response $response, array $args = []): return $response->withJson($res); } + public function stats_r1(Request $request, Response $response, array $args = []): Response + { + $res = ['status' => 'ok', 'message' => 'This endpoint is under development.']; + return $response->withJson($res); + } + + }