docs.go 9.7 KB

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