From 7f1ebe5862af302a8f64f4e534631a1902cc31a2 Mon Sep 17 00:00:00 2001 From: Amit Gujarathi Date: Thu, 19 Oct 2023 00:21:12 +0530 Subject: [PATCH 1/3] Create Retrieve_CI_Relationships.js Scripted Rest API to Retrive CI Relationships --- Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js diff --git a/Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js b/Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js new file mode 100644 index 0000000000..aed987063f --- /dev/null +++ b/Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js @@ -0,0 +1,6 @@ +(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { + + // implement resource here + return new CmdbApi(request, response).getRelationships(); + +})(request, response); From f7da517fc1a6d27711183a51aa13d49999f4803e Mon Sep 17 00:00:00 2001 From: Amit Gujarathi Date: Thu, 19 Oct 2023 00:24:49 +0530 Subject: [PATCH 2/3] Update CmdbApi.js Function to Retrieve Configuration Item (CI) Relationships. --- Scripted REST Api/CMDB API/CmdbApi.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Scripted REST Api/CMDB API/CmdbApi.js b/Scripted REST Api/CMDB API/CmdbApi.js index 83a3d1ac54..678c6b6cf2 100644 --- a/Scripted REST Api/CMDB API/CmdbApi.js +++ b/Scripted REST Api/CMDB API/CmdbApi.js @@ -387,6 +387,22 @@ createCiRelationship: function() { return new sn_ws_err.NotFoundError('No record found'); } }, +/** + * Retrieve Configuration Item (CI) Relationships. + * Mapped to GET /cis/relationships + * + * This function retrieves CI relationships + * + * @returns {Object} JSON response containing the CI relationships or error details. + */ + getRelationships: function() { + var self = this; + + return self._getGrResultStream('cmdb_rel_ci', null, { + sysparm_limit: 100 + }); + + }, /** * Determine the type of source ID. From 146077dfdba69d5f3d704b60605af9d90bbd52b5 Mon Sep 17 00:00:00 2001 From: Amit Gujarathi Date: Thu, 19 Oct 2023 00:28:07 +0530 Subject: [PATCH 3/3] Update readme.md Added te scripted REST API to retrieve CI relationships --- Scripted REST Api/CMDB API/readme.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Scripted REST Api/CMDB API/readme.md b/Scripted REST Api/CMDB API/readme.md index 87be07e4fb..f5ac3e62a8 100644 --- a/Scripted REST Api/CMDB API/readme.md +++ b/Scripted REST Api/CMDB API/readme.md @@ -10,6 +10,7 @@ Table of Contents 6. Retrieve CI Relationship types 7. Retrieve CIs 8. Update CI +9. Retrieve CI Relationships 1. Create CIs This API is designed to create Configuration Items (CIs). @@ -130,3 +131,18 @@ Table of Contents Response: Status Code: 200 OK Response Body: JSON with required fields + +9. Retrieve CI relationships + This API is designed to retrieve Configuration Item (CI) relationships. + Request Details: + Type: HTTP + Method: GET + URI: https://.service-now.com/api/cis/relationships + Headers: + Accept: application/json + Content-Type: application/json + Request Body: + NA + Response: + Status Code: 200 OK + Response Body: JSON with CI relationships required details