A.1. “example-jukebox”的YANG模块

  1. module example-jukebox {
  2. namespace "http://example.com/ns/example-jukebox";
  3. prefix "jbox";
  4. organization "Example, Inc.";
  5. contact "support at example.com";
  6. description "Example Jukebox Data Model Module.";
  7. revision "2016-08-15" {
  8. description "Initial version.";
  9. reference "example.com document 1-4673.";
  10. }
  11. identity genre {
  12. description
  13. "Base for all genre types.";
  14. }
  15. // abbreviated list of genre classifications
  16. identity alternative {
  17. base genre;
  18. description
  19. "Alternative music.";
  20. }
  21. identity blues {
  22. base genre;
  23. description
  24. "Blues music.";
  25. }
  26. identity country {
  27. base genre;
  28. description
  29. "Country music.";
  30. }
  31. identity jazz {
  32. base genre;
  33. description
  34. "Jazz music.";
  35. }
  36. identity pop {
  37. base genre;
  38. description
  39. "Pop music.";
  40. }
  41. identity rock {
  42. base genre;
  43. description
  44. "Rock music.";
  45. }
  46. container jukebox {
  47. presence
  48. "An empty container indicates that the jukebox
  49. service is available.";
  50. description
  51. "Represents a 'jukebox' resource, with a library, playlists,
  52. and a 'play' operation.";
  53. container library {
  54. description
  55. "Represents the 'jukebox' library resource.";
  56. list artist {
  57. key name;
  58. description
  59. "Represents one 'artist' resource within the
  60. 'jukebox' library resource.";
  61. leaf name {
  62. type string {
  63. length "1 .. max";
  64. }
  65. description
  66. "The name of the artist.";
  67. }
  68. list album {
  69. key name;
  70. description
  71. "Represents one 'album' resource within one
  72. 'artist' resource, within the jukebox library.";
  73. leaf name {
  74. type string {
  75. length "1 .. max";
  76. }
  77. description
  78. "The name of the album.";
  79. }
  80. leaf genre {
  81. type identityref { base genre; }
  82. description
  83. "The genre identifying the type of music on
  84. the album.";
  85. }
  86. leaf year {
  87. type uint16 {
  88. range "1900 .. max";
  89. }
  90. description
  91. "The year the album was released.";
  92. }
  93. container admin {
  94. description
  95. "Administrative information for the album.";
  96. leaf label {
  97. type string;
  98. description
  99. "The label that released the album.";
  100. }
  101. leaf catalogue-number {
  102. type string;
  103. description
  104. "The album's catalogue number.";
  105. }
  106. }
  107. list song {
  108. key name;
  109. description
  110. "Represents one 'song' resource within one
  111. 'album' resource, within the jukebox library.";
  112. leaf name {
  113. type string {
  114. length "1 .. max";
  115. }
  116. description
  117. "The name of the song.";
  118. }
  119. leaf location {
  120. type string;
  121. mandatory true;
  122. description
  123. "The file location string of the
  124. media file for the song.";
  125. }
  126. leaf format {
  127. type string;
  128. description
  129. "An identifier string for the media type
  130. for the file associated with the
  131. 'location' leaf for this entry.";
  132. }
  133. leaf length {
  134. type uint32;
  135. units "seconds";
  136. description
  137. "The duration of this song in seconds.";
  138. }
  139. } // end list 'song'
  140. } // end list 'album'
  141. } // end list 'artist'
  142. leaf artist-count {
  143. type uint32;
  144. units "artists";
  145. config false;
  146. description
  147. "Number of artists in the library.";
  148. }
  149. leaf album-count {
  150. type uint32;
  151. units "albums";
  152. config false;
  153. description
  154. "Number of albums in the library.";
  155. }
  156. leaf song-count {
  157. type uint32;
  158. units "songs";
  159. config false;
  160. description
  161. "Number of songs in the library.";
  162. }
  163. } // end library
  164. list playlist {
  165. key name;
  166. description
  167. "Example configuration data resource.";
  168. leaf name {
  169. type string;
  170. description
  171. "The name of the playlist.";
  172. }
  173. leaf description {
  174. type string;
  175. description
  176. "A comment describing the playlist.";
  177. }
  178. list song {
  179. key index;
  180. ordered-by user;
  181. description
  182. "Example nested configuration data resource.";
  183. leaf index { // not really needed
  184. type uint32;
  185. description
  186. "An arbitrary integer index for this playlist song.";
  187. }
  188. leaf id {
  189. type instance-identifier;
  190. mandatory true;
  191. description
  192. "Song identifier. Must identify an instance of
  193. /jukebox/library/artist/album/song/name.";
  194. }
  195. }
  196. }
  197. container player {
  198. description
  199. "Represents the jukebox player resource.";
  200. leaf gap {
  201. type decimal64 {
  202. fraction-digits 1;
  203. range "0.0 .. 2.0";
  204. }
  205. units "tenths of seconds";
  206. description
  207. "Time gap between each song.";
  208. }
  209. }
  210. }
  211. rpc play {
  212. description
  213. "Control function for the jukebox player.";
  214. input {
  215. leaf playlist {
  216. type string;
  217. mandatory true;
  218. description
  219. "The playlist name.";
  220. }
  221. leaf song-number {
  222. type uint32;
  223. mandatory true;
  224. description
  225. "Song number in playlist to play.";
  226. }
  227. }
  228. }
  229. }