Skip to content

Commit

Permalink
Retrieve ci relationship types (ServiceNowDevProgram#856)
Browse files Browse the repository at this point in the history
* Create RetriveCiRelationshipTypes.jss.js

This is the Rest Resources for Retrive CI Relationship Types

* Update CmdbApi.js

Add the function getCilatRelationshipTypes for retrieving the CI relationships from the instance

* Update readme.md

Contains scripted REST API to retrieve a list of Configuration Item (CI) Relationship Types from the ServiceNow instance.

* Remove additional extension from file name

.jss was present in the filename, this seems to be in error and is not aligned with the other file names so removing

---------

Co-authored-by: Astrid Sapphire <[email protected]>
  • Loading branch information
amigujarathi and SapphicFire authored Oct 15, 2023
1 parent 15c5034 commit e2884dc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Scripted REST Api/CMDB API/CmdbApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,21 @@ createCiRelationship: function() {
response['ciDetails'] = CI_details;
return response;
},



/**
* Retrieves a list of Configuration Item (CI) Relationship Types from the ServiceNow instance.
* Mapped to GET /cis/relationshiptypes
* @function
* @name getCiRelationshipTypes
* @returns {GlideRecord} A GlideRecord object representing the list of CI Relationship Types.
* @throws {Error} If there is an issue with the retrieval process.
**/
getCiRelationshipTypes: function() {
return this._getGrResultStream('cmdb_rel_type', null, {
sysparm_limit: 100
});
},

/**
* Determine the type of source ID.
* @function getSourceIDtype
Expand Down
6 changes: 6 additions & 0 deletions Scripted REST Api/CMDB API/RetriveCiRelationshipTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

// implement resource here
return new CmdbApi(request, response).getCiRelationshipTypes();

})(request, response);
15 changes: 15 additions & 0 deletions Scripted REST Api/CMDB API/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Table of Contents
3. Delete CI
4. Delete CI Relationship
5. Retrieve CI Group
6. Retrieve CI Relationship types

1. Create CIs
This API is designed to create Configuration Items (CIs).
Expand Down Expand Up @@ -84,3 +85,17 @@ Table of Contents
Response:
Status Code: 200 OK
Response Body: Details of CI and its group

6. Retrieve CI Relationship types
Scripted REST API Resource is designed to retrieve a list of Configuration Item (CI) Relationship Types from the ServiceNow instance.
Request Details:
Type: HTTP
Method: GET
URI: https://<service-now-domain>.service-now.com/api/cis/relationshiptypes
Headers:
Accept: application/json
Content-Type: application/json
Request Body: NA
Response:
Status Code: 200 OK
Response Body: Details of CI Relationship types

0 comments on commit e2884dc

Please sign in to comment.