diff --git a/src/components/IOC/IOCManage/IOCManage.js b/src/components/IOC/IOCManage/IOCManage.js index 4aaefabc2284c57482a2cbfbaf7f27abb2fda869..96f2dd9971416be0223ab2eea9e23f51cc15871e 100644 --- a/src/components/IOC/IOCManage/IOCManage.js +++ b/src/components/IOC/IOCManage/IOCManage.js @@ -41,21 +41,21 @@ export function IOCManage({ const [undeployDialogOpen, setUndeployDialogOpen] = useState(false); const deploymentJobParams = useMemo( - () => ({ awx_job_id: ioc.activeDeployment?.awxJobId }), + () => ({ job_id: ioc.activeDeployment?.jobId }), [ioc] ); - const { value: deploymentJob, wrapper: getDeploymentJobById } = useAPIMethod({ - fcn: client.apis.Deployments.fetchJobDetails, + const { value: deploymentJob, wrapper: callGetJobDetails } = useAPIMethod({ + fcn: client.apis.Operations.fetchJobDetails, call: false, params: deploymentJobParams }); useEffect(() => { - if (ioc.activeDeployment?.awxJobId) { - getDeploymentJobById(ioc.activeDeployment?.awxJobId); + if (ioc.activeDeployment?.jobId) { + callGetJobDetails(ioc.activeDeployment?.jobId); } - }, [getDeploymentJobById, ioc.activeDeployment?.awxJobId]); + }, [callGetJobDetails, ioc.activeDeployment?.jobId]); const closeDeployModal = () => { setDeployDialogOpen(false); diff --git a/src/components/common/User/UserOperationList.js b/src/components/common/User/UserOperationList.js index c02c4a84fa14ee7807702235da4419e6186f1577..e6479b290afc9d2cd6d781ca3f27a1c6afbc3d25 100644 --- a/src/components/common/User/UserOperationList.js +++ b/src/components/common/User/UserOperationList.js @@ -16,7 +16,7 @@ export function UserOperationList({ userName }) { dataReady, abort } = useAPIMethod({ - fcn: client.apis.Deployments.listOperations, + fcn: client.apis.Operations.listOperations, call: false }); diff --git a/src/components/deployments/DeploymentJobOutput.js b/src/components/deployments/DeploymentJobOutput.js index c1e7acc55615238f1eb03c3e27b504a9609e7211..d407c176d1dad8152faf03371020f661fcee058a 100644 --- a/src/components/deployments/DeploymentJobOutput.js +++ b/src/components/deployments/DeploymentJobOutput.js @@ -16,7 +16,7 @@ export function DeploymentJobOutput({ deploymentJob }) { const params = useMemo( () => ({ - awx_job_id: deploymentJob?.id + deployment_id: deploymentJob?.id }), [deploymentJob] ); @@ -28,7 +28,7 @@ export function DeploymentJobOutput({ deploymentJob }) { dataReady: logDataReady, abort: abortGetLogById } = useAPIMethod({ - fcn: client.apis.Deployments.fetchDeploymentJobLog, + fcn: client.apis.Operations.fetchDeploymentJobLog, params }); diff --git a/src/mocks/fixtures/DeploymentInfoDetails.json b/src/mocks/fixtures/DeploymentInfoDetails.json index 554128e09955b04f11098a6b6555dc33a556eb96..e4de94f4e13d4310f2d16a491d4f6f56c2b6b4dd 100644 --- a/src/mocks/fixtures/DeploymentInfoDetails.json +++ b/src/mocks/fixtures/DeploymentInfoDetails.json @@ -13,9 +13,9 @@ "externalIdValid": true, "fqdn": "jsparger-test.cslab.esss.lu.se" }, - "awxJobId": 3925, + "jobId": 3925, "iocId": 2, - "awxJobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3925", + "jobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3925", "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/ccce-demo-w38.git", "sourceVersionShort": "ee3ae2a8" }, @@ -33,9 +33,9 @@ "externalIdValid": true, "fqdn": "jsparger-test.cslab.esss.lu.se" }, - "awxJobId": 3928, + "jobId": 3928, "iocId": 1, - "awxJobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3928", + "jobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3928", "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/e3-ioc-test_49.git", "sourceVersionShort": "0.0.1" }, @@ -53,9 +53,9 @@ "externalIdValid": true, "fqdn": "jsparger-test.cslab.esss.lu.se" }, - "awxJobId": 3931, + "jobId": 3931, "iocId": 1, - "awxJobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3931", + "jobUrl": "https://awx-lab-01.cslab.esss.lu.se/#/jobs/playbook/3931", "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/e3-ioc-test_49.git", "sourceVersionShort": "0.0.1" } diff --git a/src/mocks/fixtures/IOCDetails.json b/src/mocks/fixtures/IOCDetails.json index eddd427e76e2bc3462e3bb4fccdfc13e7cd153c9..d597a512a41a281397e0ae1a10ef51c457ecc304 100644 --- a/src/mocks/fixtures/IOCDetails.json +++ b/src/mocks/fixtures/IOCDetails.json @@ -46,7 +46,7 @@ "hostName": "ccce-test-ioc-01", "network": "CSLab-GeneralLab" }, - "awxJobId": 6588, + "jobId": 6588, "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/instances/e3-ioc-test-02.git", "sourceVersionShort": "d4df546c", "operationStatus": "FAILED" @@ -114,7 +114,7 @@ "hostName": "ccce-test-ioc-02", "network": "CSLab-GeneralLab" }, - "awxJobId": 6580, + "jobId": 6580, "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/instances/e3-ioc-test-04.git", "sourceVersionShort": "8fd94089", "operationStatus": "FAILED" @@ -150,7 +150,7 @@ "hostName": "ccce-test-ioc-02", "network": "CSLab-GeneralLab" }, - "awxJobId": 6479, + "jobId": 6479, "sourceUrl": "https://gitlab.esss.lu.se/ccce/dev/iocs/instances/e3-ioc-test-05.git", "sourceVersionShort": "da21c190", "operationStatus": "SUCCESSFUL" diff --git a/src/mocks/fixtures/OperationDeploymentDetails.json b/src/mocks/fixtures/OperationDeploymentDetails.json index f921a4922b0eea3d8b95171b47b0ca3031e46902..4c36d57936e0a396dcbe2360e90ea6dc4b8a8755 100644 --- a/src/mocks/fixtures/OperationDeploymentDetails.json +++ b/src/mocks/fixtures/OperationDeploymentDetails.json @@ -17,7 +17,7 @@ "externalIdValid": false, "fqdn": "pbi-ipmi-vm-ioc.tn.esss.lu.se" }, - "awxJobId": 374182, - "awxJobUrl": null, + "jobId": 374182, + "jobUrl": null, "alerts": [] } diff --git a/src/mocks/fixtures/ccce-api.json b/src/mocks/fixtures/ccce-api.json index 2580b721c51c35382caca4bfd6ab42fd2698b296..632c2fdaaee7fb41509e50a47fb08ba928e6853f 100644 --- a/src/mocks/fixtures/ccce-api.json +++ b/src/mocks/fixtures/ccce-api.json @@ -15,6 +15,9 @@ { "name": "Names" }, + { + "name": "Operations" + }, { "name": "IOCs" }, @@ -36,9 +39,6 @@ { "name": "Hosts" }, - { - "name": "Deployments" - }, { "name": "Git" } @@ -1911,32 +1911,30 @@ } } }, - "/api/v1/names/ioc_names_by_name": { + "/api/v1/operations/{deployment_id}": { "get": { - "tags": ["Names"], - "summary": "Fetches IOC names by name from the Names service", - "operationId": "fetchIOCByName", + "tags": ["Operations"], + "summary": "Get deployment details", + "operationId": "fetchDeployment", "parameters": [ { - "name": "ioc_name", - "in": "query", - "description": "IOC name", - "required": false, + "name": "deployment_id", + "in": "path", + "description": "Unique ID of deployment", + "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64" } } ], "responses": { "200": { - "description": "Naming names, and UUIDs from the Names service", + "description": "A deployment with details", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NameResponse" - } + "$ref": "#/components/schemas/DeploymentInfoDetails" } } } @@ -1951,8 +1949,8 @@ } } }, - "500": { - "description": "Service exception", + "404": { + "description": "Deployment not found", "content": { "application/json": { "schema": { @@ -1961,8 +1959,8 @@ } } }, - "503": { - "description": "Remote service unreachable", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -1971,44 +1969,161 @@ } } } - }, - "security": [ - { - "bearerAuth": [] - } - ] + } } }, - "/api/v1/names/check_naming_uuid/{naming_uuid}": { + "/api/v1/operations/operations": { "get": { - "tags": ["Names"], - "summary": "Checks Naming UUID", - "description": "Checks Naming UUID if it is in use by IOC. \n\nSearching is based on EXACT match! \n\nIf no IOC uses the Naming UUID then the iocId will be NULL", - "operationId": "checkNamingUUId", + "tags": ["Operations"], + "summary": "List of deployments and commands", + "operationId": "listOperations", "parameters": [ { - "name": "naming_uuid", - "in": "path", - "description": "Naming UUID", - "required": true, + "name": "ioc_id", + "in": "query", + "description": "IOC ID", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "type", + "in": "query", + "description": "Type", + "required": false, + "schema": { + "type": "string", + "enum": ["DEPLOYMENT", "COMMAND"] + } + }, + { + "name": "status", + "in": "query", + "description": "Status", + "required": false, + "schema": { + "type": "string", + "enum": [ + "QUEUED", + "RUNNING", + "SUCCESSFUL", + "FAILED", + "FINISHED", + "ONGOING" + ] + } + }, + { + "name": "user", + "in": "query", + "description": "User name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "Search text (Search for IOC name, Created by)", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "start_date", + "in": "query", + "description": "Start date", + "required": false, + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "end_date", + "in": "query", + "description": "End date", + "required": false, + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "time_zone", + "in": "query", + "description": "Time zone ID", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "host_id", + "in": "query", + "description": "Host ID for the host", + "required": false, "schema": { "type": "string" } + }, + { + "name": "order_by", + "in": "query", + "description": "Order by", + "required": false, + "schema": { + "type": "string", + "enum": ["USER", "TIME", "IOC_NAME", "GIT_REFERENCE"] + } + }, + { + "name": "order_asc", + "in": "query", + "description": "Order Ascending", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "page", + "in": "query", + "description": "Page offset", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "limit", + "in": "query", + "description": "Page size", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { - "description": "Ok", + "description": "A paged array of deployments", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IdUsedByIoc" + "$ref": "#/components/schemas/PagedOperationResponse" } } } }, - "422": { - "description": "Too many IOCs use the same Naming UUID", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -2030,16 +2145,16 @@ } } }, - "/api/v1/iocs/{ioc_id}/status": { + "/api/v1/operations/operations/{operation_id}": { "get": { - "tags": ["IOCs"], - "summary": "Fetches the Prometheus status of the IOC", - "operationId": "fetchIocStatus", + "tags": ["Operations"], + "summary": "Get operation details", + "operationId": "fetchOperation", "parameters": [ { - "name": "ioc_id", + "name": "operation_id", "in": "path", - "description": "Unique ID of the IOC", + "description": "Unique ID of operation", "required": true, "schema": { "type": "integer", @@ -2049,11 +2164,11 @@ ], "responses": { "200": { - "description": "Log lines", + "description": "Operation details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocStatusResponse" + "$ref": "#/components/schemas/OperationDetails" } } } @@ -2069,7 +2184,7 @@ } }, "404": { - "description": "Ioc not found", + "description": "Not found", "content": { "application/json": { "schema": { @@ -2091,16 +2206,16 @@ } } }, - "/api/v1/iocs/{ioc_id}/description": { + "/api/v1/operations/operations/job/{job_id}": { "get": { - "tags": ["IOCs"], - "summary": "Find IOC description by ID", - "operationId": "getIocDescription", + "tags": ["Operations"], + "summary": "Get job details", + "operationId": "fetchJobDetails", "parameters": [ { - "name": "ioc_id", + "name": "job_id", "in": "path", - "description": "Unique ID of IOC", + "description": "Unique ID of the job", "required": true, "schema": { "type": "integer", @@ -2110,17 +2225,27 @@ ], "responses": { "200": { - "description": "Found IOC description", + "description": "Job details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IocDescriptionResponse" + "$ref": "#/components/schemas/AwxJobDetails" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" } } } }, "404": { - "description": "Ioc not found", + "description": "Job not found", "content": { "application/json": { "schema": { @@ -2138,52 +2263,44 @@ } } } + }, + "503": { + "description": "Remote service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } } } } }, - "/api/v1/iocs/{host_name}/{ioc_name}/log": { + "/api/v1/operations/jobs/{job_id}/log": { "get": { - "tags": ["IOCs"], - "summary": "Fetches procServ Log lines for a specific host", - "operationId": "fetchProcServLogLines", + "tags": ["Operations"], + "summary": "Get job log from AWX", + "operationId": "fetchDeploymentJobLog", "parameters": [ { - "name": "host_name", + "name": "job_id", "in": "path", - "description": "Host name (without network part)", + "description": "Unique ID of the job", "required": true, "schema": { - "type": "string" - } - }, - { - "name": "ioc_name", - "in": "path", - "description": "Name of the IOC to get procServ logs", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "time_range", - "in": "query", - "description": "Time range (in minutes)", - "required": false, - "schema": { - "type": "integer", - "format": "int32" + "type": "integer", + "format": "int64" } } ], "responses": { "200": { - "description": "Log lines", + "description": "Job log", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LokiResponse" + "$ref": "#/components/schemas/AwxJobLog" } } } @@ -2198,6 +2315,16 @@ } } }, + "404": { + "description": "Deployment not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, "500": { "description": "Service exception", "content": { @@ -2209,7 +2336,7 @@ } }, "503": { - "description": "Logging server unavailable", + "description": "Remote service exception", "content": { "application/json": { "schema": { @@ -2226,31 +2353,42 @@ ] } }, - "/api/v1/iocs/check_git_repo_id/{repo_id}": { + "/api/v1/names/ioc_names_by_name": { "get": { - "tags": ["IOCs"], - "summary": "Checks if Git Repository Id is being used by any of the IOCs", - "description": "Checks Git Repository Id if it is in use by IOC. \n\nFunction is not checking the Git repo ID in the deployment history! \n\nIf no IOC uses the Git repo Id then the iocId will be NULL!", - "operationId": "checkGitRepoId", + "tags": ["Names"], + "summary": "Fetches IOC names by name from the Names service", + "operationId": "fetchIOCByName", "parameters": [ { - "name": "repo_id", - "in": "path", - "description": "Git repository Id", - "required": true, + "name": "ioc_name", + "in": "query", + "description": "IOC name", + "required": false, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], "responses": { "200": { - "description": "Ok", + "description": "Naming names, and UUIDs from the Names service", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IdUsedByIoc" + "type": "array", + "items": { + "$ref": "#/components/schemas/NameResponse" + } + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" } } } @@ -2264,79 +2402,55 @@ } } } + }, + "503": { + "description": "Remote service unreachable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } } - } + }, + "security": [ + { + "bearerAuth": [] + } + ] } }, - "/api/v1/hosts": { + "/api/v1/names/check_naming_uuid/{naming_uuid}": { "get": { - "tags": ["Hosts"], - "summary": "List hosts", - "operationId": "listHosts", + "tags": ["Names"], + "summary": "Checks Naming UUID", + "description": "Checks Naming UUID if it is in use by IOC. \n\nSearching is based on EXACT match! \n\nIf no IOC uses the Naming UUID then the iocId will be NULL", + "operationId": "checkNamingUUId", "parameters": [ { - "name": "query", - "in": "query", - "description": "Search for host name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "filter", - "in": "query", - "description": "Filtering depending on deployments", - "required": false, - "schema": { - "type": "string", - "enum": ["ALL", "IOCS_DEPLOYED", "NO_IOCS", "OWN"] - } - }, - { - "name": "page", - "in": "query", - "description": "Page offset", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "limit", - "in": "query", - "description": "Page size", - "required": false, + "name": "naming_uuid", + "in": "path", + "description": "Naming UUID", + "required": true, "schema": { - "maximum": 100, "type": "string" } - }, - { - "name": "list_all", - "in": "query", - "description": "Use this parameter to list all Hosts in the response! Setting this parameter to true will override the Page and Limit parameters!", - "required": false, - "schema": { - "type": "boolean", - "default": false - } } ], "responses": { "200": { - "description": "A paged array of hosts", + "description": "Ok", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedNetBoxHostResponse" + "$ref": "#/components/schemas/IdUsedByIoc" } } } }, - "401": { - "description": "Unauthorized", + "422": { + "description": "Too many IOCs use the same Naming UUID", "content": { "application/json": { "schema": { @@ -2354,43 +2468,34 @@ } } } - }, - "503": { - "description": "Remote server exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } } } }, - "/api/v1/hosts/{host_id}/with_status": { + "/api/v1/iocs/{ioc_id}/status": { "get": { - "tags": ["Hosts"], - "summary": "Find host by external ID and get status", - "operationId": "findHostWithStatusById", + "tags": ["IOCs"], + "summary": "Fetches the Prometheus status of the IOC", + "operationId": "fetchIocStatus", "parameters": [ { - "name": "host_id", + "name": "ioc_id", "in": "path", - "description": "Host identifier", + "description": "Unique ID of the IOC", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64" } } ], "responses": { "200": { - "description": "Found Host", + "description": "Log lines", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NetBoxHostWithStatus" + "$ref": "#/components/schemas/IocStatusResponse" } } } @@ -2406,7 +2511,7 @@ } }, "404": { - "description": "Not found", + "description": "Ioc not found", "content": { "application/json": { "schema": { @@ -2424,49 +2529,40 @@ } } } - }, - "503": { - "description": "Remote server exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } } } }, - "/api/v1/hosts/{host_id}/status": { + "/api/v1/iocs/{ioc_id}/description": { "get": { - "tags": ["Hosts"], - "summary": "Find host status by external ID", - "operationId": "findHostStatus", + "tags": ["IOCs"], + "summary": "Find IOC description by ID", + "operationId": "getIocDescription", "parameters": [ { - "name": "host_id", + "name": "ioc_id", "in": "path", - "description": "Host identifier", + "description": "Unique ID of IOC", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64" } } ], "responses": { "200": { - "description": "Host status", + "description": "Found IOC description", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HostStatusResponse" + "$ref": "#/components/schemas/IocDescriptionResponse" } } } }, "404": { - "description": "Not found", + "description": "Ioc not found", "content": { "application/json": { "schema": { @@ -2484,30 +2580,20 @@ } } } - }, - "503": { - "description": "Remote server exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } } } }, - "/api/v1/hosts/{host_id}/iocs": { + "/api/v1/iocs/{host_name}/{ioc_name}/log": { "get": { - "tags": ["Hosts"], - "summary": "Find associated IOCs for the host", - "operationId": "findAssociatedIocsByHostId", + "tags": ["IOCs"], + "summary": "Fetches procServ Log lines for a specific host", + "operationId": "fetchProcServLogLines", "parameters": [ { - "name": "host_id", + "name": "host_name", "in": "path", - "description": "Host identifier", + "description": "Host name (without network part)", "required": true, "schema": { "type": "string" @@ -2515,32 +2601,138 @@ }, { "name": "ioc_name", - "in": "query", - "description": "IOC Name", - "required": false, + "in": "path", + "description": "Name of the IOC to get procServ logs", + "required": true, "schema": { "type": "string" } }, { - "name": "order_by", + "name": "time_range", "in": "query", - "description": "Order by", + "description": "Time range (in minutes)", "required": false, "schema": { - "type": "string", - "default": "IOC_NAME", - "enum": ["ID", "CREATED_BY", "IOC_NAME"] + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Log lines", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LokiResponse" + } + } } }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "503": { + "description": "Logging server unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + } + }, + "security": [ { - "name": "order_asc", + "bearerAuth": [] + } + ] + } + }, + "/api/v1/iocs/check_git_repo_id/{repo_id}": { + "get": { + "tags": ["IOCs"], + "summary": "Checks if Git Repository Id is being used by any of the IOCs", + "description": "Checks Git Repository Id if it is in use by IOC. \n\nFunction is not checking the Git repo ID in the deployment history! \n\nIf no IOC uses the Git repo Id then the iocId will be NULL!", + "operationId": "checkGitRepoId", + "parameters": [ + { + "name": "repo_id", + "in": "path", + "description": "Git repository Id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IdUsedByIoc" + } + } + } + }, + "500": { + "description": "Service exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + } + } + } + }, + "/api/v1/hosts": { + "get": { + "tags": ["Hosts"], + "summary": "List hosts", + "operationId": "listHosts", + "parameters": [ + { + "name": "query", "in": "query", - "description": "Order Ascending", + "description": "Search for host name", "required": false, "schema": { - "type": "boolean", - "default": true + "type": "string" + } + }, + { + "name": "filter", + "in": "query", + "description": "Filtering depending on deployments", + "required": false, + "schema": { + "type": "string", + "enum": ["ALL", "IOCS_DEPLOYED", "NO_IOCS", "OWN"] } }, { @@ -2562,15 +2754,25 @@ "maximum": 100, "type": "string" } + }, + { + "name": "list_all", + "in": "query", + "description": "Use this parameter to list all Hosts in the response! Setting this parameter to true will override the Page and Limit parameters!", + "required": false, + "schema": { + "type": "boolean", + "default": false + } } ], "responses": { "200": { - "description": "Found Host", + "description": "A paged array of hosts", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedAssociatedIocs" + "$ref": "#/components/schemas/PagedNetBoxHostResponse" } } } @@ -2594,15 +2796,25 @@ } } } + }, + "503": { + "description": "Remote server exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } } } } }, - "/api/v1/hosts/{host_id}/info": { + "/api/v1/hosts/{host_id}/with_status": { "get": { "tags": ["Hosts"], - "summary": "Find host by external ID", - "operationId": "findHostInfoById", + "summary": "Find host by external ID and get status", + "operationId": "findHostWithStatusById", "parameters": [ { "name": "host_id", @@ -2620,7 +2832,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TargetHost" + "$ref": "#/components/schemas/NetBoxHostWithStatus" } } } @@ -2654,20 +2866,30 @@ } } } + }, + "503": { + "description": "Remote server exception", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } } } } }, - "/api/v1/hosts/{fqdn}/info_by_fqdn": { + "/api/v1/hosts/{host_id}/status": { "get": { "tags": ["Hosts"], - "summary": "Find host by FQDN", - "operationId": "findNetBoxHostByFqdn", + "summary": "Find host status by external ID", + "operationId": "findHostStatus", "parameters": [ { - "name": "fqdn", + "name": "host_id", "in": "path", - "description": "The host's FQDN", + "description": "Host identifier", "required": true, "schema": { "type": "string" @@ -2676,17 +2898,17 @@ ], "responses": { "200": { - "description": "Found Host", + "description": "Host status", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TargetHost" + "$ref": "#/components/schemas/HostStatusResponse" } } } }, - "401": { - "description": "Unauthorized", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { @@ -2695,8 +2917,8 @@ } } }, - "404": { - "description": "Not found", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -2705,8 +2927,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Remote server exception", "content": { "application/json": { "schema": { @@ -2718,52 +2940,79 @@ } } }, - "/api/v1/git_helper/{project_id}/tags_and_commits": { + "/api/v1/hosts/{host_id}/iocs": { "get": { - "tags": ["Git"], - "summary": "List Tags and CommitIds", - "operationId": "listTagsAndCommitIds", + "tags": ["Hosts"], + "summary": "Find associated IOCs for the host", + "operationId": "findAssociatedIocsByHostId", "parameters": [ { - "name": "project_id", + "name": "host_id", "in": "path", - "description": "Git repo project ID", + "description": "Host identifier", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { - "name": "reference", + "name": "ioc_name", "in": "query", - "description": "Git reference", + "description": "IOC Name", "required": false, "schema": { "type": "string" } }, { - "name": "search_method", + "name": "order_by", "in": "query", - "description": "Search method - optional. Default value: filtering ref by EQUALS method", + "description": "Order by", "required": false, "schema": { "type": "string", - "enum": ["EQUALS", "CONTAINS"] + "default": "IOC_NAME", + "enum": ["ID", "CREATED_BY", "IOC_NAME"] + } + }, + { + "name": "order_asc", + "in": "query", + "description": "Order Ascending", + "required": false, + "schema": { + "type": "boolean", + "default": true + } + }, + { + "name": "page", + "in": "query", + "description": "Page offset", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "limit", + "in": "query", + "description": "Page size", + "required": false, + "schema": { + "maximum": 100, + "type": "string" } } ], "responses": { "200": { - "description": "List of Tags and CommitIds for a specific GitLab repo", + "description": "Found Host", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GitReference" - } + "$ref": "#/components/schemas/PagedAssociatedIocs" } } } @@ -2787,40 +3036,20 @@ } } } - }, - "503": { - "description": "Git exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } } } }, - "/api/v1/git_helper/{project_id}/reference_type/{git_reference}": { + "/api/v1/hosts/{host_id}/info": { "get": { - "tags": ["Git"], - "summary": "Git reference tye", - "operationId": "gitReferenceType", + "tags": ["Hosts"], + "summary": "Find host by external ID", + "operationId": "findHostInfoById", "parameters": [ { - "name": "project_id", + "name": "host_id", "in": "path", - "description": "Git repo project ID", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "git_reference", - "in": "path", - "description": "Git reference", + "description": "Host identifier", "required": true, "schema": { "type": "string" @@ -2829,17 +3058,17 @@ ], "responses": { "200": { - "description": "Git reference type", + "description": "Found Host", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ReferenceTypeResponse" + "$ref": "#/components/schemas/TargetHost" } } } }, - "500": { - "description": "Service exception", + "401": { + "description": "Unauthorized", "content": { "application/json": { "schema": { @@ -2848,8 +3077,18 @@ } } }, - "503": { - "description": "Git exception", + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralException" + } + } + } + }, + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -2861,17 +3100,17 @@ } } }, - "/api/v1/git_helper/user_info": { + "/api/v1/hosts/{fqdn}/info_by_fqdn": { "get": { - "tags": ["Git"], - "summary": "User information", - "operationId": "infoFromUserName", + "tags": ["Hosts"], + "summary": "Find host by FQDN", + "operationId": "findNetBoxHostByFqdn", "parameters": [ { - "name": "user_name", - "in": "query", - "description": "The username to retrieve info from - optional. If no user name provided the backend will look up for currently logged in user name", - "required": false, + "name": "fqdn", + "in": "path", + "description": "The host's FQDN", + "required": true, "schema": { "type": "string" } @@ -2879,14 +3118,11 @@ ], "responses": { "200": { - "description": "Information about the current user", + "description": "Found Host", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInfoResponse" - } + "$ref": "#/components/schemas/TargetHost" } } } @@ -2920,50 +3156,55 @@ } } } - }, - "503": { - "description": "Git exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } } - }, - "security": [ - { - "bearerAuth": [] - } - ] + } } }, - "/api/v1/git_helper/projects": { + "/api/v1/git_helper/{project_id}/tags_and_commits": { "get": { "tags": ["Git"], - "summary": "List IOC projects", - "operationId": "listProjects", + "summary": "List Tags and CommitIds", + "operationId": "listTagsAndCommitIds", "parameters": [ { - "name": "query", + "name": "project_id", + "in": "path", + "description": "Git repo project ID", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "reference", "in": "query", - "description": "Search text (Search for Git repository name)", + "description": "Git reference", "required": false, "schema": { "type": "string" } + }, + { + "name": "search_method", + "in": "query", + "description": "Search method - optional. Default value: filtering ref by EQUALS method", + "required": false, + "schema": { + "type": "string", + "enum": ["EQUALS", "CONTAINS"] + } } ], "responses": { "200": { - "description": "List of Gitlab projects of allowed groups", + "description": "List of Tags and CommitIds for a specific GitLab repo", "content": { "application/json": { "schema": { "type": "array", "items": { - "$ref": "#/components/schemas/GitProject" + "$ref": "#/components/schemas/GitReference" } } } @@ -2999,19 +3240,14 @@ } } } - }, - "security": [ - { - "bearerAuth": [] - } - ] + } } }, - "/api/v1/git_helper/project_info/{project_id}": { + "/api/v1/git_helper/{project_id}/reference_type/{git_reference}": { "get": { "tags": ["Git"], - "summary": "Git project detail by repository ID", - "operationId": "gitProjectDetails", + "summary": "Git reference tye", + "operationId": "gitReferenceType", "parameters": [ { "name": "project_id", @@ -3022,92 +3258,30 @@ "type": "integer", "format": "int64" } - } - ], - "responses": { - "200": { - "description": "Git project details", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GitProjectDto" - } - } - } - }, - "404": { - "description": "Project not found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } }, - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, - "503": { - "description": "Git exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - } - } - } - }, - "/api/v1/deployments/{deployment_id}": { - "get": { - "tags": ["Deployments"], - "summary": "Get deployment details", - "operationId": "fetchDeployment", - "parameters": [ { - "name": "deployment_id", + "name": "git_reference", "in": "path", - "description": "Unique ID of deployment", + "description": "Git reference", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], "responses": { "200": { - "description": "A deployment with details", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeploymentInfoDetails" - } - } - } - }, - "401": { - "description": "Unauthorized", + "description": "Git reference type", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/ReferenceTypeResponse" } } } }, - "404": { - "description": "Deployment not found", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3116,8 +3290,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3129,152 +3303,32 @@ } } }, - "/api/v1/deployments/operations": { + "/api/v1/git_helper/user_info": { "get": { - "tags": ["Deployments"], - "summary": "List of deployments and commands", - "operationId": "listOperations", + "tags": ["Git"], + "summary": "User information", + "operationId": "infoFromUserName", "parameters": [ { - "name": "ioc_id", - "in": "query", - "description": "IOC ID", - "required": false, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "type", - "in": "query", - "description": "Type", - "required": false, - "schema": { - "type": "string", - "enum": ["DEPLOYMENT", "COMMAND"] - } - }, - { - "name": "status", - "in": "query", - "description": "Status", - "required": false, - "schema": { - "type": "string", - "enum": [ - "QUEUED", - "RUNNING", - "SUCCESSFUL", - "FAILED", - "FINISHED", - "ONGOING" - ] - } - }, - { - "name": "user", - "in": "query", - "description": "User name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "query", - "in": "query", - "description": "Search text (Search for IOC name, Created by)", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "start_date", - "in": "query", - "description": "Start date", - "required": false, - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "end_date", - "in": "query", - "description": "End date", - "required": false, - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "time_zone", - "in": "query", - "description": "Time zone ID", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "host_id", + "name": "user_name", "in": "query", - "description": "Host ID for the host", + "description": "The username to retrieve info from - optional. If no user name provided the backend will look up for currently logged in user name", "required": false, "schema": { "type": "string" } - }, - { - "name": "order_by", - "in": "query", - "description": "Order by", - "required": false, - "schema": { - "type": "string", - "enum": ["USER", "TIME", "IOC_NAME", "GIT_REFERENCE"] - } - }, - { - "name": "order_asc", - "in": "query", - "description": "Order Ascending", - "required": false, - "schema": { - "type": "boolean" - } - }, - { - "name": "page", - "in": "query", - "description": "Page offset", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "limit", - "in": "query", - "description": "Page size", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - } } ], "responses": { "200": { - "description": "A paged array of deployments", + "description": "Information about the current user", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedOperationResponse" + "type": "array", + "items": { + "$ref": "#/components/schemas/UserInfoResponse" + } } } } @@ -3289,49 +3343,8 @@ } } }, - "500": { - "description": "Service exception", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - } - } - } - }, - "/api/v1/deployments/operations/{operation_id}": { - "get": { - "tags": ["Deployments"], - "summary": "Get operation details", - "operationId": "fetchOperation", - "parameters": [ - { - "name": "operation_id", - "in": "path", - "description": "Unique ID of operation", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "Operation details", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OperationDetails" - } - } - } - }, - "401": { - "description": "Unauthorized", + "404": { + "description": "Not found", "content": { "application/json": { "schema": { @@ -3340,8 +3353,8 @@ } } }, - "404": { - "description": "Not found", + "500": { + "description": "Service exception", "content": { "application/json": { "schema": { @@ -3350,8 +3363,8 @@ } } }, - "500": { - "description": "Service exception", + "503": { + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3360,33 +3373,40 @@ } } } - } + }, + "security": [ + { + "bearerAuth": [] + } + ] } }, - "/api/v1/deployments/operations/job/{awx_job_id}": { + "/api/v1/git_helper/projects": { "get": { - "tags": ["Deployments"], - "summary": "Get AWX job details", - "operationId": "fetchJobDetails", + "tags": ["Git"], + "summary": "List IOC projects", + "operationId": "listProjects", "parameters": [ { - "name": "awx_job_id", - "in": "path", - "description": "Unique ID of AWX job", - "required": true, + "name": "query", + "in": "query", + "description": "Search text (Search for Git repository name)", + "required": false, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], "responses": { "200": { - "description": "AWX job details", + "description": "List of Gitlab projects of allowed groups", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AwxJobDetails" + "type": "array", + "items": { + "$ref": "#/components/schemas/GitProject" + } } } } @@ -3401,16 +3421,6 @@ } } }, - "404": { - "description": "AWX job not found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GeneralException" - } - } - } - }, "500": { "description": "Service exception", "content": { @@ -3422,7 +3432,7 @@ } }, "503": { - "description": "Remote service exception", + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3431,49 +3441,44 @@ } } } - } + }, + "security": [ + { + "bearerAuth": [] + } + ] } }, - "/api/v1/deployments/jobs/{awx_job_id}/log": { + "/api/v1/git_helper/project_info/{project_id}": { "get": { - "tags": ["Deployments"], - "summary": "Get job log from AWX", - "operationId": "fetchDeploymentJobLog", + "tags": ["Git"], + "summary": "Git project detail by repository ID", + "operationId": "gitProjectDetails", "parameters": [ { - "name": "awx_job_id", + "name": "project_id", "in": "path", - "description": "Unique ID of AWX job", + "description": "Git repo project ID", "required": true, "schema": { "type": "integer", "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "AWX job log", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AwxJobLog" - } - } - } - }, - "401": { - "description": "Unauthorized", + } + } + ], + "responses": { + "200": { + "description": "Git project details", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GeneralException" + "$ref": "#/components/schemas/GitProjectDto" } } } }, "404": { - "description": "Deployment not found", + "description": "Project not found", "content": { "application/json": { "schema": { @@ -3493,7 +3498,7 @@ } }, "503": { - "description": "Remote service exception", + "description": "Git exception", "content": { "application/json": { "schema": { @@ -3502,12 +3507,7 @@ } } } - }, - "security": [ - { - "bearerAuth": [] - } - ] + } } }, "/api/v1/authentication/users": { @@ -4241,46 +4241,263 @@ } } }, - "RecordDetails": { + "RecordDetails": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "iocName": { + "type": "string" + }, + "iocId": { + "type": "integer", + "format": "int64" + }, + "hostName": { + "type": "string" + }, + "hostId": { + "type": "string" + }, + "pvStatus": { + "type": "string", + "enum": ["ACTIVE", "INACTIVE"] + }, + "iocVersion": { + "type": "string" + }, + "description": { + "type": "string" + }, + "recordType": { + "type": "string" + }, + "alias": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "DeploymentInfoDetails": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "createdBy": { + "type": "string" + }, + "startDate": { + "type": "string", + "format": "date-time" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "undeployment": { + "type": "boolean" + }, + "namingName": { + "type": "string" + }, + "gitProjectId": { + "type": "integer", + "format": "int64" + }, + "sourceVersion": { + "type": "string" + }, + "operationId": { + "type": "integer", + "format": "int64" + }, + "endDate": { + "type": "string", + "format": "date-time" + }, + "host": { + "$ref": "#/components/schemas/HostWithFqdn" + }, + "jobId": { + "type": "integer", + "format": "int64" + }, + "iocId": { + "type": "integer", + "format": "int64" + }, + "jobUrl": { + "type": "string" + }, + "sourceUrl": { + "type": "string" + }, + "sourceVersionShort": { + "type": "string" + }, + "alerts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Alert" + } + } + } + }, + "HostWithFqdn": { + "type": "object", + "properties": { + "hostId": { + "type": "string" + }, + "externalIdValid": { + "type": "boolean" + }, + "fqdn": { + "type": "string" + } + } + }, + "PagedOperationResponse": { + "type": "object", + "properties": { + "totalCount": { + "type": "integer", + "format": "int64" + }, + "listSize": { + "type": "integer", + "format": "int32" + }, + "pageNumber": { + "type": "integer", + "format": "int32" + }, + "limit": { + "type": "integer", + "format": "int32" + }, + "operations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Operation" + } + } + } + }, + "OperationDetails": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "createdBy": { + "type": "string" + }, + "startTime": { + "type": "string", + "format": "date-time" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "finishedAt": { + "type": "string", + "format": "date-time" + }, + "type": { + "type": "string", + "enum": ["DEPLOY", "UNDEPLOY", "START", "STOP"] + }, + "iocName": { + "type": "string" + }, + "iocId": { + "type": "integer", + "format": "int64" + }, + "deploymentId": { + "type": "integer", + "format": "int64" + }, + "gitProjectId": { + "type": "integer", + "format": "int64" + }, + "gitReference": { + "type": "string" + }, + "status": { + "type": "string", + "enum": ["UNKNOWN", "QUEUED", "RUNNING", "FAILED", "SUCCESSFUL"] + }, + "gitProjectUrl": { + "type": "string" + }, + "gitShortReference": { + "type": "string" + }, + "host": { + "$ref": "#/components/schemas/HostWithFqdn" + }, + "jobId": { + "type": "integer", + "format": "int64" + }, + "jobUrl": { + "type": "string" + }, + "alerts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Alert" + } + } + } + }, + "AwxJobDetails": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "status": { + "type": "string", + "enum": ["UNKNOWN", "QUEUED", "RUNNING", "FAILED", "SUCCESSFUL"] + }, + "started": { + "type": "string", + "format": "date-time" + }, + "finished": { + "type": "string", + "format": "date-time" + } + } + }, + "AwxJobLog": { "type": "object", "properties": { - "name": { - "type": "string" - }, - "iocName": { - "type": "string" - }, - "iocId": { + "jobId": { "type": "integer", "format": "int64" }, - "hostName": { - "type": "string" - }, - "hostId": { - "type": "string" - }, - "pvStatus": { - "type": "string", - "enum": ["ACTIVE", "INACTIVE"] - }, - "iocVersion": { - "type": "string" - }, - "description": { - "type": "string" - }, - "recordType": { - "type": "string" - }, - "alias": { + "stdoutHtml": { "type": "string" }, - "properties": { - "type": "object", - "additionalProperties": { - "type": "string" - } + "elapsed": { + "type": "number", + "format": "double" } } }, @@ -4675,223 +4892,6 @@ "type": "string" } } - }, - "DeploymentInfoDetails": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "createdBy": { - "type": "string" - }, - "startDate": { - "type": "string", - "format": "date-time" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "undeployment": { - "type": "boolean" - }, - "namingName": { - "type": "string" - }, - "gitProjectId": { - "type": "integer", - "format": "int64" - }, - "sourceVersion": { - "type": "string" - }, - "operationId": { - "type": "integer", - "format": "int64" - }, - "endDate": { - "type": "string", - "format": "date-time" - }, - "host": { - "$ref": "#/components/schemas/HostWithFqdn" - }, - "awxJobId": { - "type": "integer", - "format": "int64" - }, - "iocId": { - "type": "integer", - "format": "int64" - }, - "awxJobUrl": { - "type": "string" - }, - "sourceUrl": { - "type": "string" - }, - "sourceVersionShort": { - "type": "string" - }, - "alerts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Alert" - } - } - } - }, - "HostWithFqdn": { - "type": "object", - "properties": { - "hostId": { - "type": "string" - }, - "externalIdValid": { - "type": "boolean" - }, - "fqdn": { - "type": "string" - } - } - }, - "PagedOperationResponse": { - "type": "object", - "properties": { - "totalCount": { - "type": "integer", - "format": "int64" - }, - "listSize": { - "type": "integer", - "format": "int32" - }, - "pageNumber": { - "type": "integer", - "format": "int32" - }, - "limit": { - "type": "integer", - "format": "int32" - }, - "operations": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Operation" - } - } - } - }, - "OperationDetails": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "createdBy": { - "type": "string" - }, - "startTime": { - "type": "string", - "format": "date-time" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "finishedAt": { - "type": "string", - "format": "date-time" - }, - "type": { - "type": "string", - "enum": ["DEPLOY", "UNDEPLOY", "START", "STOP"] - }, - "iocName": { - "type": "string" - }, - "iocId": { - "type": "integer", - "format": "int64" - }, - "deploymentId": { - "type": "integer", - "format": "int64" - }, - "gitProjectId": { - "type": "integer", - "format": "int64" - }, - "gitReference": { - "type": "string" - }, - "status": { - "type": "string", - "enum": ["UNKNOWN", "QUEUED", "RUNNING", "FAILED", "SUCCESSFUL"] - }, - "gitProjectUrl": { - "type": "string" - }, - "gitShortReference": { - "type": "string" - }, - "host": { - "$ref": "#/components/schemas/HostWithFqdn" - }, - "awxJobId": { - "type": "integer", - "format": "int64" - }, - "awxJobUrl": { - "type": "string" - }, - "alerts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Alert" - } - } - } - }, - "AwxJobDetails": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "status": { - "type": "string", - "enum": ["UNKNOWN", "QUEUED", "RUNNING", "FAILED", "SUCCESSFUL"] - }, - "started": { - "type": "string", - "format": "date-time" - }, - "finished": { - "type": "string", - "format": "date-time" - } - } - }, - "AwxJobLog": { - "type": "object", - "properties": { - "awxJobId": { - "type": "integer", - "format": "int64" - }, - "stdoutHtml": { - "type": "string" - }, - "elapsed": { - "type": "number", - "format": "double" - } - } } }, "securitySchemes": { diff --git a/src/mocks/mockAPI.js b/src/mocks/mockAPI.js index b2224285e906939131cd94e6e7f52378d60dfa58..80ed59e1ac9d50bb0995d92475d2f926071a4bd8 100644 --- a/src/mocks/mockAPI.js +++ b/src/mocks/mockAPI.js @@ -144,26 +144,24 @@ function findAllRecords(req) { return { body }; } -function getDeployment(req) { - console.debug(req); - const params = getParameters(req, "/deployments/:id"); - console.debug(params); +function fetchDeployment(req) { + const params = getParameters(req, "/operations/:deployment_id"); const data = require("./fixtures/DeploymentInfoDetails.json"); - const body = data.find((x) => x.id === Number(params.id)); + const body = data.find((x) => x.id === Number(params.deployment_id)); const status = body ? 200 : 404; return { body, status }; } -function getDeploymentJob(req) { - const params = getParameters(req, "/deployments/operations/job/:id"); +function fetchJobDetails(req) { + const params = getParameters(req, "/operations/operations/job/:job_id"); const data = require("./fixtures/AwxJobDetails.json"); - const body = data.find((x) => x.id === Number(params.id)); + const body = data.find((x) => x.id === Number(params.job_id)); const status = body ? 200 : 404; return { body, status }; } -function getDeploymentJobLog(req) { - const params = getParameters(req, "/deployments/jobs/:id/log"); +function fetchDeploymentJobLog(req) { + const params = getParameters(req, "/operations/jobs/:id/log"); const jobDetailsData = require("./fixtures/AwxJobDetails.json"); const index = jobDetailsData.findIndex((x) => x.id === Number(params.id)); const logData = require("./fixtures/AwxJobLog.json"); @@ -179,19 +177,16 @@ function listOperations(req) { } function fetchOperation(req) { - const params = getParameters(req, "/deployments/operations/:id"); + const params = getParameters(req, "/operations/operations/:operation_id"); const data = require("./fixtures/OperationList.json"); - const body = data.operations.find((x) => x?.id === Number(params?.id)); + const body = data.operations.find( + (x) => x?.id === Number(params?.operation_id) + ); const status = body ? 200 : 404; return { body, status }; } -function getCommandList(req) { - const body = require("./fixtures/PagedCommandResponse.json"); - return { body }; -} - function findHostWithStatusById(req) { const params = getParameters(req, "/hosts/:host_id/with_status"); const data = require("./fixtures/NetBoxHostWithStatus.json"); @@ -293,13 +288,12 @@ const mockAPI = { fetchIocStatus, fetchProcServLogLines }, - deployments: { - getDeployment, - getDeploymentJob, - getDeploymentJobLog, - getCommandList, + operations: { listOperations, - fetchOperation + fetchOperation, + fetchJobDetails, + fetchDeploymentJobLog, + fetchDeployment }, hosts: { findHostWithStatusById, @@ -405,42 +399,35 @@ export const apiHandlers = [ mockAPI.git_helper.listTagsAndCommitIds ), - // deployments + // operations makeHandler( "GET", - qRegExp(".*/operations"), - mockAPI.deployments.listOperations + qRegExp(".*/operations/operations"), + mockAPI.operations.listOperations ), makeHandler( "GET", - qRegExp(".*/deployments/[0-9]+"), - mockAPI.deployments.getDeployment + qRegExp(".*/operations/[0-9]+"), + mockAPI.operations.fetchDeployment ), makeHandler( "GET", - qRegExp(".*/deployments/operations/[0-9]+"), - mockAPI.deployments.fetchOperation, + qRegExp(".*/operations/operations/[0-9]+"), + mockAPI.operations.fetchOperation, auth ), makeHandler( "GET", - qRegExp(".*/deployments/operations/job/[0-9]+"), - mockAPI.deployments.getDeploymentJob + qRegExp(".*/operations/operations/job/[0-9]+"), + mockAPI.operations.fetchJobDetails ), makeHandler( "GET", - qRegExp(".*/deployments/jobs/[0-9]+/log"), - mockAPI.deployments.getDeploymentJobLog, + qRegExp(".*/operations/jobs/[0-9]+/log"), + mockAPI.operations.fetchDeploymentJobLog, auth ), - // commands - makeHandler( - "GET", - qRegExp(".*/deployments/commands"), - mockAPI.deployments.getCommandList - ), - // hosts makeHandler("GET", qRegExp(".*/hosts"), mockAPI.hosts.listHosts), makeHandler( diff --git a/src/views/IOC/IOCDetailsView.js b/src/views/IOC/IOCDetailsView.js index 85c2982c3535d5b4c4c476baa3e20cfa1827425c..dda37ab0430b060bc9ff0c17f35d0a438f50800a 100644 --- a/src/views/IOC/IOCDetailsView.js +++ b/src/views/IOC/IOCDetailsView.js @@ -59,7 +59,7 @@ export function IOCDetailsView({ ioc, getIOC, abortGetIOC, loading }) { dataReady: operationsDataReady, abort: abortGetOperations } = useAPIMethod({ - fcn: client.apis.Deployments.listOperations, + fcn: client.apis.Operations.listOperations, call: false }); @@ -79,7 +79,7 @@ export function IOCDetailsView({ ioc, getIOC, abortGetIOC, loading }) { dataReady: ongoingCommandDataReady, abort: abortGetOngoingCommand } = useAPIMethod({ - fcn: client.apis.Deployments.listOperations, + fcn: client.apis.Operations.listOperations, params: ongoingCommandParams, call: false }); diff --git a/src/views/host/details/HostJobsSection.js b/src/views/host/details/HostJobsSection.js index 277f96728d3355be272992be92818b34013a7839..3c3d8f64185b15905b445c22fd53141f697db521 100644 --- a/src/views/host/details/HostJobsSection.js +++ b/src/views/host/details/HostJobsSection.js @@ -44,7 +44,7 @@ export const HostJobsSection = ({ loading, abort: abortGetHostLog } = useAPIMethod({ - fcn: client.apis.Deployments.listOperations, + fcn: client.apis.Operations.listOperations, call: false, params: useMemo( () => ({ host_id: hostId, ...pagination }), diff --git a/src/views/jobs/JobDetailsContainer.js b/src/views/jobs/JobDetailsContainer.js index 5a5f59809bbcf1a65954c65f2fe0d70b49cbcb64..0de1ae173ff9c6a90d8379e9758417e58ed5b39b 100644 --- a/src/views/jobs/JobDetailsContainer.js +++ b/src/views/jobs/JobDetailsContainer.js @@ -32,7 +32,7 @@ export function JobDetailsContainer({ id }) { error: operationError, abort: getOperationAbort } = useAPIMethod({ - fcn: client.apis.Deployments.fetchOperation, + fcn: client.apis.Operations.fetchOperation, call: false, params }); @@ -48,7 +48,7 @@ export function JobDetailsContainer({ id }) { }, [operationError]); const deploymentJobParams = useMemo( - () => ({ awx_job_id: operation?.awxJobId }), + () => ({ job_id: operation?.jobId }), [operation] ); @@ -59,7 +59,7 @@ export function JobDetailsContainer({ id }) { dataReady, abort: getJobByIdAbort } = useAPIMethod({ - fcn: client.apis.Deployments.fetchJobDetails, + fcn: client.apis.Operations.fetchJobDetails, params: deploymentJobParams }); @@ -73,14 +73,14 @@ export function JobDetailsContainer({ id }) { } }, [jobFinished, getOperation]); - const getAwxJobUntilFinished = useCallback(() => { + const getJobUntilFinished = useCallback(() => { if (!jobFinished || firstTime.current) { - if (operation?.awxJobId) { - getJobById(operation?.awxJobId); + if (operation?.jobId) { + getJobById(operation?.jobId); firstTime.current = false; } } - }, [operation?.awxJobId, jobFinished, getJobById]); + }, [operation?.jobId, jobFinished, getJobById]); return ( <> @@ -99,9 +99,9 @@ export function JobDetailsContainer({ id }) { loading={operationLoading} abort={getOperationAbort} /> - {operation?.awxJobId && ( + {operation?.jobId && ( <Watcher - get={getAwxJobUntilFinished} + get={getJobUntilFinished} loading={jobLoading || !dataReady} abort={getJobByIdAbort} /> diff --git a/src/views/jobs/JobListView.js b/src/views/jobs/JobListView.js index 46c87776fef61838a4865b4400defba8e36a2997..bb1cc59ee4204f366ababd8754648e113ebb1f24 100644 --- a/src/views/jobs/JobListView.js +++ b/src/views/jobs/JobListView.js @@ -26,7 +26,7 @@ export function JobListView() { dataReady, abort } = useAPIMethod({ - fcn: client.apis.Deployments.listOperations, + fcn: client.apis.Operations.listOperations, call: false });