This documentation supports the 9.0 version of BMC Atrium Core.

To view the latest version, select the version from the Product version menu.

/instance/{datasetId}/{namespace}/{className}/{instanceId}/graph

The following operation is available on the resource:

Graph Walk

DescriptionGraph walk API is used to query CI and get the result as graph data format. The result either contains the complete data or URI to the resource, this is based on the graph query parameters passed as query parameter.
URL Qualifier

/instance/{datasetId}/{namespace}/{className}/{instanceId}/graph?rel=({namespace}, {className}, {direction})&cl=({namespace}, {className})&mode={mode}&level={level}&datasetMask={datasetMask}

datasetId - Dataset Id under which the instances needs to retrieved. You can set this value to 0 if you do not want to specify a particular dataset.
namespace - namespace of the class that is starting node of graph walk 
className - name of the class that is starting node of graph walk
instanceId - actual instanceId which is the starting node of graph walk

Method

GET
Header
HeaderValue
Authorizationtoken
Parameters
NameDescription
rel

Used to specify the relationships to traverse. Additional details like className, classNamespace, and direction are also specified along with this parameter, where direction can have the following three values:

0 - query traverses from the source to the destination
1 - query traverses from the destination to the source
2 - query traverses the relationship, irrespective of direction

clReturns comma separated values for className and classNamespace
mode

Used to specify the end point for graph walk, where mode can have the following three values:

0 - stop traversing at the point where the first non-matching result is found
1 - stop traversing at the point where the first matching result is found
2 - walk the entire graph, irrespective of matching and non-matching results

levelSpecifies number of graph levels to traverse.
datasetMask

Used to specify if the instance should be fetched from overlay or base dataset.

0 – Retrieves instances from the base dataset, if the instances are not found in the overlay dataset.
1 – Retrieves instances from overlay dataset only.

ReturnsReturns list of relationships and classes walked during the search.

    The following shows example for Graph query.

    Request URL

    GET http://{{host}}:{{port}}/api/cmdb/v1/instance/BMC.ASSET/BMC.CORE/BMC_ComputerSystem/OI-4DCF54F56D7A430CBEB92CBEB88D8511/graph/?rel=(BMC_Dependency,
    BMC.CORE , 2)&cl=(BMC_BusinessService, BMC.CORE)&mode=2&level=10
    

    Request header

    Content-Type: multipart/form-data;
    
    Authorization: AR-JWT
    eyJhbGciOiJIUzI1NiJ9.
    eyJleHAiOjE0MTQ2MTU3MzUsInN1YiI6IkRlbW8iLCJuYmYi
    OjE0MTQ2MTIwMTUsImlzcyI6IkFSODkiLCJqdGkiOiJJREdEUjRXQUJMSk9CQU40SUJQOUFBQUFIRENLT1QiLCJfY2Fja
    GVJZCI6MzgxLCJpYXQiOjE0MTQ2MTIxMzV9.Rd4arC9huCnuJvExDLp0lZ3VeXvTxfC8DCuvaBGCaog

    The following is a sample code snippet for the Graph Query.

    package com.bmc.cmdb.restapi.example;
    
    import java.nio.charset.StandardCharsets;
    
    import org.apache.http.HttpEntity;
    import org.apache.http.client.methods.CloseableHttpResponse;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.CloseableHttpClient;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.util.EntityUtils;
    
    public class Graph {
    
        public static void main(String[] args) throws Exception {
            String token = args[0];
    
            // start HTTP GET to get an entry
            CloseableHttpClient httpClient = HttpClients.createDefault();
            HttpGet httpGet = new HttpGet(
                    "http://host:8008/api/cmdb/v1/instance/BMC.ASSET/BMC.CORE/
    BMC_ComputerSystem/OI-4DCF54F56D7A430CBEB92CBEB88D8511/graph/?rel=(BMC_Dependency, BMC.CORE , 
    2)&cl=(BMC_BusinessService, BMC.CORE)&mode=2&level=10");
    
            // add the token to the header
            httpGet.addHeader("Authorization", "AR-JWT " + token);
    
            // make the call and print the status
            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
                HttpEntity entity = response.getEntity();
                String jsonEntry = EntityUtils.toString(entity, StandardCharsets.UTF_8);
                System.out.println(jsonEntry);
            }
        }
    }

    Related topics

    Was this page helpful? Yes No Submitting... Thank you

    Comments