B.1.1. 检索顶级API资源

客户端通过检索RESTCONF根资源开始:

  1. GET /.well-known/host-meta HTTP/1.1
  2. Host: example.com
  3. Accept: application/xrd+xml

服务器可能会如下回应:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/xrd+xml
  3. Content-Length: nnn
  4. <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
  5. <Link rel='restconf' href='/restconf'/>
  6. </XRD>

客户端然后可以使用根资源“/restconf”来检索顶级API资源。

  1. GET /restconf HTTP/1.1
  2. Host: example.com
  3. Accept: application/yang-data+json

服务器可能会如下回应:

  1. HTTP/1.1 200 OK
  2. Date: Thu, 26 Jan 2017 20:56:30 GMT
  3. Server: example-server
  4. Content-Type: application/yang-data+json
  5. {
  6. "ietf-restconf:restconf" : {
  7. "data" : {},
  8. "operations" : {},
  9. "yang-library-version" : "2016-06-21"
  10. }
  11. }

如果要请求以XML格式编码响应内容,可以使用“Accept”头信息,如下面的示例请求所示:

  1. GET /restconf HTTP/1.1
  2. Host: example.com
  3. Accept: application/yang-data+xml

服务器将以任何方式返回相同的概念数据,可能如下所示:

  1. HTTP/1.1 200 OK
  2. Date: Thu, 26 Jan 2017 20:56:30 GMT
  3. Server: example-server
  4. Cache-Control: no-cache
  5. Content-Type: application/yang-data+xml
  6. <restconf xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
  7. <data/>
  8. <operations/>
  9. <yang-library-version>2016-06-21</yang-library-version>
  10. </restconf>