获取 CI 的具体关系

获取 CI 的具体关系

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

 

http://<servername>:<portnumber>/api/cmdb/cirelationships/CI Name/<Relationship Type>

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

http://localhost:8080/api/cmdb/cirelationships/CI Name/Charles/Uses

 

 

关键点

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

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

 

注意:  

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

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

 

必填参数:  

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

  • 关系类型 - 必填。 关系类型名称可以不区分大小写。

 

 

读取 CI 特定关系的 XML 输出示例

 

<?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:57 PM</created-date>

                           <relationships for="Charles">

                                  <relationship>

                                  <name>Uses</name>

                                      <ci>

                                         <type>Server</type>

                                        <name>opman-solaris1.csez.zohocorpin.com</name>

                                        <relattributes/>

                                      </ci>

                                <relationship>

                           </relationships>

              </result>

    </response>

</API>

 

 

读取 CI 特定关系的 JSON 输出示例

 

{

    "API": {

        "response": {

            "result": {

                "created-date": "Sep 2, 2013 02:59 PM",

                "message": "Successfully fetched.",

                "status": "Success",

                "statuscode": "200",

                "relationships": {

                    "relationship": {

                        "ci": {

                            "type": "Mac Workstation",

                            "relattributes": {},

                            "name": "sdp-imac.csez.zohocorpin.com"

                        },

                        "name": "Uses"

                    },

                    "for": "Charles"

                }

            }

        },

        "operation": {

            "name": "read"

        },

        "version": "1.0"

    }

}