获取两个 CI 之间的关系

获取两个 CI 之间的关系

要读取 CI 的特定关系,请使用以下网址:

 

http://<servername>:<portnumber>/api/cmdb/cirelationships/CI Name 1<->CI Name 2/

假设您要读取 CI 的特定关系(例如:技术人员正在使用的服务器),可从端口号为 8080 的本地服务器读取,URL 应为

http://localhost:8080/api/cmdb/cirelationships/connector.iad8.amazon.com<->dlf-1w.printer-1/

 

关键字

  1. 操作名称 “read”应作为 “POST attribute”发送,其关键字为 “OPERATION_NAME”。

  2. 技术员密钥应作为 “POST attribute”发送,密钥为 “TECHNICIAN_KE”。

 

注意:  

如果未指定结果格式,API 将以 JSON 格式返回输出。

  • 参数结果格式 - 可选。指定返回格式(XML 或 JSON)

 

 

 

必填参数:

  • 两个 CI 之间的符号是强制性的

  • CI 名称1 - 必须填写。 CI 名称可以不区分大小写。

 

 

 

 

两个 CI 之间关系的 XML 输出示例: 这里,网络服务器 connector.iad8.amazon.com 与 dlf-1w.printer-1 打印机相连。

 

 

<?xml version="1.0" encoding="UTF-8"?>

<API version="1.0">

    <response>

            <result>

                <statuscode>200</statuscode>

                <status>Success</status>

                <message>Successfully fetched.</message>

                <created-date>Mar 22, 2013 12:51 PM</created-date>

                         <relationships for="connector.iad8.amazon.com">

                                   <relationship>

                                    <name>Connected to</name>

                                        <ci>

                                              <type>Printer</type>

                                               <name>dlf-1w.printer-1</name>

                                               <relattributes/>

                                         </ci>

                                   </relationship>

                         </relationships>

             </result>        

    </response>

</API>

JSON 响应示例:

 

 

{

    "API": {

        "response": {

            "result": {

                "created-date": "Sep 2, 2013 03:05 PM",

                "message": "Successfully fetched.",

                "status": "Success",

                "statuscode": "200",

                "relationships": {

                    "relationship": {

                        "ci": {

                            "type": "Switch Ports",

                            "name": "connector.iad8.amazon.com"

                        },

                        "name": "Connected to"

                    },

                    "for": "DLF11thFloor-I.csez.zohocorpin.com"

                }

            }

        },

        "operation": {

            "name": "read"

        },

        "version": "1.0"

    }

}