From 8f47b7578138abdc5ae0ba28b64d285f3be7d2c1 Mon Sep 17 00:00:00 2001 From: Johanna Szepanski <johanna.szepanski@softhouse.se> Date: Fri, 11 Oct 2024 09:44:44 +0200 Subject: [PATCH] updated api --- src/mocks/fixtures/ccce-api.json | 1222 ++++++++++++++---------------- src/store/deployApi.ts | 113 +-- 2 files changed, 612 insertions(+), 723 deletions(-) diff --git a/src/mocks/fixtures/ccce-api.json b/src/mocks/fixtures/ccce-api.json index a2eb1dc8..71f86e6c 100644 --- a/src/mocks/fixtures/ccce-api.json +++ b/src/mocks/fixtures/ccce-api.json @@ -3,7 +3,7 @@ "info": { "title": "CE deploy & monitor API", "description": "CE deploy & monitor backend", - "version": "2.2.0" + "version": "2.3.0" }, "servers": [ { @@ -22,13 +22,16 @@ "name": "Authentication" }, { - "name": "Jobs" + "name": "AWX" }, { - "name": "Records" + "name": "Inventory" + }, + { + "name": "Jobs" }, { - "name": "Statistics" + "name": "Records" }, { "name": "Maintenance" @@ -57,18 +60,18 @@ "required": true }, "responses": { - "201": { - "description": "Maintenance Mode Changed", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MaintenanceMode" + "$ref": "#/components/schemas/GeneralException" } } } }, - "503": { - "description": "Remote service exception", + "422": { + "description": "Unprocessable request", "content": { "application/json": { "schema": { @@ -77,8 +80,8 @@ } } }, - "422": { - "description": "Unprocessable request", + "400": { + "description": "Incomplete request", "content": { "application/json": { "schema": { @@ -87,18 +90,18 @@ } } }, - "400": { - "description": "Incomplete request", + "201": { + "description": "Maintenance Mode Changed", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/MaintenanceMode" } } } }, - "409": { - "description": "Maintenance Mode already set to that value", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { @@ -107,8 +110,8 @@ } } }, - "500": { - "description": "Service exception", + "409": { + "description": "Maintenance Mode already set to that value", "content": { "application/json": { "schema": { @@ -117,8 +120,8 @@ } } }, - "403": { - "description": "Forbidden: User doesn't have the necessary permissions", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -127,8 +130,8 @@ } } }, - "401": { - "description": "Unauthorized", + "403": { + "description": "Forbidden: User doesn't have the necessary permissions", "content": { "application/json": { "schema": { @@ -173,8 +176,8 @@ "required": true }, "responses": { - "409": { - "description": "Concurrent deployment, undeployment, start or stop for IOC is ongoing", + "424": { + "description": "Metadata file not found, or not processable", "content": { "application/json": { "schema": { @@ -183,8 +186,8 @@ } } }, - "503": { - "description": "Remote service exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -193,8 +196,8 @@ } } }, - "422": { - "description": "IOC has no active / NetBox host not found / IOC is not deployed correctly", + "403": { + "description": "Forbidden: User doesn't have the necessary permissions in Gitlab", "content": { "application/json": { "schema": { @@ -203,8 +206,8 @@ } } }, - "400": { - "description": "Incomplete request", + "404": { + "description": "IOC not found", "content": { "application/json": { "schema": { @@ -213,8 +216,8 @@ } } }, - "404": { - "description": "IOC not found", + "400": { + "description": "Incomplete request", "content": { "application/json": { "schema": { @@ -223,8 +226,8 @@ } } }, - "500": { - "description": "Service exception", + "422": { + "description": "IOC has no active / NetBox host not found / IOC is not deployed correctly", "content": { "application/json": { "schema": { @@ -233,8 +236,8 @@ } } }, - "403": { - "description": "Forbidden: User doesn't have the necessary permissions in Gitlab", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { @@ -243,28 +246,28 @@ } } }, - "201": { - "description": "IOC job initiated", + "409": { + "description": "Concurrent deployment, undeployment, start or stop for IOC is ongoing", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Job" + "$ref": "#/components/schemas/GeneralException" } } } }, - "401": { - "description": "Unauthorized", + "201": { + "description": "IOC job initiated", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/Job" } } } }, - "424": { - "description": "Metadata file not found, or not processable", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -414,22 +417,22 @@ } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "A paged array of IOCs", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/PagedIocResponse" } } } }, - "200": { - "description": "A paged array of IOCs", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedIocResponse" + "$ref": "#/components/schemas/GeneralException" } } } @@ -451,8 +454,8 @@ "required": true }, "responses": { - "503": { - "description": "Remote service exception", + "424": { + "description": "Metadata file not found, or not processable", "content": { "application/json": { "schema": { @@ -461,8 +464,8 @@ } } }, - "422": { - "description": "Unprocessable request", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -471,18 +474,18 @@ } } }, - "400": { - "description": "Incomplete, or bad request", + "201": { + "description": "IOC created", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/Ioc" } } } }, - "500": { - "description": "Service exception", + "403": { + "description": "Forbidden: User doesn't have the necessary permissions in Gitlab", "content": { "application/json": { "schema": { @@ -491,8 +494,8 @@ } } }, - "403": { - "description": "Forbidden: User doesn't have the necessary permissions in Gitlab", + "422": { + "description": "Unprocessable request", "content": { "application/json": { "schema": { @@ -501,12 +504,12 @@ } } }, - "201": { - "description": "IOC created", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Ioc" + "$ref": "#/components/schemas/GeneralException" } } } @@ -521,6 +524,16 @@ } } }, + "400": { + "description": "Incomplete, or bad request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -530,9 +543,63 @@ } } } + } + }, + "security": [ + { + "bearerAuth": [] + } + ] + } + }, + "/api/v1/awx/jobs": { + "post": { + "tags": ["AWX"], + "summary": "Update an AWX job's status", + "operationId": "updateJob", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AwxJobMeta" + } + } }, - "424": { - "description": "Metadata file not found, or not processable", + "required": true + }, + "responses": { + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "404": { + "description": "Job not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "200": { + "description": "Job updated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -544,7 +611,7 @@ }, "security": [ { - "bearerAuth": [] + "apiKey": [] } ] } @@ -556,8 +623,8 @@ "description": "Renewing valid, non-expired JWT token", "operationId": "tokenRenew", "responses": { - "503": { - "description": "Login server unavailable", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -586,8 +653,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Login server unavailable", "content": { "application/json": { "schema": { @@ -631,8 +698,8 @@ "required": true }, "responses": { - "503": { - "description": "Login server unavailable", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -641,22 +708,22 @@ } } }, - "200": { - "description": "Ok", + "401": { + "description": "Bad username, and/or password", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LoginResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "401": { - "description": "Bad username, and/or password", + "200": { + "description": "Ok", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/LoginResponse" } } } @@ -671,8 +738,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Login server unavailable", "content": { "application/json": { "schema": { @@ -702,28 +769,28 @@ } ], "responses": { - "200": { - "description": "Found IOC", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocDetails" + "$ref": "#/components/schemas/GeneralException" } } } }, - "404": { - "description": "Ioc not found", + "200": { + "description": "Found IOC", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/IocDetails" } } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Ioc not found", "content": { "application/json": { "schema": { @@ -761,8 +828,8 @@ } ], "responses": { - "409": { - "description": "Concurrent deployment, undeployment, start or stop for IOC is ongoing", + "503": { + "description": "Git repository can not be deleted", "content": { "application/json": { "schema": { @@ -791,6 +858,16 @@ } } }, + "409": { + "description": "Concurrent deployment, undeployment, start or stop for IOC is ongoing", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "204": { "description": "IOC deleted", "content": { @@ -801,8 +878,8 @@ } } }, - "503": { - "description": "Git repository can not be deleted", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -820,16 +897,6 @@ } } } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } }, "security": [ @@ -865,8 +932,8 @@ "required": true }, "responses": { - "503": { - "description": "Remote service exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -875,12 +942,12 @@ } } }, - "409": { - "description": "IOC already created or concurrent deployment, undeployment, start or stop for IOC is ongoing", + "200": { + "description": "IOC updated", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/Ioc" } } } @@ -905,8 +972,8 @@ } } }, - "500": { - "description": "Service exception", + "409": { + "description": "IOC already created or concurrent deployment, undeployment, start or stop for IOC is ongoing", "content": { "application/json": { "schema": { @@ -915,18 +982,18 @@ } } }, - "200": { - "description": "IOC updated", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Ioc" + "$ref": "#/components/schemas/GeneralException" } } } }, - "403": { - "description": "Forbidden: User doesn't have the necessary permissions", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -935,8 +1002,8 @@ } } }, - "401": { - "description": "Unauthorized", + "403": { + "description": "Forbidden: User doesn't have the necessary permissions", "content": { "application/json": { "schema": { @@ -972,21 +1039,18 @@ } ], "responses": { - "200": { - "description": "Undeployment created", + "409": { + "description": "Ongoing deployment, or undeployment for IOC", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Deployment" - } + "$ref": "#/components/schemas/GeneralException" } } } }, - "422": { - "description": "IOC is not deployed", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1005,8 +1069,8 @@ } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { @@ -1015,8 +1079,8 @@ } } }, - "404": { - "description": "Not found", + "422": { + "description": "IOC is not deployed", "content": { "application/json": { "schema": { @@ -1025,8 +1089,8 @@ } } }, - "409": { - "description": "Ongoing deployment, or undeployment for IOC", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -1035,12 +1099,15 @@ } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "Undeployment created", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "$ref": "#/components/schemas/Deployment" + } } } } @@ -1082,8 +1149,8 @@ "required": true }, "responses": { - "409": { - "description": "Ongoing operation for IOC", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1092,15 +1159,12 @@ } } }, - "200": { - "description": "Successful host update", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Ioc" - } + "$ref": "#/components/schemas/GeneralException" } } } @@ -1115,8 +1179,8 @@ } } }, - "500": { - "description": "Service exception", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -1125,12 +1189,15 @@ } } }, - "404": { - "description": "Not found", + "200": { + "description": "Successful host update", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "$ref": "#/components/schemas/Ioc" + } } } } @@ -1145,8 +1212,8 @@ } } }, - "401": { - "description": "Unauthorized", + "409": { + "description": "Ongoing operation for IOC", "content": { "application/json": { "schema": { @@ -1163,190 +1230,17 @@ ] } }, - "/api/v1/statistics/general/{statistics_type}": { - "get": { - "tags": ["Statistics"], - "summary": "Calculating statistics", - "operationId": "calculateStatistics", - "parameters": [ - { - "name": "statistics_type", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "HOSTS_REGISTERED", - "HOSTS_WITH_IOCS", - "HOSTS_REACHABLE", - "HOSTS_WITH_ACTIVE_IOCS", - "IOCS_REGISTERED", - "IOCS_DEPLOYED", - "IOCS_RUNNING" - ] - } - } - ], - "responses": { - "200": { - "description": "Calculate statistics", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/StatisticResponse" - } - } - } - }, - "400": { - "description": "Unsupported statistic type", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - } - } - } - }, - "/api/v1/statistics/general/operation_history": { - "get": { - "tags": ["Statistics"], - "summary": "Operation history from DB for statistics", - "operationId": "operationHistory", - "responses": { - "200": { - "description": "Operations history from DB for statistics", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OperationStatisticsResponse" - } - } - } - }, - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - } - } - } - }, - "/api/v1/statistics/general/active_ioc_statistics": { + "/healthcheck": { "get": { - "tags": ["Statistics"], - "summary": "Currently active IOC statistics", - "operationId": "currentlyActiveIocs", + "tags": ["health-check-controller"], + "operationId": "getHealthCheck", "responses": { - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, "200": { - "description": "Statistics about currently active IOCs", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ActiveIocStatisticsResponse" - } - } - } - } - }, - "401": { - "description": "Unauthorized", + "description": "OK", "content": { - "application/json": { + "*/*": { "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - } - } - } - }, - "/api/v1/statistics/general/active_ioc_history": { - "get": { - "tags": ["Statistics"], - "summary": "Active IOC history from Prometheus for statistics", - "operationId": "activeIocHistory", - "responses": { - "200": { - "description": "History about active IOCs for statistics", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ActiveIOCSForHistoryResponse" - } - } - } - } - }, - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "string" } } } @@ -1410,12 +1304,12 @@ } ], "responses": { - "200": { - "description": "A paged array of Channel Finder records", + "503": { + "description": "Remote server exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedRecordResponse" + "$ref": "#/components/schemas/GeneralException" } } } @@ -1430,12 +1324,12 @@ } } }, - "503": { - "description": "Remote server exception", + "200": { + "description": "A paged array of Channel Finder records", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/PagedRecordResponse" } } } @@ -1460,12 +1354,12 @@ } ], "responses": { - "200": { - "description": "Found record", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RecordDetails" + "$ref": "#/components/schemas/GeneralException" } } } @@ -1480,12 +1374,12 @@ } } }, - "500": { - "description": "Service exception", + "200": { + "description": "Found record", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/RecordDetails" } } } @@ -1510,16 +1404,6 @@ } ], "responses": { - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, "200": { "description": "Naming names, and UUIDs from the Names service", "content": { @@ -1543,6 +1427,16 @@ } } }, + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1579,12 +1473,12 @@ } ], "responses": { - "200": { - "description": "Ok", + "422": { + "description": "Too many IOCs use the same Naming UUID", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IdUsedByIoc" + "$ref": "#/components/schemas/GeneralException" } } } @@ -1599,12 +1493,12 @@ } } }, - "422": { - "description": "Too many IOCs use the same Naming UUID", + "200": { + "description": "Ok", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/IdUsedByIoc" } } } @@ -1618,8 +1512,8 @@ "summary": "Get Current Maintenance Mode", "operationId": "getCurrentMode", "responses": { - "404": { - "description": "Maintenance Mode not found", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1638,8 +1532,8 @@ } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Maintenance Mode not found", "content": { "application/json": { "schema": { @@ -1655,8 +1549,8 @@ "summary": "End Current Maintenance Mode", "operationId": "endCurrentMaintenanceMode", "responses": { - "503": { - "description": "Remote service exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1688,8 +1582,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { @@ -1698,8 +1592,8 @@ } } }, - "403": { - "description": "Forbidden: User doesn't have the necessary permissions", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -1708,8 +1602,8 @@ } } }, - "401": { - "description": "Unauthorized", + "403": { + "description": "Forbidden: User doesn't have the necessary permissions", "content": { "application/json": { "schema": { @@ -1866,22 +1760,22 @@ } ], "responses": { - "200": { - "description": "A paged array of deployments", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedJobResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "200": { + "description": "A paged array of deployments", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/PagedJobResponse" } } } @@ -1937,22 +1831,22 @@ } } }, - "200": { - "description": "Job details", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/JobDetails" + "$ref": "#/components/schemas/GeneralException" } } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "Job details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/JobDetails" } } } @@ -1978,8 +1872,8 @@ } ], "responses": { - "404": { - "description": "Job not found", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1988,8 +1882,8 @@ } } }, - "503": { - "description": "Remote service exception", + "404": { + "description": "Job not found", "content": { "application/json": { "schema": { @@ -1998,22 +1892,22 @@ } } }, - "200": { - "description": "Job details", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AwxJobDetails" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "200": { + "description": "Job details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/AwxJobDetails" } } } @@ -2049,8 +1943,8 @@ } ], "responses": { - "503": { - "description": "Remote service exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -2059,28 +1953,28 @@ } } }, - "404": { - "description": "Deployment not found", + "200": { + "description": "Job log", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/AwxJobLog" } } } }, - "200": { - "description": "Job log", + "404": { + "description": "Deployment not found", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AwxJobLog" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Remote service exception", "content": { "application/json": { "schema": { @@ -2135,12 +2029,12 @@ } } }, - "200": { - "description": "Log lines", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocStatusResponse" + "$ref": "#/components/schemas/GeneralException" } } } @@ -2155,12 +2049,12 @@ } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "Log lines", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/IocStatusResponse" } } } @@ -2186,28 +2080,28 @@ } ], "responses": { - "200": { - "description": "Found IOC description", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocDescriptionResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "404": { - "description": "Ioc not found", + "200": { + "description": "Found IOC description", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/IocDescriptionResponse" } } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Ioc not found", "content": { "application/json": { "schema": { @@ -2247,22 +2141,22 @@ } } }, - "200": { - "description": "Alerts of the IOC", + "404": { + "description": "Ioc not found", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocAlertResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "404": { - "description": "Ioc not found", + "200": { + "description": "Alerts of the IOC", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/IocAlertResponse" } } } @@ -2316,28 +2210,28 @@ } } }, - "200": { - "description": "Log lines", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LokiResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "503": { - "description": "Logging server unavailable", + "200": { + "description": "Log lines", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/LokiResponse" } } } }, - "401": { - "description": "Unauthorized", + "503": { + "description": "Logging server unavailable", "content": { "application/json": { "schema": { @@ -2373,6 +2267,16 @@ } ], "responses": { + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "200": { "description": "Ok", "content": { @@ -2382,7 +2286,15 @@ } } } - }, + } + } + } + }, + "/api/v1/inventory": { + "get": { + "tags": ["Inventory"], + "operationId": "fetchInventory", + "responses": { "500": { "description": "Service exception", "content": { @@ -2392,6 +2304,16 @@ } } } + }, + "200": { + "description": "Inventory response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InventoryResponse" + } + } + } } } } @@ -2453,28 +2375,28 @@ } ], "responses": { - "200": { - "description": "A paged array of hosts", + "503": { + "description": "Remote server exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedNetBoxHostResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "200": { + "description": "A paged array of hosts", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/PagedNetBoxHostResponse" } } } }, - "503": { - "description": "Remote server exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -2533,28 +2455,28 @@ } } }, - "200": { - "description": "Log lines", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LokiResponse" + "$ref": "#/components/schemas/GeneralException" } } } }, - "503": { - "description": "Logging server unavailable", + "200": { + "description": "Log lines", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/LokiResponse" } } } }, - "401": { - "description": "Unauthorized", + "503": { + "description": "Logging server unavailable", "content": { "application/json": { "schema": { @@ -2588,8 +2510,8 @@ } ], "responses": { - "500": { - "description": "Service exception", + "503": { + "description": "Remote server exception", "content": { "application/json": { "schema": { @@ -2598,12 +2520,12 @@ } } }, - "200": { - "description": "Host status", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HostStatusResponse" + "$ref": "#/components/schemas/GeneralException" } } } @@ -2618,12 +2540,12 @@ } } }, - "503": { - "description": "Remote server exception", + "200": { + "description": "Host status", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/HostStatusResponse" } } } @@ -2698,18 +2620,18 @@ } ], "responses": { - "200": { - "description": "Found Host", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedAssociatedIocs" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -2718,12 +2640,12 @@ } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "Found Host", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/PagedAssociatedIocs" } } } @@ -2748,18 +2670,18 @@ } ], "responses": { - "200": { - "description": "Found Host", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HostInfoWithId" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { @@ -2768,12 +2690,12 @@ } } }, - "404": { - "description": "Not found", + "200": { + "description": "Found Host", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/HostInfoWithId" } } } @@ -2808,12 +2730,12 @@ } ], "responses": { - "200": { - "description": "Host alerts", + "503": { + "description": "Remote server exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HostAlertResponse" + "$ref": "#/components/schemas/GeneralException" } } } @@ -2838,12 +2760,12 @@ } } }, - "503": { - "description": "Remote server exception", + "200": { + "description": "Host alerts", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/HostAlertResponse" } } } @@ -2868,18 +2790,18 @@ } ], "responses": { - "200": { - "description": "Found Host", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HostInfoWithId" + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { @@ -2888,12 +2810,12 @@ } } }, - "404": { - "description": "Not found", + "200": { + "description": "Found Host", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/HostInfoWithId" } } } @@ -2948,6 +2870,16 @@ } ], "responses": { + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "503": { "description": "Git exception", "content": { @@ -2958,8 +2890,8 @@ } } }, - "500": { - "description": "Service exception", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -2980,16 +2912,6 @@ } } } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } } } @@ -3020,9 +2942,9 @@ } } ], - "responses": { - "503": { - "description": "Git exception", + "responses": { + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3031,8 +2953,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3071,8 +2993,8 @@ } ], "responses": { - "503": { - "description": "Git exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3081,8 +3003,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3101,25 +3023,25 @@ } } }, - "200": { - "description": "Information about the current user", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInfoResponse" - } + "$ref": "#/components/schemas/GeneralException" } } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "Information about the current user", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "$ref": "#/components/schemas/UserInfoResponse" + } } } } @@ -3149,8 +3071,8 @@ } ], "responses": { - "503": { - "description": "Git exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3159,21 +3081,18 @@ } } }, - "200": { - "description": "List of Gitlab projects of allowed groups", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GitProject" - } + "$ref": "#/components/schemas/GeneralException" } } } }, - "500": { - "description": "Service exception", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -3182,12 +3101,15 @@ } } }, - "401": { - "description": "Unauthorized", + "200": { + "description": "List of Gitlab projects of allowed groups", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "$ref": "#/components/schemas/GitProject" + } } } } @@ -3218,8 +3140,8 @@ } ], "responses": { - "503": { - "description": "Git exception", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3228,12 +3150,12 @@ } } }, - "200": { - "description": "Git project details", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GitProjectDto" + "$ref": "#/components/schemas/GeneralException" } } } @@ -3248,12 +3170,12 @@ } } }, - "500": { - "description": "Service exception", + "200": { + "description": "Git project details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/GitProjectDto" } } } @@ -3279,8 +3201,8 @@ } ], "responses": { - "503": { - "description": "Login server unavailable", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3299,25 +3221,25 @@ } } }, - "500": { - "description": "Service exception", + "200": { + "description": "Ok", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "type": "string" + } } } } }, - "200": { - "description": "Ok", + "503": { + "description": "Login server unavailable", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/components/schemas/GeneralException" } } } @@ -3347,8 +3269,8 @@ "description": "Get user roles from authorization service", "operationId": "getUserRoles", "responses": { - "503": { - "description": "Login server unavailable", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3367,25 +3289,25 @@ } } }, - "500": { - "description": "Service exception", + "200": { + "description": "Ok", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "type": "array", + "items": { + "type": "string" + } } } } }, - "200": { - "description": "Ok", + "503": { + "description": "Login server unavailable", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/components/schemas/GeneralException" } } } @@ -3473,6 +3395,17 @@ }, "description": "Maintenance Mode to set to" }, + "GeneralException": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, "MaintenanceMode": { "type": "object", "properties": { @@ -3489,17 +3422,6 @@ } } }, - "GeneralException": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "description": { - "type": "string" - } - } - }, "CreateJobRequest": { "type": "object", "properties": { @@ -3719,6 +3641,40 @@ } } }, + "AwxJobMeta": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "started": { + "type": "string", + "format": "date-time" + }, + "finished": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "enum": [ + "UNKNOWN", + "CREATED", + "QUEUED_BY_BACKEND", + "new", + "pending", + "waiting", + "running", + "failed", + "canceled", + "error", + "successful" + ] + } + }, + "description": "Job to update" + }, "LoginResponse": { "type": "object", "properties": { @@ -3759,80 +3715,6 @@ }, "description": "IOC to update" }, - "StatisticResponse": { - "type": "object", - "properties": { - "value": { - "type": "integer", - "format": "int64" - }, - "statisticType": { - "type": "string", - "enum": [ - "HOSTS_REGISTERED", - "HOSTS_WITH_IOCS", - "HOSTS_REACHABLE", - "HOSTS_WITH_ACTIVE_IOCS", - "IOCS_REGISTERED", - "IOCS_DEPLOYED", - "IOCS_RUNNING" - ] - } - } - }, - "OperationStatistic": { - "type": "object", - "properties": { - "deploymentCount": { - "type": "integer", - "format": "int64" - }, - "commandCount": { - "type": "integer", - "format": "int64" - }, - "historyDate": { - "type": "string", - "format": "date-time" - } - } - }, - "OperationStatisticsResponse": { - "type": "object", - "properties": { - "operationStatistics": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OperationStatistic" - } - } - } - }, - "ActiveIocStatisticsResponse": { - "type": "object", - "properties": { - "network": { - "type": "string" - }, - "iocCount": { - "type": "integer", - "format": "int64" - } - } - }, - "ActiveIOCSForHistoryResponse": { - "type": "object", - "properties": { - "iocCount": { - "type": "integer", - "format": "int64" - }, - "historyDate": { - "type": "string", - "format": "date-time" - } - } - }, "PagedRecordResponse": { "type": "object", "properties": { @@ -4293,6 +4175,64 @@ } } }, + "HostInventoryList": { + "type": "object", + "properties": { + "hosts": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "IOCInventory": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "git": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "IOCInventoryList": { + "type": "object", + "properties": { + "iocs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IOCInventory" + } + } + } + }, + "InventoryResponse": { + "type": "object", + "properties": { + "_meta": { + "$ref": "#/components/schemas/MetaStructure" + }, + "all": { + "$ref": "#/components/schemas/HostInventoryList" + } + } + }, + "MetaStructure": { + "type": "object", + "properties": { + "hostvars": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/IOCInventoryList" + } + } + } + }, "HostInfoWithId": { "type": "object", "properties": { diff --git a/src/store/deployApi.ts b/src/store/deployApi.ts index 7a033fe7..62ee2e83 100644 --- a/src/store/deployApi.ts +++ b/src/store/deployApi.ts @@ -99,32 +99,6 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: () => ({ url: `/healthcheck` }) }), - calculateStatistics: build.query< - CalculateStatisticsApiResponse, - CalculateStatisticsApiArg - >({ - query: (queryArg) => ({ - url: `/api/v1/statistics/general/${queryArg.statisticsType}` - }) - }), - operationHistory: build.query< - OperationHistoryApiResponse, - OperationHistoryApiArg - >({ - query: () => ({ url: `/api/v1/statistics/general/operation_history` }) - }), - currentlyActiveIocs: build.query< - CurrentlyActiveIocsApiResponse, - CurrentlyActiveIocsApiArg - >({ - query: () => ({ url: `/api/v1/statistics/general/active_ioc_statistics` }) - }), - activeIocHistory: build.query< - ActiveIocHistoryApiResponse, - ActiveIocHistoryApiArg - >({ - query: () => ({ url: `/api/v1/statistics/general/active_ioc_history` }) - }), findAllRecords: build.query< FindAllRecordsApiResponse, FindAllRecordsApiArg @@ -251,6 +225,12 @@ const injectedRtkApi = api.injectEndpoints({ url: `/api/v1/iocs/check_git_repo_id/${queryArg.repoId}` }) }), + fetchInventory: build.query< + FetchInventoryApiResponse, + FetchInventoryApiArg + >({ + query: () => ({ url: `/api/v1/inventory` }) + }), listHosts: build.query<ListHostsApiResponse, ListHostsApiArg>({ query: (queryArg) => ({ url: `/api/v1/hosts`, @@ -459,27 +439,6 @@ export type UpdateActiveDeploymentHostApiArg = { }; export type GetHealthCheckApiResponse = /** status 200 OK */ string; export type GetHealthCheckApiArg = void; -export type CalculateStatisticsApiResponse = - /** status 200 Calculate statistics */ StatisticResponse; -export type CalculateStatisticsApiArg = { - statisticsType: - | "HOSTS_REGISTERED" - | "HOSTS_WITH_IOCS" - | "HOSTS_REACHABLE" - | "HOSTS_WITH_ACTIVE_IOCS" - | "IOCS_REGISTERED" - | "IOCS_DEPLOYED" - | "IOCS_RUNNING"; -}; -export type OperationHistoryApiResponse = - /** status 200 Operations history from DB for statistics */ OperationStatisticsResponse; -export type OperationHistoryApiArg = void; -export type CurrentlyActiveIocsApiResponse = - /** status 200 Statistics about currently active IOCs */ ActiveIocStatisticsResponse[]; -export type CurrentlyActiveIocsApiArg = void; -export type ActiveIocHistoryApiResponse = - /** status 200 History about active IOCs for statistics */ ActiveIocsForHistoryResponse[]; -export type ActiveIocHistoryApiArg = void; export type FindAllRecordsApiResponse = /** status 200 A paged array of Channel Finder records */ PagedRecordResponse; export type FindAllRecordsApiArg = { @@ -602,6 +561,9 @@ export type CheckGitRepoIdApiArg = { /** Git repository Id */ repoId: number; }; +export type FetchInventoryApiResponse = + /** status 200 Inventory response */ InventoryResponse; +export type FetchInventoryApiArg = void; export type ListHostsApiResponse = /** status 200 A paged array of hosts */ PagedNetBoxHostResponse; export type ListHostsApiArg = { @@ -854,33 +816,6 @@ export type IocUpdateRequest = { export type UpdateHostRequest = { hostId?: string; }; -export type StatisticResponse = { - value?: number; - statisticType?: - | "HOSTS_REGISTERED" - | "HOSTS_WITH_IOCS" - | "HOSTS_REACHABLE" - | "HOSTS_WITH_ACTIVE_IOCS" - | "IOCS_REGISTERED" - | "IOCS_DEPLOYED" - | "IOCS_RUNNING"; -}; -export type OperationStatistic = { - deploymentCount?: number; - commandCount?: number; - historyDate?: string; -}; -export type OperationStatisticsResponse = { - operationStatistics?: OperationStatistic[]; -}; -export type ActiveIocStatisticsResponse = { - network?: string; - iocCount?: number; -}; -export type ActiveIocsForHistoryResponse = { - iocCount?: number; - historyDate?: string; -}; export type Record = { name?: string; iocName?: string; @@ -990,6 +925,26 @@ export type LokiResponse = { lines?: LokiMessage[]; warning?: string; }; +export type IocInventory = { + name?: string; + git?: string; + version?: string; +}; +export type IocInventoryList = { + iocs?: IocInventory[]; +}; +export type MetaStructure = { + hostvars?: { + [key: string]: IocInventoryList; + }; +}; +export type HostInventoryList = { + hosts?: string[]; +}; +export type InventoryResponse = { + _meta?: MetaStructure; + all?: HostInventoryList; +}; export type HostInfoWithId = { id?: number; fqdn?: string; @@ -1070,14 +1025,6 @@ export const { useUpdateActiveDeploymentHostMutation, useGetHealthCheckQuery, useLazyGetHealthCheckQuery, - useCalculateStatisticsQuery, - useLazyCalculateStatisticsQuery, - useOperationHistoryQuery, - useLazyOperationHistoryQuery, - useCurrentlyActiveIocsQuery, - useLazyCurrentlyActiveIocsQuery, - useActiveIocHistoryQuery, - useLazyActiveIocHistoryQuery, useFindAllRecordsQuery, useLazyFindAllRecordsQuery, useGetRecordQuery, @@ -1107,6 +1054,8 @@ export const { useLazyFetchProcServLogLinesQuery, useCheckGitRepoIdQuery, useLazyCheckGitRepoIdQuery, + useFetchInventoryQuery, + useLazyFetchInventoryQuery, useListHostsQuery, useLazyListHostsQuery, useFetchSyslogLinesQuery, -- GitLab