docs.go 9.6 KB

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