B.1.2. 检索服务器模块信息

YANG模块库可能随时间而改变。 如前一节所述,客户端可以从API资源中检索服务器支持的“ietf-yang-library”模块的修订日期。

在本例中,客户端以JSON格式从服务器中检索模块信息:

  1. GET /restconf/data/ietf-yang-library:modules-state 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. Cache-Control: no-cache
  5. Last-Modified: Thu, 26 Jan 2017 14:00:14 GMT
  6. Content-Type: application/yang-data+json
  7. {
  8. "ietf-yang-library:modules-state" : {
  9. "module-set-id" : "5479120c17a619545ea6aff7aa19838b036ebbd7",
  10. "module" : [
  11. {
  12. "name" : "foo",
  13. "revision" : "2012-01-02",
  14. "schema" : "https://example.com/modules/foo/2012-01-02",
  15. "namespace" : "http://example.com/ns/foo",
  16. "feature" : [ "feature1", "feature2" ],
  17. "deviation" : [
  18. {
  19. "name" : "foo-dev",
  20. "revision" : "2012-02-16"
  21. }
  22. ],
  23. "conformance-type" : "implement"
  24. },
  25. {
  26. "name" : "ietf-yang-library",
  27. "revision" : "2016-06-21",
  28. "schema" : "https://example.com/modules/\
  29. ietf-yang-library/2016-06-21",
  30. "namespace" :
  31. "urn:ietf:params:xml:ns:yang:ietf-yang-library",
  32. "conformance-type" : "implement"
  33. },
  34. {
  35. "name" : "foo-types",
  36. "revision" : "2012-01-05",
  37. "schema" :
  38. "https://example.com/modules/foo-types/2012-01-05",
  39. "namespace" : "http://example.com/ns/foo-types",
  40. "conformance-type" : "import"
  41. },
  42. {
  43. "name" : "bar",
  44. "revision" : "2012-11-05",
  45. "schema" : "https://example.com/modules/bar/2012-11-05",
  46. "namespace" : "http://example.com/ns/bar",
  47. "feature" : [ "bar-ext" ],
  48. "conformance-type" : "implement",
  49. "submodule" : [
  50. {
  51. "name" : "bar-submod1",
  52. "revision" : "2012-11-05",
  53. "schema" :
  54. "https://example.com/modules/bar-submod1/2012-11-05"
  55. },
  56. {
  57. "name" : "bar-submod2",
  58. "revision" : "2012-11-05",
  59. "schema" :
  60. "https://example.com/modules/bar-submod2/2012-11-05"
  61. }
  62. ]
  63. }
  64. ]
  65. }
  66. }