docs.go 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. <<<<<<< HEAD
  14. // Version: 0.17.0
  15. =======
  16. // Version: 0.16.3
  17. >>>>>>> 407c6ed20a427153acb4901db7e61d3016823cc4
  18. // Host: netmaker.io
  19. //
  20. // Consumes:
  21. // - application/json
  22. //
  23. // Produces:
  24. // - application/json
  25. //
  26. // Security:
  27. // - oauth
  28. //
  29. // swagger:meta
  30. package controller
  31. import (
  32. serverconfigpkg "github.com/gravitl/netmaker/config"
  33. "github.com/gravitl/netmaker/logic/acls"
  34. "github.com/gravitl/netmaker/models"
  35. "github.com/gravitl/netmaker/netclient/config"
  36. )
  37. var _ = useUnused() // "use" the function to prevent "unused function" errors
  38. // swagger:parameters getNodeDNS getCustomDNS getDNS
  39. type dnsPathParams struct {
  40. // Network
  41. // in: path
  42. Network string `json:"network"`
  43. }
  44. // swagger:parameters createDNS
  45. type dnsParams struct {
  46. // Network
  47. // in: path
  48. Network string `json:"network"`
  49. // DNS Entry
  50. // in: body
  51. Body []models.DNSEntry `json:"body"`
  52. }
  53. // Success
  54. // swagger:response dnsResponse
  55. type dnsResponse struct {
  56. // in: body
  57. Body []models.DNSEntry `json:"body"`
  58. }
  59. // swagger:parameters deleteDNS
  60. type dnsDeletePathParams struct {
  61. // Network
  62. // in: path
  63. Network string `json:"network"`
  64. // Domain
  65. // in: path
  66. Domain string `json:"domain"`
  67. }
  68. // swagger:response stringJSONResponse
  69. type stringJSONResponse struct {
  70. // Response
  71. // in: body
  72. Response string `json:"response"`
  73. }
  74. // swagger:parameters getAllExtClients
  75. type getAllClientsRequest struct {
  76. // Networks
  77. // in:body
  78. Networks []string `json:"networks"`
  79. }
  80. // swagger:response extClientSliceResponse
  81. type extClientSliceResponse struct {
  82. // ExtClients
  83. // in: body
  84. ExtClients []models.ExtClient `json:"ext_clients"`
  85. }
  86. // swagger:response extClientResponse
  87. type extClientResponse struct {
  88. // ExtClient
  89. // in: body
  90. ExtClient models.ExtClient `json:"ext_client"`
  91. }
  92. // swagger:response successResponse
  93. type successResponse struct {
  94. // Success Response
  95. // in: body
  96. SuccessResponse models.SuccessResponse `json:"success_response"`
  97. }
  98. // swagger:parameters getExtClient getExtClientConf updateExtClient deleteExtClient
  99. type extClientPathParams struct {
  100. // Client ID
  101. // in: path
  102. ClientID string `json:"clientid"`
  103. // Network
  104. // in: path
  105. Network string `json:"network"`
  106. }
  107. // swagger:parameters updateExtClient
  108. type extClientBodyParam struct {
  109. // ExtClient
  110. // in: body
  111. ExtClient models.ExtClient `json:"ext_client"`
  112. }
  113. // swagger:parameters getNetworkExtClients
  114. type extClientNetworkPathParam struct {
  115. // Network
  116. // in: path
  117. Network string `json:"network"`
  118. }
  119. // swagger:parameters createExtClient
  120. type createExtClientPathParams struct {
  121. // Network
  122. // in: path
  123. Network string `json:"network"`
  124. // Node ID
  125. // in: path
  126. NodeID string `json:"node"`
  127. // Custom ExtClient
  128. // in: body
  129. CustomExtClient models.CustomExtClient `json:"custom_ext_client"`
  130. }
  131. // swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway uncordonNode
  132. type networkNodePathParams struct {
  133. // Network
  134. // in: path
  135. Network string `json:"network"`
  136. // Node ID
  137. // in: path
  138. NodeID string `json:"nodeid"`
  139. }
  140. // swagger:response byteArrayResponse
  141. type byteArrayResponse struct {
  142. // in: body
  143. ByteArray []byte `json:"byte_array"`
  144. }
  145. // swagger:parameters getNetworks
  146. type headerNetworks struct {
  147. // name: networks
  148. // in: header
  149. Networks []string `json:"networks"`
  150. }
  151. // swagger:response getNetworksSliceResponse
  152. type getNetworksSliceResponse struct {
  153. // Networks
  154. // in: body
  155. Networks []models.Network `json:"networks"`
  156. }
  157. // swagger:parameters createNetwork updateNetwork
  158. type networkBodyParam struct {
  159. // Network
  160. // in: body
  161. Network models.Network `json:"network"`
  162. }
  163. // swagger:parameters updateNetwork getNetwork updateNetwork updateNetworkNodeLimit deleteNetwork keyUpdate createAccessKey getAccessKeys deleteAccessKey updateNetworkACL getNetworkACL
  164. type networkPathParam struct {
  165. // Network Name
  166. // in: path
  167. NetworkName string `json:"networkname"`
  168. }
  169. // swagger:parameters deleteAccessKey
  170. type networkAccessKeyNamePathParam struct {
  171. // Access Key Name
  172. // in: path
  173. AccessKeyName string `json:"access_key_name"`
  174. }
  175. // swagger:response networkBodyResponse
  176. type networkBodyResponse struct {
  177. // Network
  178. // in: body
  179. Network models.Network `json:"network"`
  180. }
  181. // swagger:parameters createAccessKey
  182. type accessKeyBodyParam struct {
  183. // Access Key
  184. // in: body
  185. AccessKey models.AccessKey `json:"access_key"`
  186. }
  187. // swagger:response accessKeyBodyResponse
  188. type accessKeyBodyResponse struct {
  189. // Access Key
  190. // in: body
  191. AccessKey models.AccessKey `json:"access_key"`
  192. }
  193. // swagger:response accessKeySliceBodyResponse
  194. type accessKeySliceBodyResponse struct {
  195. // Access Keys
  196. // in: body
  197. AccessKey []models.AccessKey `json:"access_key"`
  198. }
  199. // swagger:parameters updateNetworkACL getNetworkACL
  200. type aclContainerBodyParam struct {
  201. // ACL Container
  202. // in: body
  203. ACLContainer acls.ACLContainer `json:"acl_container"`
  204. }
  205. // swagger:response aclContainerResponse
  206. type aclContainerResponse struct {
  207. // ACL Container
  208. // in: body
  209. ACLContainer acls.ACLContainer `json:"acl_container"`
  210. }
  211. // swagger:response nodeSliceResponse
  212. type nodeSliceResponse struct {
  213. // Nodes
  214. // in: body
  215. Nodes []models.Node `json:"nodes"`
  216. }
  217. // swagger:response nodeResponse
  218. type nodeResponse struct {
  219. // Node
  220. // in: body
  221. Node models.Node `json:"node"`
  222. }
  223. // swagger:parameters updateNode deleteNode
  224. type nodeBodyParam struct {
  225. // Node
  226. // in: body
  227. Node models.Node `json:"node"`
  228. }
  229. // swagger:parameters createRelay
  230. type relayRequestBodyParam struct {
  231. // Relay Request
  232. // in: body
  233. RelayRequest models.RelayRequest `json:"relay_request"`
  234. }
  235. // swagger:parameters createEgressGateway
  236. type egressGatewayBodyParam struct {
  237. // Egress Gateway Request
  238. // in: body
  239. EgressGatewayRequest models.EgressGatewayRequest `json:"egress_gateway_request"`
  240. }
  241. // swagger:parameters authenticate
  242. type authParamBodyParam struct {
  243. // AuthParams
  244. // in: body
  245. AuthParams models.AuthParams `json:"auth_params"`
  246. }
  247. // swagger:response serverConfigResponse
  248. type serverConfigResponse struct {
  249. // Server Config
  250. // in: body
  251. ServerConfig serverconfigpkg.ServerConfig `json:"server_config"`
  252. }
  253. // swagger:response nodeGetResponse
  254. type nodeGetResponse struct {
  255. // Node Get
  256. // in: body
  257. NodeGet models.NodeGet `json:"node_get"`
  258. }
  259. // swagger:response nodeLastModifiedResponse
  260. type nodeLastModifiedResponse struct {
  261. // Node Last Modified
  262. // in: body
  263. NodesLastModified int64 `json:"nodes_last_modified"`
  264. }
  265. // swagger:parameters register
  266. type registerRequestBodyParam struct {
  267. // Register Request
  268. // in: body
  269. RegisterRequest config.RegisterRequest `json:"register_request"`
  270. }
  271. // swagger:response registerResponse
  272. type registerResponse struct {
  273. // Register Response
  274. // in: body
  275. RegisterResponse config.RegisterResponse `json:"register_response"`
  276. }
  277. // swagger:response boolResponse
  278. type boolResponse struct {
  279. // Boolean Response
  280. // in: body
  281. BoolResponse bool `json:"bool_response"`
  282. }
  283. // swagger:parameters createAdmin updateUser updateUserNetworks createUser
  284. type userBodyParam struct {
  285. // User
  286. // in: body
  287. User models.User `json:"user"`
  288. }
  289. // swagger:response userBodyResponse
  290. type userBodyResponse struct {
  291. // User
  292. // in: body
  293. User models.User `json:"user"`
  294. }
  295. // swagger:parameters authenticateUser
  296. type userAuthBodyParam struct {
  297. // User Auth Params
  298. // in: body
  299. UserAuthParams models.UserAuthParams `json:"user_auth_params"`
  300. }
  301. // swagger:parameters updateUser updateUserNetworks updateUserAdm createUser deleteUser getUser
  302. type usernamePathParam struct {
  303. // Username
  304. // in: path
  305. Username string `json:"username"`
  306. }
  307. // prevent issues with integration tests for types just used by Swagger docs.
  308. func useUnused() bool {
  309. _ = dnsPathParams{}
  310. _ = dnsParams{}
  311. _ = dnsResponse{}
  312. _ = dnsDeletePathParams{}
  313. _ = stringJSONResponse{}
  314. _ = getAllClientsRequest{}
  315. _ = extClientSliceResponse{}
  316. _ = extClientResponse{}
  317. _ = successResponse{}
  318. _ = extClientPathParams{}
  319. _ = extClientBodyParam{}
  320. _ = extClientNetworkPathParam{}
  321. _ = createExtClientPathParams{}
  322. _ = networkNodePathParams{}
  323. _ = byteArrayResponse{}
  324. _ = headerNetworks{}
  325. _ = getNetworksSliceResponse{}
  326. _ = networkBodyParam{}
  327. _ = networkPathParam{}
  328. _ = networkAccessKeyNamePathParam{}
  329. _ = networkBodyResponse{}
  330. _ = accessKeyBodyParam{}
  331. _ = accessKeyBodyResponse{}
  332. _ = accessKeySliceBodyResponse{}
  333. _ = aclContainerBodyParam{}
  334. _ = aclContainerResponse{}
  335. _ = nodeSliceResponse{}
  336. _ = nodeResponse{}
  337. _ = nodeBodyParam{}
  338. _ = relayRequestBodyParam{}
  339. _ = egressGatewayBodyParam{}
  340. _ = authParamBodyParam{}
  341. _ = serverConfigResponse{}
  342. _ = nodeGetResponse{}
  343. _ = nodeLastModifiedResponse{}
  344. _ = registerRequestBodyParam{}
  345. _ = registerResponse{}
  346. _ = boolResponse{}
  347. _ = userBodyParam{}
  348. _ = userBodyResponse{}
  349. _ = userAuthBodyParam{}
  350. _ = usernamePathParam{}
  351. return false
  352. }