knife-ionoscloud 5.1.1 → 6.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (326) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.md +1 -1
  3. data/docs/subcommands/composite_server_create.md +9 -3
  4. data/docs/subcommands/cube_server_create.md +91 -0
  5. data/docs/subcommands/firewall_create.md +5 -2
  6. data/docs/subcommands/flowlog_create.md +63 -0
  7. data/docs/subcommands/flowlog_delete.md +51 -0
  8. data/docs/subcommands/flowlog_list.md +51 -0
  9. data/docs/subcommands/group_create.md +10 -1
  10. data/docs/subcommands/natgateway_create.md +41 -0
  11. data/docs/subcommands/natgateway_delete.md +35 -0
  12. data/docs/subcommands/natgateway_lan_add.md +46 -0
  13. data/docs/subcommands/natgateway_lan_remove.md +39 -0
  14. data/docs/subcommands/natgateway_list.md +35 -0
  15. data/docs/subcommands/natgateway_rule_add.md +66 -0
  16. data/docs/subcommands/natgateway_rule_list.md +38 -0
  17. data/docs/subcommands/natgateway_rule_remove.md +39 -0
  18. data/docs/subcommands/networkloadbalancer_create.md +54 -0
  19. data/docs/subcommands/networkloadbalancer_delete.md +35 -0
  20. data/docs/subcommands/networkloadbalancer_list.md +35 -0
  21. data/docs/subcommands/networkloadbalancer_rule_add.md +72 -0
  22. data/docs/subcommands/networkloadbalancer_rule_list.md +39 -0
  23. data/docs/subcommands/networkloadbalancer_rule_remove.md +39 -0
  24. data/docs/subcommands/networkloadbalancer_rule_target_add.md +64 -0
  25. data/docs/subcommands/networkloadbalancer_rule_target_list.md +43 -0
  26. data/docs/subcommands/networkloadbalancer_rule_target_remove.md +51 -0
  27. data/docs/subcommands/nic_create.md +3 -3
  28. data/docs/subcommands/nodepool_lan_add.md +49 -0
  29. data/docs/subcommands/nodepool_lan_remove.md +39 -0
  30. data/docs/subcommands/server_console.md +39 -0
  31. data/docs/subcommands/server_list.md +4 -1
  32. data/docs/subcommands/server_resume.md +35 -0
  33. data/docs/subcommands/server_suspend.md +35 -0
  34. data/docs/subcommands/server_token.md +39 -0
  35. data/docs/subcommands/server_upgrade.md +39 -0
  36. data/docs/subcommands/template_list.md +31 -0
  37. data/docs/subcommands/volume_create.md +2 -5
  38. data/docs/summary.md +29 -0
  39. data/knife-ionoscloud.gemspec +1 -1
  40. data/lib/chef/knife/ionoscloud_backupunit_create.rb +12 -16
  41. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +2 -5
  42. data/lib/chef/knife/ionoscloud_backupunit_get.rb +33 -0
  43. data/lib/chef/knife/ionoscloud_backupunit_list.rb +1 -1
  44. data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +1 -1
  45. data/lib/chef/knife/ionoscloud_backupunit_update.rb +62 -0
  46. data/lib/chef/knife/ionoscloud_base.rb +309 -1
  47. data/lib/chef/knife/ionoscloud_composite_server_create.rb +23 -5
  48. data/lib/chef/knife/ionoscloud_contract_list.rb +32 -23
  49. data/lib/chef/knife/ionoscloud_cube_server_create.rb +212 -0
  50. data/lib/chef/knife/ionoscloud_datacenter_create.rb +11 -14
  51. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +2 -7
  52. data/lib/chef/knife/ionoscloud_datacenter_get.rb +33 -0
  53. data/lib/chef/knife/ionoscloud_datacenter_list.rb +4 -2
  54. data/lib/chef/knife/ionoscloud_datacenter_update.rb +67 -0
  55. data/lib/chef/knife/ionoscloud_firewall_create.rb +16 -21
  56. data/lib/chef/knife/ionoscloud_firewall_delete.rb +5 -13
  57. data/lib/chef/knife/ionoscloud_firewall_get.rb +52 -0
  58. data/lib/chef/knife/ionoscloud_firewall_list.rb +5 -3
  59. data/lib/chef/knife/ionoscloud_firewall_update.rb +133 -0
  60. data/lib/chef/knife/ionoscloud_flowlog_create.rb +116 -0
  61. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +103 -0
  62. data/lib/chef/knife/ionoscloud_flowlog_get.rb +84 -0
  63. data/lib/chef/knife/ionoscloud_flowlog_list.rb +101 -0
  64. data/lib/chef/knife/ionoscloud_flowlog_update.rb +127 -0
  65. data/lib/chef/knife/ionoscloud_group_create.rb +33 -27
  66. data/lib/chef/knife/ionoscloud_group_delete.rb +1 -11
  67. data/lib/chef/knife/ionoscloud_group_get.rb +1 -13
  68. data/lib/chef/knife/ionoscloud_group_list.rb +19 -7
  69. data/lib/chef/knife/ionoscloud_group_update.rb +131 -0
  70. data/lib/chef/knife/ionoscloud_group_user_add.rb +1 -18
  71. data/lib/chef/knife/ionoscloud_group_user_remove.rb +1 -18
  72. data/lib/chef/knife/ionoscloud_image_list.rb +1 -1
  73. data/lib/chef/knife/ionoscloud_ipblock_create.rb +10 -13
  74. data/lib/chef/knife/ionoscloud_ipblock_delete.rb +1 -4
  75. data/lib/chef/knife/ionoscloud_ipblock_get.rb +33 -0
  76. data/lib/chef/knife/ionoscloud_ipblock_update.rb +57 -0
  77. data/lib/chef/knife/ionoscloud_ipfailover_add.rb +1 -1
  78. data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -1
  79. data/lib/chef/knife/ionoscloud_k8s_create.rb +27 -35
  80. data/lib/chef/knife/ionoscloud_k8s_delete.rb +1 -9
  81. data/lib/chef/knife/ionoscloud_k8s_get.rb +33 -0
  82. data/lib/chef/knife/ionoscloud_k8s_update.rb +99 -0
  83. data/lib/chef/knife/ionoscloud_label_add.rb +1 -1
  84. data/lib/chef/knife/ionoscloud_label_list.rb +1 -1
  85. data/lib/chef/knife/ionoscloud_label_remove.rb +1 -1
  86. data/lib/chef/knife/ionoscloud_lan_create.rb +6 -14
  87. data/lib/chef/knife/ionoscloud_lan_delete.rb +3 -4
  88. data/lib/chef/knife/ionoscloud_lan_get.rb +38 -0
  89. data/lib/chef/knife/ionoscloud_lan_list.rb +2 -1
  90. data/lib/chef/knife/ionoscloud_lan_update.rb +76 -0
  91. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +4 -14
  92. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +2 -9
  93. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +3 -13
  94. data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +1 -1
  95. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +3 -15
  96. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +3 -16
  97. data/lib/chef/knife/ionoscloud_loadbalancer_update.rb +73 -0
  98. data/lib/chef/knife/ionoscloud_location_list.rb +5 -3
  99. data/lib/chef/knife/ionoscloud_natgateway_create.rb +60 -0
  100. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +54 -0
  101. data/lib/chef/knife/ionoscloud_natgateway_get.rb +42 -0
  102. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +74 -0
  103. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +52 -0
  104. data/lib/chef/knife/ionoscloud_natgateway_list.rb +51 -0
  105. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +107 -0
  106. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +65 -0
  107. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +55 -0
  108. data/lib/chef/knife/ionoscloud_natgateway_rule_update.rb +116 -0
  109. data/lib/chef/knife/ionoscloud_natgateway_update.rb +84 -0
  110. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +89 -0
  111. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +62 -0
  112. data/lib/chef/knife/ionoscloud_networkloadbalancer_get.rb +42 -0
  113. data/lib/chef/knife/ionoscloud_networkloadbalancer_list.rb +57 -0
  114. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +141 -0
  115. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +65 -0
  116. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +68 -0
  117. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +124 -0
  118. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +70 -0
  119. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +88 -0
  120. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_update.rb +148 -0
  121. data/lib/chef/knife/ionoscloud_networkloadbalancer_update.rb +98 -0
  122. data/lib/chef/knife/ionoscloud_nic_create.rb +17 -22
  123. data/lib/chef/knife/ionoscloud_nic_delete.rb +3 -7
  124. data/lib/chef/knife/ionoscloud_nic_get.rb +49 -0
  125. data/lib/chef/knife/ionoscloud_nic_list.rb +9 -5
  126. data/lib/chef/knife/ionoscloud_nic_update.rb +96 -0
  127. data/lib/chef/knife/ionoscloud_node_get.rb +49 -0
  128. data/lib/chef/knife/ionoscloud_node_list.rb +0 -1
  129. data/lib/chef/knife/ionoscloud_nodepool_create.rb +35 -48
  130. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +1 -7
  131. data/lib/chef/knife/ionoscloud_nodepool_get.rb +43 -0
  132. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +104 -0
  133. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +72 -0
  134. data/lib/chef/knife/ionoscloud_nodepool_list.rb +3 -1
  135. data/lib/chef/knife/ionoscloud_nodepool_update.rb +124 -0
  136. data/lib/chef/knife/ionoscloud_pcc_create.rb +12 -18
  137. data/lib/chef/knife/ionoscloud_pcc_delete.rb +2 -10
  138. data/lib/chef/knife/ionoscloud_pcc_get.rb +33 -0
  139. data/lib/chef/knife/ionoscloud_pcc_list.rb +1 -1
  140. data/lib/chef/knife/ionoscloud_pcc_update.rb +63 -0
  141. data/lib/chef/knife/ionoscloud_request_get.rb +40 -0
  142. data/lib/chef/knife/ionoscloud_request_list.rb +1 -1
  143. data/lib/chef/knife/ionoscloud_request_status.rb +1 -1
  144. data/lib/chef/knife/ionoscloud_s3key_create.rb +3 -7
  145. data/lib/chef/knife/ionoscloud_s3key_delete.rb +4 -7
  146. data/lib/chef/knife/ionoscloud_s3key_get.rb +38 -0
  147. data/lib/chef/knife/ionoscloud_s3key_list.rb +2 -2
  148. data/lib/chef/knife/ionoscloud_server_console.rb +43 -0
  149. data/lib/chef/knife/ionoscloud_server_create.rb +14 -26
  150. data/lib/chef/knife/ionoscloud_server_delete.rb +3 -9
  151. data/lib/chef/knife/ionoscloud_server_get.rb +43 -0
  152. data/lib/chef/knife/ionoscloud_server_list.rb +16 -5
  153. data/lib/chef/knife/ionoscloud_server_reboot.rb +1 -1
  154. data/lib/chef/knife/ionoscloud_server_resume.rb +44 -0
  155. data/lib/chef/knife/ionoscloud_server_start.rb +1 -1
  156. data/lib/chef/knife/ionoscloud_server_stop.rb +1 -1
  157. data/lib/chef/knife/ionoscloud_server_suspend.rb +45 -0
  158. data/lib/chef/knife/ionoscloud_server_token.rb +43 -0
  159. data/lib/chef/knife/ionoscloud_server_update.rb +97 -0
  160. data/lib/chef/knife/ionoscloud_server_upgrade.rb +45 -0
  161. data/lib/chef/knife/ionoscloud_share_create.rb +7 -11
  162. data/lib/chef/knife/ionoscloud_share_delete.rb +2 -3
  163. data/lib/chef/knife/ionoscloud_share_get.rb +38 -0
  164. data/lib/chef/knife/ionoscloud_share_update.rb +70 -0
  165. data/lib/chef/knife/ionoscloud_snapshot_create.rb +2 -10
  166. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +2 -7
  167. data/lib/chef/knife/ionoscloud_snapshot_get.rb +32 -0
  168. data/lib/chef/knife/ionoscloud_snapshot_list.rb +1 -1
  169. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +3 -14
  170. data/lib/chef/knife/ionoscloud_snapshot_update.rb +126 -0
  171. data/lib/chef/knife/ionoscloud_template_list.rb +47 -0
  172. data/lib/chef/knife/ionoscloud_user_create.rb +1 -8
  173. data/lib/chef/knife/ionoscloud_user_delete.rb +1 -6
  174. data/lib/chef/knife/ionoscloud_user_get.rb +32 -0
  175. data/lib/chef/knife/ionoscloud_user_ssourl.rb +1 -1
  176. data/lib/chef/knife/ionoscloud_user_update.rb +92 -0
  177. data/lib/chef/knife/ionoscloud_volume_attach.rb +1 -1
  178. data/lib/chef/knife/ionoscloud_volume_create.rb +18 -34
  179. data/lib/chef/knife/ionoscloud_volume_delete.rb +3 -9
  180. data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -1
  181. data/lib/chef/knife/ionoscloud_volume_get.rb +36 -0
  182. data/lib/chef/knife/ionoscloud_volume_list.rb +2 -2
  183. data/lib/chef/knife/ionoscloud_volume_update.rb +106 -0
  184. data/lib/knife-ionoscloud/version.rb +1 -1
  185. data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +2 -2
  186. data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +5 -5
  187. data/spec/chef/knife/ionoscloud_backupunit_get_spec.rb +65 -0
  188. data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +1 -1
  189. data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +3 -3
  190. data/spec/chef/knife/ionoscloud_backupunit_update_spec.rb +78 -0
  191. data/spec/chef/knife/ionoscloud_base_spec.rb +4 -4
  192. data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +11 -8
  193. data/spec/chef/knife/ionoscloud_contract_list_spec.rb +32 -27
  194. data/spec/chef/knife/ionoscloud_cube_server_create_spec.rb +249 -0
  195. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +6 -2
  196. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +8 -5
  197. data/spec/chef/knife/ionoscloud_datacenter_get_spec.rb +69 -0
  198. data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +5 -3
  199. data/spec/chef/knife/ionoscloud_datacenter_update_spec.rb +82 -0
  200. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +5 -3
  201. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +6 -5
  202. data/spec/chef/knife/ionoscloud_firewall_get_spec.rb +77 -0
  203. data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +5 -3
  204. data/spec/chef/knife/ionoscloud_firewall_update_spec.rb +117 -0
  205. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +254 -0
  206. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +360 -0
  207. data/spec/chef/knife/ionoscloud_flowlog_get_spec.rb +171 -0
  208. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +264 -0
  209. data/spec/chef/knife/ionoscloud_flowlog_update_spec.rb +244 -0
  210. data/spec/chef/knife/ionoscloud_group_create_spec.rb +9 -0
  211. data/spec/chef/knife/ionoscloud_group_delete_spec.rb +6 -0
  212. data/spec/chef/knife/ionoscloud_group_get_spec.rb +6 -0
  213. data/spec/chef/knife/ionoscloud_group_list_spec.rb +26 -8
  214. data/spec/chef/knife/ionoscloud_group_update_spec.rb +121 -0
  215. data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +6 -0
  216. data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +6 -0
  217. data/spec/chef/knife/ionoscloud_image_list_spec.rb +2 -2
  218. data/spec/chef/knife/ionoscloud_ipblock_get_spec.rb +66 -0
  219. data/spec/chef/knife/ionoscloud_ipblock_update_spec.rb +79 -0
  220. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +4 -4
  221. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +7 -7
  222. data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +7 -0
  223. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +16 -11
  224. data/spec/chef/knife/ionoscloud_k8s_get_spec.rb +72 -0
  225. data/spec/chef/knife/ionoscloud_k8s_update_spec.rb +114 -0
  226. data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +2 -2
  227. data/spec/chef/knife/ionoscloud_label_add_spec.rb +10 -10
  228. data/spec/chef/knife/ionoscloud_label_list_spec.rb +14 -14
  229. data/spec/chef/knife/ionoscloud_label_remove_spec.rb +20 -20
  230. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +4 -3
  231. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +7 -5
  232. data/spec/chef/knife/ionoscloud_lan_get_spec.rb +68 -0
  233. data/spec/chef/knife/ionoscloud_lan_list_spec.rb +2 -2
  234. data/spec/chef/knife/ionoscloud_lan_update_spec.rb +87 -0
  235. data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +3 -3
  236. data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +5 -5
  237. data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +2 -2
  238. data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +2 -2
  239. data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +6 -6
  240. data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +6 -6
  241. data/spec/chef/knife/ionoscloud_loadbalancer_update_spec.rb +89 -0
  242. data/spec/chef/knife/ionoscloud_location_list_spec.rb +5 -3
  243. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +92 -0
  244. data/spec/chef/knife/ionoscloud_natgateway_delete_spec.rb +118 -0
  245. data/spec/chef/knife/ionoscloud_natgateway_get_spec.rb +81 -0
  246. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +158 -0
  247. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +209 -0
  248. data/spec/chef/knife/ionoscloud_natgateway_list_spec.rb +79 -0
  249. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +99 -0
  250. data/spec/chef/knife/ionoscloud_natgateway_rule_list_spec.rb +92 -0
  251. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +78 -0
  252. data/spec/chef/knife/ionoscloud_natgateway_rule_update_spec.rb +121 -0
  253. data/spec/chef/knife/ionoscloud_natgateway_update_spec.rb +121 -0
  254. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +93 -0
  255. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +120 -0
  256. data/spec/chef/knife/ionoscloud_networkloadbalancer_get_spec.rb +82 -0
  257. data/spec/chef/knife/ionoscloud_networkloadbalancer_list_spec.rb +88 -0
  258. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +105 -0
  259. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_list_spec.rb +89 -0
  260. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +150 -0
  261. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +113 -0
  262. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_list_spec.rb +85 -0
  263. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +281 -0
  264. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_update_spec.rb +163 -0
  265. data/spec/chef/knife/ionoscloud_networkloadbalancer_update_spec.rb +107 -0
  266. data/spec/chef/knife/ionoscloud_nic_create_spec.rb +9 -5
  267. data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +8 -6
  268. data/spec/chef/knife/ionoscloud_nic_get_spec.rb +72 -0
  269. data/spec/chef/knife/ionoscloud_nic_list_spec.rb +12 -6
  270. data/spec/chef/knife/ionoscloud_nic_update_spec.rb +97 -0
  271. data/spec/chef/knife/ionoscloud_node_get_spec.rb +70 -0
  272. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +10 -5
  273. data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +14 -0
  274. data/spec/chef/knife/ionoscloud_nodepool_get_spec.rb +83 -0
  275. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +222 -0
  276. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +196 -0
  277. data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +3 -1
  278. data/spec/chef/knife/ionoscloud_nodepool_update_spec.rb +134 -0
  279. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +11 -8
  280. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +7 -7
  281. data/spec/chef/knife/ionoscloud_pcc_get_spec.rb +71 -0
  282. data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +2 -2
  283. data/spec/chef/knife/ionoscloud_pcc_update_spec.rb +83 -0
  284. data/spec/chef/knife/ionoscloud_request_get_spec.rb +69 -0
  285. data/spec/chef/knife/ionoscloud_request_list_spec.rb +16 -16
  286. data/spec/chef/knife/ionoscloud_request_status_spec.rb +3 -3
  287. data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +2 -2
  288. data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +5 -5
  289. data/spec/chef/knife/ionoscloud_s3key_get_spec.rb +66 -0
  290. data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +2 -2
  291. data/spec/chef/knife/ionoscloud_server_console_spec.rb +97 -0
  292. data/spec/chef/knife/ionoscloud_server_create_spec.rb +6 -3
  293. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +8 -5
  294. data/spec/chef/knife/ionoscloud_server_get_spec.rb +74 -0
  295. data/spec/chef/knife/ionoscloud_server_list_spec.rb +63 -5
  296. data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +3 -5
  297. data/spec/chef/knife/ionoscloud_server_resume_spec.rb +93 -0
  298. data/spec/chef/knife/ionoscloud_server_start_spec.rb +3 -5
  299. data/spec/chef/knife/ionoscloud_server_stop_spec.rb +3 -5
  300. data/spec/chef/knife/ionoscloud_server_suspend_spec.rb +93 -0
  301. data/spec/chef/knife/ionoscloud_server_token_spec.rb +97 -0
  302. data/spec/chef/knife/ionoscloud_server_update_spec.rb +105 -0
  303. data/spec/chef/knife/ionoscloud_server_upgrade_spec.rb +96 -0
  304. data/spec/chef/knife/ionoscloud_share_get_spec.rb +66 -0
  305. data/spec/chef/knife/ionoscloud_share_update_spec.rb +91 -0
  306. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +15 -3
  307. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +17 -5
  308. data/spec/chef/knife/ionoscloud_snapshot_get_spec.rb +79 -0
  309. data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +2 -2
  310. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +12 -3
  311. data/spec/chef/knife/ionoscloud_snapshot_update_spec.rb +113 -0
  312. data/spec/chef/knife/ionoscloud_template_list_spec.rb +78 -0
  313. data/spec/chef/knife/ionoscloud_user_create_spec.rb +3 -1
  314. data/spec/chef/knife/ionoscloud_user_delete_spec.rb +4 -2
  315. data/spec/chef/knife/ionoscloud_user_get_spec.rb +70 -0
  316. data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +3 -3
  317. data/spec/chef/knife/ionoscloud_user_update_spec.rb +110 -0
  318. data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +4 -4
  319. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +21 -11
  320. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +15 -5
  321. data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +5 -5
  322. data/spec/chef/knife/ionoscloud_volume_get_spec.rb +81 -0
  323. data/spec/chef/knife/ionoscloud_volume_list_spec.rb +4 -4
  324. data/spec/chef/knife/ionoscloud_volume_update_spec.rb +116 -0
  325. data/spec/spec_helper.rb +251 -39
  326. metadata +245 -6
@@ -0,0 +1,133 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFirewallUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud firewall update (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ option :server_id,
16
+ short: '-S SERVER_ID',
17
+ long: '--server-id SERVER_ID',
18
+ description: 'The ID of the server'
19
+
20
+ option :nic_id,
21
+ short: '-N NIC_ID',
22
+ long: '--nic-id NIC_ID',
23
+ description: 'ID of the NIC'
24
+
25
+ option :firewall_id,
26
+ short: '-F FIREWALL_ID',
27
+ long: '--firewall-id FIREWALL_ID',
28
+ description: 'ID of the Firewall Rule'
29
+
30
+ option :name,
31
+ short: '-n NAME',
32
+ long: '--name NAME',
33
+ description: 'Name of the Firewall Rule'
34
+
35
+ option :protocol,
36
+ short: '-P PROTOCOL',
37
+ long: '--protocol PROTOCOL',
38
+ default: 'TCP',
39
+ description: 'The protocol of the firewall rule (TCP, UDP, ICMP, ANY)'
40
+
41
+ option :source_mac,
42
+ short: '-m MAC',
43
+ long: '--source-mac MAC',
44
+ description: 'Only traffic originating from the respective MAC address is allowed'
45
+
46
+ option :source_ip,
47
+ short: '-I IP',
48
+ long: '--source-ip IP',
49
+ description: 'Only traffic originating from the respective IPv4' \
50
+ ' address is allowed; null allows all source IPs'
51
+
52
+ option :target_ip,
53
+ long: '--target-ip IP',
54
+ description: 'In case the target NIC has multiple IP addresses,' \
55
+ ' only traffic directed to the respective IP' \
56
+ ' address of the NIC is allowed; null value allows' \
57
+ ' all target IPs'
58
+
59
+ option :port_range_start,
60
+ short: '-p PORT',
61
+ long: '--port-range-start PORT',
62
+ description: 'Defines the start range of the allowed port(s)'
63
+
64
+ option :port_range_end,
65
+ short: '-t PORT',
66
+ long: '--port-range-end PORT',
67
+ description: 'Defines the end range of the allowed port(s)'
68
+
69
+ option :icmp_type,
70
+ long: '--icmp-type INT',
71
+ description: 'Defines the allowed type (from 0 to 254) if the' \
72
+ ' protocol ICMP is chosen; null allows all types'
73
+
74
+ option :icmp_code,
75
+ long: '--icmp-code INT',
76
+ description: 'Defines the allowed code (from 0 to 254) if the' \
77
+ ' protocol ICMP is chosen; null allows all codes'
78
+
79
+ attr_reader :description, :required_options
80
+
81
+ def initialize(args = [])
82
+ super(args)
83
+ @description =
84
+ 'Updates information about a Ionoscloud Firewall Rule.'
85
+ @required_options = [:datacenter_id, :ionoscloud_username, :ionoscloud_password]
86
+ @updatable_fields = [
87
+ :name, :protocol, :source_mac, :source_ip, :target_ip,
88
+ :port_range_start, :port_range_end, :icmp_type, :icmp_code,
89
+ ]
90
+ end
91
+
92
+ def run
93
+ $stdout.sync = true
94
+ handle_extra_config
95
+ validate_required_params(@required_options, config)
96
+
97
+ firewall_rules_api = Ionoscloud::FirewallRulesApi.new(api_client)
98
+
99
+ if @updatable_fields.map { |el| config[el] }.any?
100
+ print "#{ui.color('Updating Firewall Rule...', :magenta)}"
101
+
102
+ params = {
103
+ name: config[:name],
104
+ protocol: config[:protocol],
105
+ source_mac: config[:source_mac],
106
+ source_ip: config[:source_ip],
107
+ target_ip: config[:target_ip],
108
+ port_range_start: config[:port_range_start],
109
+ port_range_end: config[:port_range_end],
110
+ icmp_type: config[:icmp_type],
111
+ icmp_code: config[:icmp_code],
112
+ }
113
+
114
+ _, _, headers = firewall_rules_api.datacenters_servers_nics_firewallrules_patch_with_http_info(
115
+ config[:datacenter_id], config[:server_id], config[:nic_id], config[:firewall_id],
116
+ Ionoscloud::FirewallruleProperties.new(params.compact),
117
+ )
118
+
119
+ dot = ui.color('.', :magenta)
120
+ api_client.wait_for { print dot; is_done? get_request_id headers }
121
+ else
122
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
123
+ end
124
+
125
+ print_firewall_rule(
126
+ firewall_rules_api.datacenters_servers_nics_firewallrules_find_by_id(
127
+ config[:datacenter_id], config[:server_id], config[:nic_id], config[:firewall_id],
128
+ ),
129
+ )
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,116 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFlowlogCreate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud flowlog create (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'ID of the data center'
14
+
15
+ option :type,
16
+ short: '-t FLOWLOG_TYPE',
17
+ long: '--type FLOWLOG_TYPE',
18
+ description: 'The object to which the flow log will be attached'
19
+
20
+ option :server_id,
21
+ short: '-S SERVER_ID',
22
+ long: '--server-id SERVER_ID',
23
+ description: 'ID of the server'
24
+
25
+ option :nic_id,
26
+ short: '-N NIC_ID',
27
+ long: '--nic-id NIC_ID',
28
+ description: 'ID of the NIC'
29
+
30
+ option :natgateway_id,
31
+ short: '-G NAT_GATEWAY_ID',
32
+ long: '--natgateway NAT_GATEWAY_ID',
33
+ description: 'ID of the NAT Gateway'
34
+
35
+ option :network_loadbalancer_id,
36
+ short: '-L NETWORK_LOADBALANCER',
37
+ long: '--network-loadbalancer NETWORK_LOADBALANCER',
38
+ description: 'ID of the Network Load Balancer'
39
+
40
+ option :name,
41
+ short: '-n NAME',
42
+ long: '--name NAME',
43
+ description: 'Name of the Flow Log'
44
+
45
+ option :action,
46
+ short: '-a ACTION',
47
+ long: '--action ACTION',
48
+ default: 'ALL',
49
+ description: 'Specifies the traffic action pattern. Must be one of ["ALL", "ACCEPTED", "REJECTED"].'
50
+
51
+ option :direction,
52
+ long: '--direction DIRECTION',
53
+ default: 'BIDIRECTIONAL',
54
+ description: 'Specifies the traffic direction pattern. Must be one of ["INGRESS", "EGRESS", "BIDIRECTIONAL"].'
55
+
56
+ option :bucket,
57
+ short: '-b BUCKET',
58
+ long: '--bucket BUCKET',
59
+ description: 'S3 bucket name of an existing IONOS Cloud S3 bucket. Ex. bucketName/key'
60
+
61
+ attr_reader :description, :required_options
62
+
63
+ def initialize(args = [])
64
+ super(args)
65
+ @description =
66
+ 'This will add a Flow Log to the network interface, NAT Gateway or Network Load Balancer.'
67
+ @required_options = [:datacenter_id, :type, :ionoscloud_username, :ionoscloud_password]
68
+ end
69
+
70
+ def run
71
+ $stdout.sync = true
72
+ handle_extra_config
73
+ validate_required_params(@required_options, config)
74
+
75
+ print "#{ui.color('Creating Flow Log...', :magenta)}"
76
+
77
+ case config[:type]
78
+ when 'nic'
79
+ validate_required_params([:server_id, :nic_id], config)
80
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
81
+ method = flowlogs_api.method(:datacenters_servers_nics_flowlogs_post_with_http_info)
82
+ args = [config[:datacenter_id], config[:server_id], config[:nic_id]]
83
+ when 'natgateway'
84
+ validate_required_params([:natgateway_id], config)
85
+ flowlogs_api = Ionoscloud::NATGatewaysApi.new(api_client)
86
+ method = flowlogs_api.method(:datacenters_natgateways_flowlogs_post_with_http_info)
87
+ args = [config[:datacenter_id], config[:natgateway_id]]
88
+ when 'networkloadbalancer'
89
+ validate_required_params([:network_loadbalancer_id], config)
90
+ flowlogs_api = Ionoscloud::NetworkLoadBalancersApi.new(api_client)
91
+ method = flowlogs_api.method(:datacenters_networkloadbalancers_flowlogs_post_with_http_info)
92
+ args = [config[:datacenter_id], config[:network_loadbalancer_id]]
93
+ else
94
+ ui.error "Flow Log cannot belong to #{config[:type]}. Value must be one of ['nic', 'natgateway', 'networkloadbalancer']"
95
+ exit(1)
96
+ end
97
+
98
+ flowlog = Ionoscloud::FlowLog.new(
99
+ properties: Ionoscloud::FlowLogProperties.new({
100
+ name: config[:name],
101
+ action: config[:action],
102
+ direction: config[:direction],
103
+ bucket: config[:bucket],
104
+ }.compact),
105
+ )
106
+
107
+ flowlog, _, headers = method.call(*args, flowlog)
108
+
109
+ dot = ui.color('.', :magenta)
110
+ api_client.wait_for { print dot; is_done? get_request_id headers }
111
+
112
+ print_flowlog(flowlog)
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,103 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFlowlogDelete < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud flowlog delete FLOWLOG_ID [FLOWLOG_ID] (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ option :type,
16
+ short: '-t FLOWLOG_TYPE',
17
+ long: '--type FLOWLOG_TYPE',
18
+ description: 'The object to which the Flow Log will be attached'
19
+
20
+ option :server_id,
21
+ short: '-S SERVER_ID',
22
+ long: '--server-id SERVER_ID',
23
+ description: 'The ID of the server'
24
+
25
+ option :nic_id,
26
+ short: '-N NIC_ID',
27
+ long: '--nic-id NIC_ID',
28
+ description: 'ID of the NIC'
29
+
30
+ option :natgateway_id,
31
+ short: '-G NAT_GATEWAY_ID',
32
+ long: '--nat-gateway NAT_GATEWAY_ID',
33
+ description: 'ID of the NAT Gateway'
34
+
35
+ option :network_loadbalancer_id,
36
+ short: '-L NETWORK_LOADBALANCER',
37
+ long: '--network-loadbalancer NETWORK_LOADBALANCER',
38
+ description: 'ID of the Network Load Balancer'
39
+
40
+ attr_reader :description, :required_options
41
+
42
+ def initialize(args = [])
43
+ super(args)
44
+ @description =
45
+ 'Removes the specified Flow Logs.'
46
+ @required_options = [:datacenter_id, :type, :ionoscloud_username, :ionoscloud_password]
47
+ end
48
+
49
+ def run
50
+ $stdout.sync = true
51
+ handle_extra_config
52
+ validate_required_params(@required_options, config)
53
+
54
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
55
+
56
+ case config[:type]
57
+ when 'nic'
58
+ validate_required_params([:server_id, :nic_id], config)
59
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
60
+ delete_method = flowlogs_api.method(:datacenters_servers_nics_flowlogs_delete_with_http_info)
61
+ get_method = flowlogs_api.method(:datacenters_servers_nics_flowlogs_find_by_id)
62
+ args = [config[:datacenter_id], config[:server_id], config[:nic_id]]
63
+ when 'natgateway'
64
+ validate_required_params([:natgateway_id], config)
65
+ flowlogs_api = Ionoscloud::NATGatewaysApi.new(api_client)
66
+ delete_method = flowlogs_api.method(:datacenters_natgateways_flowlogs_delete_with_http_info)
67
+ get_method = flowlogs_api.method(:datacenters_natgateways_flowlogs_find_by_flow_log_id)
68
+ args = [config[:datacenter_id], config[:natgateway_id]]
69
+ when 'networkloadbalancer'
70
+ validate_required_params([:network_loadbalancer_id], config)
71
+ flowlogs_api = Ionoscloud::NetworkLoadBalancersApi.new(api_client)
72
+ delete_method = flowlogs_api.method(:datacenters_networkloadbalancers_flowlogs_delete_with_http_info)
73
+ get_method = flowlogs_api.method(:datacenters_networkloadbalancers_flowlogs_find_by_flow_log_id)
74
+ args = [config[:datacenter_id], config[:network_loadbalancer_id]]
75
+ else
76
+ ui.error "Flow Log cannot belong to #{config[:type]}. Value must be one of ['nic', 'natgateway', 'networkloadbalancer']"
77
+ exit(1)
78
+ end
79
+
80
+ @name_args.each do |flowlog_id|
81
+ begin
82
+ flowlog = get_method.call(*args, flowlog_id)
83
+ rescue Ionoscloud::ApiError => err
84
+ raise err unless err.code == 404
85
+ ui.error("Flow Log ID #{flowlog_id} not found. Skipping.")
86
+ next
87
+ end
88
+
89
+ print_flowlog(flowlog)
90
+
91
+ begin
92
+ confirm('Do you really want to delete this Flow Log')
93
+ rescue SystemExit => exc
94
+ next
95
+ end
96
+
97
+ _, _, headers = delete_method.call(*args, flowlog_id)
98
+ ui.warn("Deleted Flow Log #{flowlog.id}. Request ID: #{get_request_id headers}")
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,84 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFlowlogGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud flowlog get (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ option :type,
16
+ short: '-t FLOWLOG_TYPE',
17
+ long: '--type FLOWLOG_TYPE',
18
+ description: 'The object to which the Flow Log will be attached'
19
+
20
+ option :server_id,
21
+ short: '-S SERVER_ID',
22
+ long: '--server-id SERVER_ID',
23
+ description: 'The ID of the server'
24
+
25
+ option :nic_id,
26
+ short: '-N NIC_ID',
27
+ long: '--nic-id NIC_ID',
28
+ description: 'ID of the NIC'
29
+
30
+ option :natgateway_id,
31
+ short: '-G NAT_GATEWAY_ID',
32
+ long: '--nat-gateway NAT_GATEWAY_ID',
33
+ description: 'ID of the NAT Gateway'
34
+
35
+ option :network_loadbalancer_id,
36
+ short: '-L NETWORK_LOADBALANCER',
37
+ long: '--network-loadbalancer NETWORK_LOADBALANCER',
38
+ description: 'ID of the Network Load Balancer'
39
+
40
+ option :flowlog_id,
41
+ short: '-F FLOWLOG_ID',
42
+ long: '--flowlog-id FLOWLOG_ID',
43
+ description: 'The ID of the Flow Log'
44
+
45
+ attr_reader :description, :required_options
46
+
47
+ def initialize(args = [])
48
+ super(args)
49
+ @description =
50
+ 'Retrieves information about a Ionoscloud Flow Log.'
51
+ @required_options = [:flowlog_id, :datacenter_id, :type, :ionoscloud_username, :ionoscloud_password]
52
+ end
53
+
54
+ def run
55
+ $stdout.sync = true
56
+ handle_extra_config
57
+ validate_required_params(@required_options, config)
58
+
59
+ case config[:type]
60
+ when 'nic'
61
+ validate_required_params([:server_id, :nic_id], config)
62
+ flowlog = Ionoscloud::FlowLogsApi.new(api_client).datacenters_servers_nics_flowlogs_find_by_id(
63
+ config[:datacenter_id], config[:server_id], config[:nic_id], config[:flowlog_id],
64
+ )
65
+ when 'natgateway'
66
+ validate_required_params([:natgateway_id], config)
67
+ flowlog = Ionoscloud::NATGatewaysApi.new(api_client).datacenters_natgateways_flowlogs_find_by_flow_log_id(
68
+ config[:datacenter_id], config[:natgateway_id], config[:flowlog_id],
69
+ )
70
+ when 'networkloadbalancer'
71
+ validate_required_params([:network_loadbalancer_id], config)
72
+ flowlog = Ionoscloud::NetworkLoadBalancersApi.new(api_client).datacenters_networkloadbalancers_flowlogs_find_by_flow_log_id(
73
+ config[:datacenter_id], config[:network_loadbalancer_id], config[:flowlog_id],
74
+ )
75
+ else
76
+ ui.error "Flow Log cannot belong to #{config[:type]}. Value must be one of ['nic', 'natgateway', 'networkloadbalancer']"
77
+ exit(1)
78
+ end
79
+
80
+ print_flowlog(flowlog)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,101 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFlowlogList < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud flowlog list (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'ID of the data center'
14
+
15
+ option :type,
16
+ short: '-t FLOWLOG_TYPE',
17
+ long: '--type FLOWLOG_TYPE',
18
+ description: 'The object to which the flow log will be attached'
19
+
20
+ option :server_id,
21
+ short: '-S SERVER_ID',
22
+ long: '--server-id SERVER_ID',
23
+ description: 'The ID of the server'
24
+
25
+ option :nic_id,
26
+ short: '-N NIC_ID',
27
+ long: '--nic-id NIC_ID',
28
+ description: 'ID of the NIC'
29
+
30
+ option :natgateway_id,
31
+ short: '-G NAT_GATEWAY_ID',
32
+ long: '--nat-gateway NAT_GATEWAY_ID',
33
+ description: 'ID of the NAT Gateway'
34
+
35
+ option :network_loadbalancer_id,
36
+ short: '-L NETWORK_LOADBALANCER',
37
+ long: '--network-loadbalancer NETWORK_LOADBALANCER',
38
+ description: 'ID of the Network Load Balancer'
39
+
40
+ attr_reader :description, :required_options
41
+
42
+ def initialize(args = [])
43
+ super(args)
44
+ @description =
45
+ 'Lists all available flow logs assigned to a NIC, NAT Gateway or Network Load Balancer.'
46
+ @required_options = [:datacenter_id, :type, :ionoscloud_username, :ionoscloud_password]
47
+ end
48
+
49
+ def run
50
+ $stdout.sync = true
51
+ handle_extra_config
52
+ validate_required_params(@required_options, config)
53
+
54
+ flowlog_list = [
55
+ ui.color('ID', :bold),
56
+ ui.color('Name', :bold),
57
+ ui.color('Action', :bold),
58
+ ui.color('Direction', :bold),
59
+ ui.color('Bucket', :bold),
60
+ ]
61
+ flowlogs = []
62
+
63
+ case config[:type]
64
+ when 'nic'
65
+ validate_required_params([:server_id, :nic_id], config)
66
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
67
+ flowlogs = flowlogs_api.datacenters_servers_nics_flowlogs_get(
68
+ config[:datacenter_id], config[:server_id], config[:nic_id], { depth: 1 }
69
+ )
70
+ when 'natgateway'
71
+ validate_required_params([:natgateway_id], config)
72
+ flowlogs_api = Ionoscloud::NATGatewaysApi.new(api_client)
73
+ flowlogs = flowlogs_api.datacenters_natgateways_flowlogs_get(
74
+ config[:datacenter_id], config[:natgateway_id], { depth: 1 }
75
+ )
76
+ when 'networkloadbalancer'
77
+ validate_required_params([:network_loadbalancer_id], config)
78
+ flowlogs_api = Ionoscloud::NetworkLoadBalancersApi.new(api_client)
79
+ flowlogs = flowlogs_api.datacenters_networkloadbalancers_flowlogs_get(
80
+ config[:datacenter_id], config[:network_loadbalancer_id], { depth: 1 }
81
+ )
82
+ else
83
+ ui.error "Flow log cannot belong to #{config[:type]}. Value must be one of ['nic', 'natgateway', 'networkloadbalancer']"
84
+ exit(1)
85
+ end
86
+
87
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
88
+
89
+ flowlogs.items.each do |flowlog|
90
+ flowlog_list << flowlog.id
91
+ flowlog_list << flowlog.properties.name
92
+ flowlog_list << flowlog.properties.action.to_s
93
+ flowlog_list << flowlog.properties.direction.to_s
94
+ flowlog_list << flowlog.properties.bucket.to_s
95
+ end
96
+
97
+ puts ui.list(flowlog_list, :uneven_columns_across, 5)
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,127 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudFlowlogUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud flowlog update (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ option :type,
16
+ short: '-t FLOWLOG_TYPE',
17
+ long: '--type FLOWLOG_TYPE',
18
+ description: 'The object to which the Flow Log will be attached'
19
+
20
+ option :server_id,
21
+ short: '-S SERVER_ID',
22
+ long: '--server-id SERVER_ID',
23
+ description: 'The ID of the server'
24
+
25
+ option :nic_id,
26
+ short: '-N NIC_ID',
27
+ long: '--nic-id NIC_ID',
28
+ description: 'ID of the NIC'
29
+
30
+ option :natgateway_id,
31
+ short: '-G NAT_GATEWAY_ID',
32
+ long: '--nat-gateway NAT_GATEWAY_ID',
33
+ description: 'ID of the NAT Gateway'
34
+
35
+ option :network_loadbalancer_id,
36
+ short: '-L NETWORK_LOADBALANCER',
37
+ long: '--network-loadbalancer NETWORK_LOADBALANCER',
38
+ description: 'ID of the Network Load Balancer'
39
+
40
+ option :flowlog_id,
41
+ short: '-F FLOWLOG_ID',
42
+ long: '--flowlog-id FLOWLOG_ID',
43
+ description: 'The ID of the Flow Log'
44
+
45
+ option :name,
46
+ short: '-n NAME',
47
+ long: '--name NAME',
48
+ description: 'Name of the Flow Log'
49
+
50
+ option :action,
51
+ short: '-a ACTION',
52
+ long: '--action ACTION',
53
+ default: 'ALL',
54
+ description: 'Specifies the traffic action pattern. Must be one of ["ALL", "ACCEPTED", "REJECTED"].'
55
+
56
+ option :direction,
57
+ long: '--direction DIRECTION',
58
+ default: 'BIDIRECTIONAL',
59
+ description: 'Specifies the traffic direction pattern. Must be one of ["INGRESS", "EGRESS", "BIDIRECTIONAL"].'
60
+
61
+ option :bucket,
62
+ short: '-b BUCKET',
63
+ long: '--bucket BUCKET',
64
+ description: 'S3 bucket name of an existing IONOS Cloud S3 bucket. Ex. bucketName/key'
65
+
66
+ attr_reader :description, :required_options
67
+
68
+ def initialize(args = [])
69
+ super(args)
70
+ @description =
71
+ 'Updates information about a Ionoscloud Flow Log.'
72
+ @required_options = [:flowlog_id, :datacenter_id, :type, :ionoscloud_username, :ionoscloud_password]
73
+ @updatable_fields = [:name, :action, :direction, :bucket]
74
+ end
75
+
76
+ def run
77
+ $stdout.sync = true
78
+ handle_extra_config
79
+ validate_required_params(@required_options, config)
80
+
81
+ case config[:type]
82
+ when 'nic'
83
+ validate_required_params([:server_id, :nic_id], config)
84
+ flowlogs_api = Ionoscloud::FlowLogsApi.new(api_client)
85
+ patch_method = flowlogs_api.method(:datacenters_servers_nics_flowlogs_patch_with_http_info)
86
+ get_method = flowlogs_api.method(:datacenters_servers_nics_flowlogs_find_by_id)
87
+ args = [config[:datacenter_id], config[:server_id], config[:nic_id], config[:flowlog_id]]
88
+ when 'natgateway'
89
+ validate_required_params([:natgateway_id], config)
90
+ flowlogs_api = Ionoscloud::NATGatewaysApi.new(api_client)
91
+ patch_method = flowlogs_api.method(:datacenters_natgateways_flowlogs_patch_with_http_info)
92
+ get_method = flowlogs_api.method(:datacenters_natgateways_flowlogs_find_by_flow_log_id)
93
+ args = [config[:datacenter_id], config[:natgateway_id], config[:flowlog_id]]
94
+ when 'networkloadbalancer'
95
+ validate_required_params([:network_loadbalancer_id], config)
96
+ flowlogs_api = Ionoscloud::NetworkLoadBalancersApi.new(api_client)
97
+ patch_method = flowlogs_api.method(:datacenters_networkloadbalancers_flowlogs_patch_with_http_info)
98
+ get_method = flowlogs_api.method(:datacenters_networkloadbalancers_flowlogs_find_by_flow_log_id)
99
+ args = [config[:datacenter_id], config[:network_loadbalancer_id], config[:flowlog_id]]
100
+ else
101
+ ui.error "Flow Log cannot belong to #{config[:type]}. Value must be one of ['nic', 'natgateway', 'networkloadbalancer']"
102
+ exit(1)
103
+ end
104
+
105
+ if @updatable_fields.map { |el| config[el] }.any?
106
+ print "#{ui.color('Updating Flow Log...', :magenta)}"
107
+
108
+ flowlog_properties = Ionoscloud::FlowLogProperties.new({
109
+ name: config[:name],
110
+ action: config[:action],
111
+ direction: config[:direction],
112
+ bucket: config[:bucket],
113
+ }.compact)
114
+
115
+ _, _, headers = patch_method.call(*args, flowlog_properties)
116
+
117
+ dot = ui.color('.', :magenta)
118
+ api_client.wait_for { print dot; is_done? get_request_id headers }
119
+ else
120
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
121
+ end
122
+
123
+ print_flowlog(get_method.call(*args))
124
+ end
125
+ end
126
+ end
127
+ end