docs.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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.23.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 apiHostSliceResponse
  47. type apiHostSliceResponse struct {
  48. // in: body
  49. Host []models.ApiHost
  50. }
  51. // swagger:response apiHostResponse
  52. type apiHostResponse struct {
  53. // in: body
  54. Host models.ApiHost
  55. }
  56. // swagger:parameters getNodeDNS getCustomDNS getDNS
  57. type dnsNetworkPathParam struct {
  58. // Network
  59. // in: path
  60. Network string `json:"network"`
  61. }
  62. // swagger:parameters createDNS
  63. type dnsParams struct {
  64. // Network
  65. // in: path
  66. Network string `json:"network"`
  67. // DNS Entry
  68. // in: body
  69. Body []models.DNSEntry `json:"body"`
  70. }
  71. // Success
  72. // swagger:response dnsResponse
  73. type dnsResponse struct {
  74. // in: body
  75. Body []models.DNSEntry `json:"body"`
  76. }
  77. // swagger:parameters deleteDNS
  78. type dnsDeletePathParams struct {
  79. // Network
  80. // in: path
  81. Network string `json:"network"`
  82. // Domain
  83. // in: path
  84. Domain string `json:"domain"`
  85. }
  86. // swagger:response stringJSONResponse
  87. type stringJSONResponse struct {
  88. // Response
  89. // in: body
  90. Response string `json:"response"`
  91. }
  92. //swagger:response EnrollmentKey
  93. type EnrollmentKey struct {
  94. // in: body
  95. EnrollmentKey models.EnrollmentKey
  96. }
  97. //swagger:response EnrollmentKeys
  98. type EnrollmentKeys struct {
  99. // in: body
  100. EnrollmentKeys []models.EnrollmentKey
  101. }
  102. // swagger:parameters getAllExtClients
  103. type getAllClientsRequest struct {
  104. // Networks
  105. // in:body
  106. Networks []string `json:"networks"`
  107. }
  108. // swagger:response extClientSliceResponse
  109. type extClientSliceResponse struct {
  110. // ExtClients
  111. // in: body
  112. ExtClients []models.ExtClient `json:"ext_clients"`
  113. }
  114. // swagger:response extClientResponse
  115. type extClientResponse struct {
  116. // ExtClient
  117. // in: body
  118. ExtClient models.ExtClient `json:"ext_client"`
  119. }
  120. // swagger:response fileResponse
  121. type fileResponse struct {
  122. // in: body
  123. File os.File
  124. }
  125. // swagger:response successResponse
  126. type successResponse struct {
  127. // Success Response
  128. // in: body
  129. SuccessResponse models.SuccessResponse `json:"success_response"`
  130. }
  131. // swagger:parameters getExtClientConf
  132. type extClientConfParams struct {
  133. // Client ID
  134. // in: path
  135. ClientID string `json:"clientid"`
  136. // Network
  137. // in: path
  138. Network string `json:"network"`
  139. // Type
  140. // in: path
  141. Type string `json:"type"`
  142. }
  143. // swagger:parameters getExtClient getExtClientConf updateExtClient deleteExtClient
  144. type extClientPathParams struct {
  145. // Client ID
  146. // in: path
  147. ClientID string `json:"clientid"`
  148. // Network
  149. // in: path
  150. Network string `json:"network"`
  151. }
  152. // swagger:parameters updateExtClient
  153. type extClientBodyParam struct {
  154. // ExtClient
  155. // in: body
  156. ExtClient models.ExtClient `json:"ext_client"`
  157. }
  158. // swagger:parameters getNetworkExtClients
  159. type extClientNetworkPathParam struct {
  160. // Network
  161. // in: path
  162. Network string `json:"network"`
  163. }
  164. // swagger:parameters createExtClient
  165. type createExtClientPathParams struct {
  166. // Network
  167. // in: path
  168. Network string `json:"network"`
  169. // Node ID
  170. // in: path
  171. NodeID string `json:"nodeid"`
  172. // Custom ExtClient
  173. // in: body
  174. CustomExtClient models.CustomExtClient `json:"custom_ext_client"`
  175. }
  176. // swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway ingressGatewayUsers
  177. type networkNodePathParams struct {
  178. // in: path
  179. Network string `json:"network"`
  180. // in: path
  181. NodeID string `json:"nodeid"`
  182. }
  183. // swagger:response byteArrayResponse
  184. type byteArrayResponse struct {
  185. // in: body
  186. ByteArray []byte `json:"byte_array"`
  187. }
  188. // swagger:parameters getNetwork deleteNetwork updateNetwork getNetworkACL updateNetworkACL
  189. type NetworkParam struct {
  190. // name: network name
  191. // in: path
  192. Networkname string `json:"networkname"`
  193. }
  194. // swagger:response getNetworksSliceResponse
  195. type getNetworksSliceResponse struct {
  196. // Networks
  197. // in: body
  198. Networks []models.Network `json:"networks"`
  199. }
  200. // swagger:response hostPull
  201. type hostPull struct {
  202. // hostPull
  203. // in: body
  204. HostPull models.HostPull
  205. }
  206. // swagger:parameters createNetwork updateNetwork
  207. type networkBodyParam struct {
  208. // Network
  209. // in: body
  210. Network models.Network `json:"network"`
  211. }
  212. // swagger:parameters updateNetworkNodeLimit keyUpdate createAccessKey getAccessKeys getNetworkNodes
  213. type networkPathParam struct {
  214. // Network
  215. // in: path
  216. Network string `json:"network"`
  217. }
  218. // swagger:response networkBodyResponse
  219. type networkBodyResponse struct {
  220. // Network
  221. // in: body
  222. Network models.Network `json:"network"`
  223. }
  224. // swagger:parameters updateNetworkACL
  225. type aclContainerBodyParam struct {
  226. // ACL Container
  227. // in: body
  228. ACLContainer acls.ACLContainer `json:"acl_container"`
  229. }
  230. // swagger:response aclContainerResponse
  231. type aclContainerResponse struct {
  232. // ACL Container
  233. // in: body
  234. ACLContainer acls.ACLContainer `json:"acl_container"`
  235. }
  236. // swagger:response nodeSliceResponse
  237. type nodeSliceResponse struct {
  238. // Nodes
  239. // in: body
  240. Nodes []models.ApiNode `json:"nodes"`
  241. }
  242. // swagger:response nodeResponse
  243. type nodeResponse struct {
  244. // Node
  245. // in: body
  246. Node models.LegacyNode `json:"node"`
  247. }
  248. // swagger:parameters updateNode deleteNode
  249. type nodeBodyParam struct {
  250. // Node
  251. // in: body
  252. Node models.LegacyNode `json:"node"`
  253. }
  254. //swagger:response okResponse
  255. type okRespone struct{}
  256. // swagger:response RegisterResponse
  257. type RegisterResponse struct {
  258. // in: body
  259. RegisterResponse models.RegisterResponse
  260. }
  261. // swagger:parameters createRelay
  262. type relayRequestBodyParam struct {
  263. // Relay Request
  264. // in: body
  265. RelayRequest models.RelayRequest `json:"relay_request"`
  266. }
  267. // swagger:parameters createEgressGateway
  268. type egressGatewayBodyParam struct {
  269. // Egress Gateway Request
  270. // in: body
  271. EgressGatewayRequest models.EgressGatewayRequest `json:"egress_gateway_request"`
  272. }
  273. // swagger:parameters attachUserToRemoteAccessGateway removeUserFromRemoteAccessGW getUserRemoteAccessGws
  274. type RemoteAccessGatewayUser struct {
  275. // in: path
  276. Username string `json:"username"`
  277. }
  278. // swagger:parameters authenticate
  279. type authParamBodyParam struct {
  280. // network
  281. // in: path
  282. Network string `json:"network"`
  283. // AuthParams
  284. // in: body
  285. AuthParams models.AuthParams `json:"auth_params"`
  286. }
  287. // swagger:response signal
  288. type signal struct {
  289. // in: body
  290. Signal models.Signal
  291. }
  292. // swagger:parameters synchost deleteHost updateHost signalPeer updateKeys
  293. type HostID struct {
  294. // HostID
  295. // in: path
  296. HostID string `json:"hostid"`
  297. }
  298. // swagger:parameters addHostToNetwork deleteHostFromNetwork
  299. type HostFromNetworkParams struct {
  300. // hostid to add or delete from network
  301. // in: path
  302. HostID string `json:"hostid"`
  303. // network
  304. // in: path
  305. Network string `json:"network"`
  306. }
  307. // swagger:parameters createEnrollmentKey
  308. type createEnrollmentKeyParams struct {
  309. // APIEnrollmentKey
  310. // in: body
  311. Body models.APIEnrollmentKey `json:"body"`
  312. }
  313. // swagger:parameters updateEnrollmentKey
  314. type updateEnrollmentKeyParams struct {
  315. // KeyID
  316. // in: path
  317. KeyID string `json:"keyid"`
  318. // APIEnrollmentKey
  319. // in: body
  320. Body models.APIEnrollmentKey `json:"body"`
  321. }
  322. // swagger:parameters deleteEnrollmentKey
  323. type deleteEnrollmentKeyParam struct {
  324. // in: path
  325. KeyID string `json:"keyid"`
  326. }
  327. // swagger:parameters handleHostRegister
  328. type RegisterParams struct {
  329. // in: path
  330. Token string `json:"token"`
  331. // in: body
  332. Host models.Host `json:"host"`
  333. }
  334. // swagger:response serverConfigResponse
  335. type serverConfigResponse struct {
  336. // Server Config
  337. // in: body
  338. // example
  339. //{
  340. //"mqusername": "xxxxxxx"
  341. //}
  342. ServerConfig config.ServerConfig `json:"server_config"`
  343. }
  344. // swagger:parameters createAdmin updateUser updateUserNetworks createUser
  345. type userBodyParam struct {
  346. // User
  347. // in: body
  348. User models.User `json:"user"`
  349. }
  350. // swagger:response userBodyResponse
  351. type userBodyResponse struct {
  352. // User
  353. // in: body
  354. User models.User `json:"user"`
  355. }
  356. // swagger:parameters authenticateUser
  357. type userAuthBodyParam struct {
  358. // User Auth Params
  359. // in: body
  360. UserAuthParams models.UserAuthParams `json:"user_auth_params"`
  361. }
  362. // swagger:parameters updateUser updateUserNetworks updateUserAdm createUser deleteUser getUser
  363. type usernamePathParam struct {
  364. // Username
  365. // in: path
  366. Username string `json:"username"`
  367. }
  368. // prevent issues with integration tests for types just used by Swagger docs.
  369. func useUnused() bool {
  370. _ = dnsParams{}
  371. _ = dnsResponse{}
  372. _ = dnsDeletePathParams{}
  373. _ = stringJSONResponse{}
  374. _ = getAllClientsRequest{}
  375. _ = extClientSliceResponse{}
  376. _ = extClientResponse{}
  377. _ = successResponse{}
  378. _ = extClientPathParams{}
  379. _ = extClientBodyParam{}
  380. _ = extClientNetworkPathParam{}
  381. _ = createExtClientPathParams{}
  382. _ = networkNodePathParams{}
  383. _ = byteArrayResponse{}
  384. _ = getNetworksSliceResponse{}
  385. _ = networkBodyParam{}
  386. _ = networkPathParam{}
  387. _ = networkBodyResponse{}
  388. _ = aclContainerBodyParam{}
  389. _ = aclContainerResponse{}
  390. _ = nodeSliceResponse{}
  391. _ = nodeResponse{}
  392. _ = nodeBodyParam{}
  393. _ = relayRequestBodyParam{}
  394. _ = egressGatewayBodyParam{}
  395. _ = authParamBodyParam{}
  396. _ = serverConfigResponse{}
  397. _ = userBodyParam{}
  398. _ = userBodyResponse{}
  399. _ = userAuthBodyParam{}
  400. _ = usernamePathParam{}
  401. _ = hasAdmin{}
  402. _ = apiHostSliceResponse{}
  403. _ = apiHostResponse{}
  404. _ = fileResponse{}
  405. _ = extClientConfParams{}
  406. _ = hostPull{}
  407. _ = okRespone{}
  408. _ = signal{}
  409. _ = filenameToGet{}
  410. _ = dnsNetworkPathParam{}
  411. _ = createEnrollmentKeyParams{}
  412. _ = updateEnrollmentKeyParams{}
  413. _ = deleteEnrollmentKeyParam{}
  414. return false
  415. }