types.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. package bookstackclient
  2. import "time"
  3. // Shelves represents the BookStack API endpoint /api/shelves
  4. type Shelves struct {
  5. Data []struct {
  6. ID int `json:"id"`
  7. Name string `json:"name"`
  8. Slug string `json:"slug"`
  9. Description string `json:"description"`
  10. CreatedAt time.Time `json:"created_at"`
  11. UpdatedAt time.Time `json:"updated_at"`
  12. CreatedBy int `json:"created_by"`
  13. UpdatedBy int `json:"updated_by"`
  14. OwnedBy int `json:"owned_by"`
  15. ImageID int `json:"image_id"`
  16. } `json:"data"`
  17. Total int `json:"total"`
  18. }
  19. // Shelf represents the BookStack API endpoint /api/shelves/{id}
  20. type Shelf struct {
  21. ID int `json:"id"`
  22. Name string `json:"name"`
  23. Slug string `json:"slug"`
  24. Description string `json:"description"`
  25. CreatedBy struct {
  26. ID int `json:"id"`
  27. Name string `json:"name"`
  28. } `json:"created_by"`
  29. UpdatedBy struct {
  30. ID int `json:"id"`
  31. Name string `json:"name"`
  32. } `json:"updated_by"`
  33. OwnedBy struct {
  34. ID int `json:"id"`
  35. Name string `json:"name"`
  36. } `json:"owned_by"`
  37. CreatedAt time.Time `json:"created_at"`
  38. UpdatedAt time.Time `json:"updated_at"`
  39. Tags []struct {
  40. ID int `json:"id"`
  41. Name string `json:"name"`
  42. Value string `json:"value"`
  43. Order int `json:"order"`
  44. } `json:"tags"`
  45. Cover struct {
  46. ID int `json:"id"`
  47. Name string `json:"name"`
  48. URL string `json:"url"`
  49. CreatedAt time.Time `json:"created_at"`
  50. UpdatedAt time.Time `json:"updated_at"`
  51. CreatedBy int `json:"created_by"`
  52. UpdatedBy int `json:"updated_by"`
  53. Path string `json:"path"`
  54. Type string `json:"type"`
  55. UploadedTo int `json:"uploaded_to"`
  56. } `json:"cover"`
  57. Books []struct {
  58. ID int `json:"id"`
  59. Name string `json:"name"`
  60. Slug string `json:"slug"`
  61. } `json:"books"`
  62. }
  63. // Books represents the BookStack API endpoint /api/books
  64. type Books struct {
  65. Data []struct {
  66. ID int `json:"id"`
  67. Name string `json:"name"`
  68. Slug string `json:"slug"`
  69. Description string `json:"description"`
  70. CreatedAt time.Time `json:"created_at"`
  71. UpdatedAt time.Time `json:"updated_at"`
  72. CreatedBy int `json:"created_by"`
  73. UpdatedBy int `json:"updated_by"`
  74. OwnedBy int `json:"owned_by"`
  75. ImageID int `json:"image_id"`
  76. } `json:"data"`
  77. Total int `json:"total"`
  78. }
  79. // Book represents the BookStack API endpoint /api/books/{id}
  80. type Book struct {
  81. ID int `json:"id"`
  82. Name string `json:"name"`
  83. Slug string `json:"slug"`
  84. Description string `json:"description"`
  85. CreatedAt time.Time `json:"created_at"`
  86. UpdatedAt time.Time `json:"updated_at"`
  87. CreatedBy struct {
  88. ID int `json:"id"`
  89. Name string `json:"name"`
  90. } `json:"created_by"`
  91. UpdatedBy struct {
  92. ID int `json:"id"`
  93. Name string `json:"name"`
  94. } `json:"updated_by"`
  95. OwnedBy struct {
  96. ID int `json:"id"`
  97. Name string `json:"name"`
  98. } `json:"owned_by"`
  99. Tags []struct {
  100. ID int `json:"id"`
  101. Name string `json:"name"`
  102. Value string `json:"value"`
  103. Order int `json:"order"`
  104. } `json:"tags"`
  105. Cover struct {
  106. ID int `json:"id"`
  107. Name string `json:"name"`
  108. URL string `json:"url"`
  109. CreatedAt time.Time `json:"created_at"`
  110. UpdatedAt time.Time `json:"updated_at"`
  111. CreatedBy int `json:"created_by"`
  112. UpdatedBy int `json:"updated_by"`
  113. Path string `json:"path"`
  114. Type string `json:"type"`
  115. UploadedTo int `json:"uploaded_to"`
  116. } `json:"cover"`
  117. }
  118. // Chapters represents the BookStack API endpoint /api/chapters
  119. type Chapters struct {
  120. Data []struct {
  121. ID int `json:"id"`
  122. BookID int `json:"book_id"`
  123. Name string `json:"name"`
  124. Slug string `json:"slug"`
  125. Description string `json:"description"`
  126. Priority int `json:"priority"`
  127. CreatedAt string `json:"created_at"`
  128. UpdatedAt time.Time `json:"updated_at"`
  129. CreatedBy int `json:"created_by"`
  130. UpdatedBy int `json:"updated_by"`
  131. OwnedBy int `json:"owned_by"`
  132. } `json:"data"`
  133. Total int `json:"total"`
  134. }
  135. // Chapter represents the BookStack API endpoint /api/chapters/{id}
  136. type Chapter struct {
  137. ID int `json:"id"`
  138. BookID int `json:"book_id"`
  139. Slug string `json:"slug"`
  140. Name string `json:"name"`
  141. Description string `json:"description"`
  142. Priority int `json:"priority"`
  143. CreatedAt time.Time `json:"created_at"`
  144. UpdatedAt time.Time `json:"updated_at"`
  145. CreatedBy struct {
  146. ID int `json:"id"`
  147. Name string `json:"name"`
  148. } `json:"created_by"`
  149. UpdatedBy struct {
  150. ID int `json:"id"`
  151. Name string `json:"name"`
  152. } `json:"updated_by"`
  153. OwnedBy struct {
  154. ID int `json:"id"`
  155. Name string `json:"name"`
  156. } `json:"owned_by"`
  157. Tags []struct {
  158. Name string `json:"name"`
  159. Value string `json:"value"`
  160. Order int `json:"order"`
  161. } `json:"tags"`
  162. Pages []struct {
  163. ID int `json:"id"`
  164. BookID int `json:"book_id"`
  165. ChapterID int `json:"chapter_id"`
  166. Name string `json:"name"`
  167. Slug string `json:"slug"`
  168. Priority int `json:"priority"`
  169. CreatedAt time.Time `json:"created_at"`
  170. UpdatedAt time.Time `json:"updated_at"`
  171. CreatedBy int `json:"created_by"`
  172. UpdatedBy int `json:"updated_by"`
  173. Draft bool `json:"draft"`
  174. RevisionCount int `json:"revision_count"`
  175. Template bool `json:"template"`
  176. } `json:"pages"`
  177. }
  178. // Pages represents the BookStack API endpoint /api/pages
  179. type Pages struct {
  180. Data []struct {
  181. ID int `json:"id"`
  182. BookID int `json:"book_id"`
  183. ChapterID int `json:"chapter_id"`
  184. Name string `json:"name"`
  185. Slug string `json:"slug"`
  186. Priority int `json:"priority"`
  187. Draft bool `json:"draft"`
  188. Template bool `json:"template"`
  189. CreatedAt time.Time `json:"created_at"`
  190. UpdatedAt time.Time `json:"updated_at"`
  191. CreatedBy int `json:"created_by"`
  192. UpdatedBy int `json:"updated_by"`
  193. OwnedBy int `json:"owned_by"`
  194. } `json:"data"`
  195. Total int `json:"total"`
  196. }
  197. // Page represents the BookStack API endpoint /api/pages/{id}
  198. type Page struct {
  199. ID int `json:"id"`
  200. BookID int `json:"book_id"`
  201. ChapterID int `json:"chapter_id"`
  202. Name string `json:"name"`
  203. Slug string `json:"slug"`
  204. HTML string `json:"html"`
  205. Priority int `json:"priority"`
  206. CreatedAt time.Time `json:"created_at"`
  207. UpdatedAt time.Time `json:"updated_at"`
  208. CreatedBy struct {
  209. ID int `json:"id"`
  210. Name string `json:"name"`
  211. } `json:"created_by"`
  212. UpdatedBy struct {
  213. ID int `json:"id"`
  214. Name string `json:"name"`
  215. } `json:"updated_by"`
  216. OwnedBy struct {
  217. ID int `json:"id"`
  218. Name string `json:"name"`
  219. } `json:"owned_by"`
  220. Draft bool `json:"draft"`
  221. Markdown string `json:"markdown"`
  222. RevisionCount int `json:"revision_count"`
  223. Template bool `json:"template"`
  224. Tags []struct {
  225. Name string `json:"name"`
  226. Value string `json:"value"`
  227. Order int `json:"order"`
  228. } `json:"tags"`
  229. }
  230. // Wiki is the BookStack2Site representation of a Wiki
  231. type Wiki struct {
  232. Name string
  233. Books []WikiBook
  234. // one book can be on multiple shelves
  235. Shelves []WikiShelf
  236. }
  237. type WikiShelf struct {
  238. ShelfID int
  239. Name string
  240. Slug string
  241. BookIDs []int
  242. }
  243. type WikiChapter struct {
  244. ChapterID int
  245. Name string
  246. Slug string
  247. Priority int
  248. Pages []WikiPage
  249. }
  250. type WikiPage struct {
  251. PageID int
  252. Name string
  253. Slug string
  254. Priority int
  255. // FilePath is path of file relative to root of wiki. To be filled while downloading.
  256. // Should start with a '/'.
  257. // Should not end with a '/'.
  258. FilePath string
  259. }
  260. type WikiBook struct {
  261. BookID int
  262. Name string
  263. Slug string
  264. // a book can have pages in chapters or independent pages
  265. Chapters []WikiChapter
  266. IndiePages []WikiPage
  267. }