docs.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. // Package classification Netmaker
  2. //
  3. // # API Usage
  4. //
  5. // Most actions that can be performed via API can be performed via UI. We recommend managing your networks using the official netmaker-ui project. However, Netmaker can also be run without the UI, and all functions can be achieved via API calls. If your use case requires using Netmaker without the UI or you need to do some troubleshooting/advanced configuration, using the API directly may help.
  6. //
  7. // # Authentication
  8. //
  9. // API calls must be authenticated via a header of the format -H “Authorization: Bearer <YOUR_SECRET_KEY>” There are two methods to obtain YOUR_SECRET_KEY: 1. Using the masterkey. By default, this value is “secret key,” but you should change this on your instance and keep it secure. This value can be set via env var at startup or in a config file (config/environments/< env >.yaml). See the [Netmaker](https://docs.netmaker.org/index.html) documentation for more details. 2. Using a JWT received for a node. This can be retrieved by calling the /api/nodes/<network>/authenticate endpoint, as documented below.
  10. //
  11. // Schemes: https
  12. // BasePath: /
  13. // Version: 0.21.1
  14. // Host: api.demo.netmaker.io
  15. //
  16. // Consumes:
  17. // - application/json
  18. //
  19. // Produces:
  20. // - application/json
  21. //
  22. // Security:
  23. // - oauth
  24. //
  25. // swagger:meta
  26. package controller
  27. import (
  28. "os"
  29. "github.com/gravitl/netmaker/config"
  30. "github.com/gravitl/netmaker/logic/acls"
  31. "github.com/gravitl/netmaker/models"
  32. )
  33. var _ = useUnused() // "use" the function to prevent "unused function" errors
  34. // swagger:parameters getFile
  35. type filenameToGet struct {
  36. // Filename
  37. // in: path
  38. // required: true
  39. Filename string `json:"filename"`
  40. }
  41. // swagger:response hasAdmin
  42. type hasAdmin struct {
  43. // in: body
  44. Admin bool
  45. }
  46. // swagger:response apiHostResponse
  47. type apiHostResponse struct {
  48. // in: body
  49. Host models.ApiHost
  50. }
  51. // swagger:parameters getNodeDNS getCustomDNS getDNS
  52. type dnsNetworkPathParam struct {
  53. // Network
  54. // in: path
  55. Network string `json:"network"`
  56. }
  57. // swagger:parameters createDNS
  58. type dnsParams struct {
  59. // Network
  60. // in: path
  61. Network string `json:"network"`
  62. // DNS Entry
  63. // in: body
  64. Body []models.DNSEntry `json:"body"`
  65. }
  66. // Success
  67. // swagger:response dnsResponse
  68. type dnsResponse struct {
  69. // in: body
  70. Body []models.DNSEntry `json:"body"`
  71. }
  72. // swagger:parameters deleteDNS
  73. type dnsDeletePathParams struct {
  74. // Network
  75. // in: path
  76. Network string `json:"network"`
  77. // Domain
  78. // in: path
  79. Domain string `json:"domain"`
  80. }
  81. // swagger:response stringJSONResponse
  82. type stringJSONResponse struct {
  83. // Response
  84. // in: body
  85. Response string `json:"response"`
  86. }
  87. //swagger:response EnrollmentKey
  88. type EnrollmentKey struct {
  89. // in: body
  90. EnrollmentKey models.EnrollmentKey
  91. }
  92. //swagger:response EnrollmentKeys
  93. type EnrollmentKeys struct {
  94. // in: body
  95. EnrollmentKeys []models.EnrollmentKey
  96. }
  97. // swagger:parameters getAllExtClients
  98. type getAllClientsRequest struct {
  99. // Networks
  100. // in:body
  101. Networks []string `json:"networks"`
  102. }
  103. // swagger:response extClientSliceResponse
  104. type extClientSliceResponse struct {
  105. // ExtClients
  106. // in: body
  107. ExtClients []models.ExtClient `json:"ext_clients"`
  108. }
  109. // swagger:response extClientResponse
  110. type extClientResponse struct {
  111. // ExtClient
  112. // in: body
  113. ExtClient models.ExtClient `json:"ext_client"`
  114. }
  115. // swagger:response fileResponse
  116. type fileResponse struct {
  117. // in: body
  118. File os.File
  119. }
  120. // swagger:response successResponse
  121. type successResponse struct {
  122. // Success Response
  123. // in: body
  124. SuccessResponse models.SuccessResponse `json:"success_response"`
  125. }
  126. // swagger:parameters getExtClientConf
  127. type extClientConfParams struct {
  128. // Client ID
  129. // in: path
  130. ClientID string `json:"clientid"`
  131. // Network
  132. // in: path
  133. Network string `json:"network"`
  134. // Type
  135. // in: path
  136. Type string `json:"type"`
  137. }
  138. // swagger:parameters getExtClient getExtClientConf updateExtClient deleteExtClient
  139. type extClientPathParams struct {
  140. // Client ID
  141. // in: path
  142. ClientID string `json:"clientid"`
  143. // Network
  144. // in: path
  145. Network string `json:"network"`
  146. }
  147. // swagger:parameters updateExtClient
  148. type extClientBodyParam struct {
  149. // ExtClient
  150. // in: body
  151. ExtClient models.ExtClient `json:"ext_client"`
  152. }
  153. // swagger:parameters getNetworkExtClients
  154. type extClientNetworkPathParam struct {
  155. // Network
  156. // in: path
  157. Network string `json:"network"`
  158. }
  159. // swagger:parameters createExtClient
  160. type createExtClientPathParams struct {
  161. // Network
  162. // in: path
  163. Network string `json:"network"`
  164. // Node ID
  165. // in: path
  166. NodeID string `json:"nodeid"`
  167. // Custom ExtClient
  168. // in: body
  169. CustomExtClient models.CustomExtClient `json:"custom_ext_client"`
  170. }
  171. // swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway ingressGatewayUsers
  172. type networkNodePathParams struct {
  173. // in: path
  174. Network string `json:"network"`
  175. // in: path
  176. NodeID string `json:"nodeid"`
  177. }
  178. // swagger:response byteArrayResponse
  179. type byteArrayResponse struct {
  180. // in: body
  181. ByteArray []byte `json:"byte_array"`
  182. }
  183. // swagger:parameters getNetwork deleteNetwork updateNetwork getNetworkACL updateNetworkACL
  184. type NetworkParam struct {
  185. // name: network name
  186. // in: path
  187. Networkname string `json:"networkname"`
  188. }
  189. // swagger:response getNetworksSliceResponse
  190. type getNetworksSliceResponse struct {
  191. // Networks
  192. // in: body
  193. Networks []models.Network `json:"networks"`
  194. }
  195. // swagger:response hostPull
  196. type hostPull struct {
  197. // hostPull
  198. // in: body
  199. HostPull models.HostPull
  200. }
  201. // swagger:parameters createNetwork updateNetwork
  202. type networkBodyParam struct {
  203. // Network
  204. // in: body
  205. Network models.Network `json:"network"`
  206. }
  207. // swagger:parameters updateNetworkNodeLimit keyUpdate createAccessKey getAccessKeys getNetworkNodes
  208. type networkPathParam struct {
  209. // Network
  210. // in: path
  211. Network string `json:"network"`
  212. }
  213. // swagger:response networkBodyResponse
  214. type networkBodyResponse struct {
  215. // Network
  216. // in: body
  217. Network models.Network `json:"network"`
  218. }
  219. // swagger:parameters updateNetworkACL getNetworkACL
  220. type aclContainerBodyParam struct {
  221. // ACL Container
  222. // in: body
  223. ACLContainer acls.ACLContainer `json:"acl_container"`
  224. }
  225. // swagger:response aclContainerResponse
  226. type aclContainerResponse struct {
  227. // ACL Container
  228. // in: body
  229. ACLContainer acls.ACLContainer `json:"acl_container"`
  230. }
  231. // swagger:response nodeSliceResponse
  232. type nodeSliceResponse struct {
  233. // Nodes
  234. // in: body
  235. Nodes []models.LegacyNode `json:"nodes"`
  236. }
  237. // swagger:response nodeResponse
  238. type nodeResponse struct {
  239. // Node
  240. // in: body
  241. Node models.LegacyNode `json:"node"`
  242. }
  243. // swagger:parameters updateNode deleteNode
  244. type nodeBodyParam struct {
  245. // Node
  246. // in: body
  247. Node models.LegacyNode `json:"node"`
  248. }
  249. //swagger:response okResponse
  250. type okRespone struct{}
  251. // swagger:response RegisterResponse
  252. type RegisterResponse struct {
  253. // in: body
  254. RegisterResponse models.RegisterResponse
  255. }
  256. // swagger:parameters createRelay
  257. type relayRequestBodyParam struct {
  258. // Relay Request
  259. // in: body
  260. RelayRequest models.RelayRequest `json:"relay_request"`
  261. }
  262. // swagger:parameters createEgressGateway
  263. type egressGatewayBodyParam struct {
  264. // Egress Gateway Request
  265. // in: body
  266. EgressGatewayRequest models.EgressGatewayRequest `json:"egress_gateway_request"`
  267. }
  268. // swagger:parameters attachUserToRemoteAccessGateway removeUserFromRemoteAccessGW getUserRemoteAccessGws
  269. type RemoteAccessGatewayUser struct {
  270. // in: path
  271. Username string `json:"username"`
  272. }
  273. // swagger:parameters authenticate
  274. type authParamBodyParam struct {
  275. // network
  276. // in: path
  277. Network string `json:"network"`
  278. // AuthParams
  279. // in: body
  280. AuthParams models.AuthParams `json:"auth_params"`
  281. }
  282. // swagger:response signal
  283. type signal struct {
  284. // in: body
  285. Signal models.Signal
  286. }
  287. // swagger:parameters synchost deleteHost updateHost signalPeer updateKeys
  288. type HostID struct {
  289. // HostID
  290. // in: path
  291. HostID string `json:"hostid"`
  292. }
  293. // swagger:parameters addHostToNetwork deleteHostFromNetwork
  294. type HostFromNetworkParams struct {
  295. // hostid to add or delete from network
  296. // in: path
  297. HostID string `json:"hostid"`
  298. // network
  299. // in: path
  300. Network string `json:"network"`
  301. }
  302. // swagger:parameters deleteEnrollmentKey
  303. type DeleteEnrollmentKeyParam struct {
  304. // in: path
  305. KeyID string `json:"keyid"`
  306. }
  307. // swagger:parameters handleHostRegister
  308. type RegisterParams struct {
  309. // in: path
  310. Token string `json:"token"`
  311. // in: body
  312. Host models.Host `json:"host"`
  313. }
  314. // swagger:response serverConfigResponse
  315. type serverConfigResponse struct {
  316. // Server Config
  317. // in: body
  318. // example
  319. //{
  320. //"mqusername": "xxxxxxx"
  321. //}
  322. ServerConfig config.ServerConfig `json:"server_config"`
  323. }
  324. // swagger:parameters createAdmin updateUser updateUserNetworks createUser
  325. type userBodyParam struct {
  326. // User
  327. // in: body
  328. User models.User `json:"user"`
  329. }
  330. // swagger:response userBodyResponse
  331. type userBodyResponse struct {
  332. // User
  333. // in: body
  334. User models.User `json:"user"`
  335. }
  336. // swagger:parameters authenticateUser
  337. type userAuthBodyParam struct {
  338. // User Auth Params
  339. // in: body
  340. UserAuthParams models.UserAuthParams `json:"user_auth_params"`
  341. }
  342. // swagger:parameters updateUser updateUserNetworks updateUserAdm createUser deleteUser getUser
  343. type usernamePathParam struct {
  344. // Username
  345. // in: path
  346. Username string `json:"username"`
  347. }
  348. // prevent issues with integration tests for types just used by Swagger docs.
  349. func useUnused() bool {
  350. _ = dnsParams{}
  351. _ = dnsResponse{}
  352. _ = dnsDeletePathParams{}
  353. _ = stringJSONResponse{}
  354. _ = getAllClientsRequest{}
  355. _ = extClientSliceResponse{}
  356. _ = extClientResponse{}
  357. _ = successResponse{}
  358. _ = extClientPathParams{}
  359. _ = extClientBodyParam{}
  360. _ = extClientNetworkPathParam{}
  361. _ = createExtClientPathParams{}
  362. _ = networkNodePathParams{}
  363. _ = byteArrayResponse{}
  364. _ = getNetworksSliceResponse{}
  365. _ = networkBodyParam{}
  366. _ = networkPathParam{}
  367. _ = networkBodyResponse{}
  368. _ = aclContainerBodyParam{}
  369. _ = aclContainerResponse{}
  370. _ = nodeSliceResponse{}
  371. _ = nodeResponse{}
  372. _ = nodeBodyParam{}
  373. _ = relayRequestBodyParam{}
  374. _ = egressGatewayBodyParam{}
  375. _ = authParamBodyParam{}
  376. _ = serverConfigResponse{}
  377. _ = userBodyParam{}
  378. _ = userBodyResponse{}
  379. _ = userAuthBodyParam{}
  380. _ = usernamePathParam{}
  381. _ = hasAdmin{}
  382. _ = apiHostResponse{}
  383. _ = fileResponse{}
  384. _ = extClientConfParams{}
  385. _ = hostPull{}
  386. _ = okRespone{}
  387. _ = signal{}
  388. _ = filenameToGet{}
  389. _ = dnsNetworkPathParam{}
  390. return false
  391. }