gitlab-fog-google 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (556) hide show
  1. checksums.yaml +7 -0
  2. data/.codecov.yml +2 -0
  3. data/.editorconfig +11 -0
  4. data/.fog.example +25 -0
  5. data/.gitignore +20 -0
  6. data/.gitlab-ci.yml +13 -0
  7. data/.hound.yml +2 -0
  8. data/.rubocop.yml +255 -0
  9. data/.ruby-gemset +1 -0
  10. data/.travis.yml +33 -0
  11. data/CHANGELOG.md +464 -0
  12. data/CONTRIBUTING.md +175 -0
  13. data/CONTRIBUTORS.md +95 -0
  14. data/Gemfile +13 -0
  15. data/LICENSE.md +20 -0
  16. data/MIGRATING.md +1 -0
  17. data/README.md +177 -0
  18. data/Rakefile +19 -0
  19. data/SECURITY.md +16 -0
  20. data/ci/.gitignore +1 -0
  21. data/ci/README.md +65 -0
  22. data/ci/build-head-pipeline.yml +173 -0
  23. data/ci/credentials.yml.template +28 -0
  24. data/ci/docker-image/Dockerfile +18 -0
  25. data/ci/integration-pipeline.yml +226 -0
  26. data/ci/pipeline-dev.yml +58 -0
  27. data/ci/tasks/run-int.sh +53 -0
  28. data/ci/tasks/run-int.yml +18 -0
  29. data/ci/tasks/utils.sh +10 -0
  30. data/examples/backend_services.rb +23 -0
  31. data/examples/bootstrap.rb +27 -0
  32. data/examples/create_instance.rb +73 -0
  33. data/examples/create_instance_with_attached_disk.rb +53 -0
  34. data/examples/dns/project.rb +7 -0
  35. data/examples/dns/zones.rb +43 -0
  36. data/examples/get_list_images.rb +42 -0
  37. data/examples/get_list_snapshots.rb +28 -0
  38. data/examples/image_create.rb +17 -0
  39. data/examples/l7_load_balance.rb +79 -0
  40. data/examples/load-balance.rb +116 -0
  41. data/examples/metadata.rb +40 -0
  42. data/examples/monitoring/metric_descriptors.rb +24 -0
  43. data/examples/monitoring/monitored_resource_descriptors.rb +24 -0
  44. data/examples/monitoring/timeseries_collection.rb +32 -0
  45. data/examples/network.rb +55 -0
  46. data/examples/precreated_client.rb +24 -0
  47. data/examples/pubsub/subscriptions.rb +54 -0
  48. data/examples/pubsub/topics.rb +33 -0
  49. data/examples/sql/flags.rb +11 -0
  50. data/examples/sql/instances.rb +38 -0
  51. data/examples/sql/operations.rb +24 -0
  52. data/examples/sql/ssl_certs.rb +32 -0
  53. data/examples/sql/tiers.rb +11 -0
  54. data/examples/storage.rb +49 -0
  55. data/examples/storage_json.rb +37 -0
  56. data/gitlab-fog-google.gemspec +44 -0
  57. data/lib/fog/bin/google.rb +97 -0
  58. data/lib/fog/compute/google.rb +304 -0
  59. data/lib/fog/compute/google/mock.rb +845 -0
  60. data/lib/fog/compute/google/models/address.rb +133 -0
  61. data/lib/fog/compute/google/models/addresses.rb +63 -0
  62. data/lib/fog/compute/google/models/backend_service.rb +86 -0
  63. data/lib/fog/compute/google/models/backend_services.rb +24 -0
  64. data/lib/fog/compute/google/models/disk.rb +155 -0
  65. data/lib/fog/compute/google/models/disk_type.rb +27 -0
  66. data/lib/fog/compute/google/models/disk_types.rb +42 -0
  67. data/lib/fog/compute/google/models/disks.rb +88 -0
  68. data/lib/fog/compute/google/models/firewall.rb +94 -0
  69. data/lib/fog/compute/google/models/firewalls.rb +24 -0
  70. data/lib/fog/compute/google/models/forwarding_rule.rb +79 -0
  71. data/lib/fog/compute/google/models/forwarding_rules.rb +44 -0
  72. data/lib/fog/compute/google/models/global_address.rb +58 -0
  73. data/lib/fog/compute/google/models/global_addresses.rb +46 -0
  74. data/lib/fog/compute/google/models/global_forwarding_rule.rb +78 -0
  75. data/lib/fog/compute/google/models/global_forwarding_rules.rb +24 -0
  76. data/lib/fog/compute/google/models/http_health_check.rb +104 -0
  77. data/lib/fog/compute/google/models/http_health_checks.rb +24 -0
  78. data/lib/fog/compute/google/models/image.rb +81 -0
  79. data/lib/fog/compute/google/models/images.rb +109 -0
  80. data/lib/fog/compute/google/models/instance_group.rb +90 -0
  81. data/lib/fog/compute/google/models/instance_group_manager.rb +51 -0
  82. data/lib/fog/compute/google/models/instance_group_managers.rb +45 -0
  83. data/lib/fog/compute/google/models/instance_groups.rb +63 -0
  84. data/lib/fog/compute/google/models/instance_template.rb +47 -0
  85. data/lib/fog/compute/google/models/instance_templates.rb +24 -0
  86. data/lib/fog/compute/google/models/machine_type.rb +23 -0
  87. data/lib/fog/compute/google/models/machine_types.rb +46 -0
  88. data/lib/fog/compute/google/models/network.rb +60 -0
  89. data/lib/fog/compute/google/models/networks.rb +24 -0
  90. data/lib/fog/compute/google/models/operation.rb +73 -0
  91. data/lib/fog/compute/google/models/operations.rb +45 -0
  92. data/lib/fog/compute/google/models/project.rb +28 -0
  93. data/lib/fog/compute/google/models/projects.rb +19 -0
  94. data/lib/fog/compute/google/models/region.rb +30 -0
  95. data/lib/fog/compute/google/models/regions.rb +24 -0
  96. data/lib/fog/compute/google/models/route.rb +49 -0
  97. data/lib/fog/compute/google/models/routes.rb +24 -0
  98. data/lib/fog/compute/google/models/server.rb +604 -0
  99. data/lib/fog/compute/google/models/servers.rb +120 -0
  100. data/lib/fog/compute/google/models/snapshot.rb +62 -0
  101. data/lib/fog/compute/google/models/snapshots.rb +32 -0
  102. data/lib/fog/compute/google/models/ssl_certificate.rb +42 -0
  103. data/lib/fog/compute/google/models/ssl_certificates.rb +24 -0
  104. data/lib/fog/compute/google/models/subnetwork.rb +83 -0
  105. data/lib/fog/compute/google/models/subnetworks.rb +43 -0
  106. data/lib/fog/compute/google/models/target_http_proxies.rb +24 -0
  107. data/lib/fog/compute/google/models/target_http_proxy.rb +73 -0
  108. data/lib/fog/compute/google/models/target_https_proxies.rb +24 -0
  109. data/lib/fog/compute/google/models/target_https_proxy.rb +105 -0
  110. data/lib/fog/compute/google/models/target_instance.rb +67 -0
  111. data/lib/fog/compute/google/models/target_instances.rb +46 -0
  112. data/lib/fog/compute/google/models/target_pool.rb +171 -0
  113. data/lib/fog/compute/google/models/target_pools.rb +43 -0
  114. data/lib/fog/compute/google/models/url_map.rb +121 -0
  115. data/lib/fog/compute/google/models/url_maps.rb +24 -0
  116. data/lib/fog/compute/google/models/zone.rb +25 -0
  117. data/lib/fog/compute/google/models/zones.rb +24 -0
  118. data/lib/fog/compute/google/real.rb +24 -0
  119. data/lib/fog/compute/google/requests/abandon_instances.rb +28 -0
  120. data/lib/fog/compute/google/requests/add_backend_service_backends.rb +19 -0
  121. data/lib/fog/compute/google/requests/add_instance_group_instances.rb +37 -0
  122. data/lib/fog/compute/google/requests/add_server_access_config.rb +32 -0
  123. data/lib/fog/compute/google/requests/add_target_pool_health_checks.rb +32 -0
  124. data/lib/fog/compute/google/requests/add_target_pool_instances.rb +30 -0
  125. data/lib/fog/compute/google/requests/attach_disk.rb +22 -0
  126. data/lib/fog/compute/google/requests/create_disk_snapshot.rb +24 -0
  127. data/lib/fog/compute/google/requests/delete_address.rb +24 -0
  128. data/lib/fog/compute/google/requests/delete_backend_service.rb +19 -0
  129. data/lib/fog/compute/google/requests/delete_disk.rb +25 -0
  130. data/lib/fog/compute/google/requests/delete_firewall.rb +19 -0
  131. data/lib/fog/compute/google/requests/delete_forwarding_rule.rb +20 -0
  132. data/lib/fog/compute/google/requests/delete_global_address.rb +19 -0
  133. data/lib/fog/compute/google/requests/delete_global_forwarding_rule.rb +19 -0
  134. data/lib/fog/compute/google/requests/delete_global_operation.rb +20 -0
  135. data/lib/fog/compute/google/requests/delete_http_health_check.rb +19 -0
  136. data/lib/fog/compute/google/requests/delete_image.rb +19 -0
  137. data/lib/fog/compute/google/requests/delete_instance_group.rb +19 -0
  138. data/lib/fog/compute/google/requests/delete_instance_group_manager.rb +19 -0
  139. data/lib/fog/compute/google/requests/delete_instance_template.rb +19 -0
  140. data/lib/fog/compute/google/requests/delete_network.rb +19 -0
  141. data/lib/fog/compute/google/requests/delete_region_operation.rb +22 -0
  142. data/lib/fog/compute/google/requests/delete_route.rb +23 -0
  143. data/lib/fog/compute/google/requests/delete_server.rb +19 -0
  144. data/lib/fog/compute/google/requests/delete_server_access_config.rb +22 -0
  145. data/lib/fog/compute/google/requests/delete_snapshot.rb +19 -0
  146. data/lib/fog/compute/google/requests/delete_ssl_certificate.rb +19 -0
  147. data/lib/fog/compute/google/requests/delete_subnetwork.rb +31 -0
  148. data/lib/fog/compute/google/requests/delete_target_http_proxy.rb +19 -0
  149. data/lib/fog/compute/google/requests/delete_target_https_proxy.rb +19 -0
  150. data/lib/fog/compute/google/requests/delete_target_instance.rb +20 -0
  151. data/lib/fog/compute/google/requests/delete_target_pool.rb +20 -0
  152. data/lib/fog/compute/google/requests/delete_url_map.rb +19 -0
  153. data/lib/fog/compute/google/requests/delete_zone_operation.rb +22 -0
  154. data/lib/fog/compute/google/requests/deprecate_image.rb +22 -0
  155. data/lib/fog/compute/google/requests/detach_disk.rb +20 -0
  156. data/lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb +38 -0
  157. data/lib/fog/compute/google/requests/get_address.rb +24 -0
  158. data/lib/fog/compute/google/requests/get_backend_service.rb +19 -0
  159. data/lib/fog/compute/google/requests/get_backend_service_health.rb +24 -0
  160. data/lib/fog/compute/google/requests/get_disk.rb +24 -0
  161. data/lib/fog/compute/google/requests/get_disk_type.rb +19 -0
  162. data/lib/fog/compute/google/requests/get_firewall.rb +19 -0
  163. data/lib/fog/compute/google/requests/get_forwarding_rule.rb +22 -0
  164. data/lib/fog/compute/google/requests/get_global_address.rb +19 -0
  165. data/lib/fog/compute/google/requests/get_global_forwarding_rule.rb +19 -0
  166. data/lib/fog/compute/google/requests/get_global_operation.rb +23 -0
  167. data/lib/fog/compute/google/requests/get_http_health_check.rb +19 -0
  168. data/lib/fog/compute/google/requests/get_image.rb +20 -0
  169. data/lib/fog/compute/google/requests/get_image_from_family.rb +26 -0
  170. data/lib/fog/compute/google/requests/get_instance_group.rb +19 -0
  171. data/lib/fog/compute/google/requests/get_instance_group_manager.rb +19 -0
  172. data/lib/fog/compute/google/requests/get_instance_template.rb +19 -0
  173. data/lib/fog/compute/google/requests/get_machine_type.rb +20 -0
  174. data/lib/fog/compute/google/requests/get_network.rb +19 -0
  175. data/lib/fog/compute/google/requests/get_project.rb +19 -0
  176. data/lib/fog/compute/google/requests/get_region.rb +19 -0
  177. data/lib/fog/compute/google/requests/get_region_operation.rb +20 -0
  178. data/lib/fog/compute/google/requests/get_route.rb +22 -0
  179. data/lib/fog/compute/google/requests/get_server.rb +19 -0
  180. data/lib/fog/compute/google/requests/get_server_serial_port_output.rb +38 -0
  181. data/lib/fog/compute/google/requests/get_snapshot.rb +20 -0
  182. data/lib/fog/compute/google/requests/get_ssl_certificate.rb +19 -0
  183. data/lib/fog/compute/google/requests/get_subnetwork.rb +29 -0
  184. data/lib/fog/compute/google/requests/get_target_http_proxy.rb +19 -0
  185. data/lib/fog/compute/google/requests/get_target_https_proxy.rb +19 -0
  186. data/lib/fog/compute/google/requests/get_target_instance.rb +20 -0
  187. data/lib/fog/compute/google/requests/get_target_pool.rb +20 -0
  188. data/lib/fog/compute/google/requests/get_target_pool_health.rb +24 -0
  189. data/lib/fog/compute/google/requests/get_url_map.rb +19 -0
  190. data/lib/fog/compute/google/requests/get_zone.rb +19 -0
  191. data/lib/fog/compute/google/requests/get_zone_operation.rb +25 -0
  192. data/lib/fog/compute/google/requests/insert_address.rb +30 -0
  193. data/lib/fog/compute/google/requests/insert_backend_service.rb +23 -0
  194. data/lib/fog/compute/google/requests/insert_disk.rb +48 -0
  195. data/lib/fog/compute/google/requests/insert_firewall.rb +65 -0
  196. data/lib/fog/compute/google/requests/insert_forwarding_rule.rb +29 -0
  197. data/lib/fog/compute/google/requests/insert_global_address.rb +25 -0
  198. data/lib/fog/compute/google/requests/insert_global_forwarding_rule.rb +26 -0
  199. data/lib/fog/compute/google/requests/insert_http_health_check.rb +24 -0
  200. data/lib/fog/compute/google/requests/insert_image.rb +23 -0
  201. data/lib/fog/compute/google/requests/insert_instance_group.rb +37 -0
  202. data/lib/fog/compute/google/requests/insert_instance_group_manager.rb +31 -0
  203. data/lib/fog/compute/google/requests/insert_instance_template.rb +38 -0
  204. data/lib/fog/compute/google/requests/insert_network.rb +34 -0
  205. data/lib/fog/compute/google/requests/insert_route.rb +35 -0
  206. data/lib/fog/compute/google/requests/insert_server.rb +122 -0
  207. data/lib/fog/compute/google/requests/insert_ssl_certificate.rb +27 -0
  208. data/lib/fog/compute/google/requests/insert_subnetwork.rb +61 -0
  209. data/lib/fog/compute/google/requests/insert_target_http_proxy.rb +26 -0
  210. data/lib/fog/compute/google/requests/insert_target_https_proxy.rb +29 -0
  211. data/lib/fog/compute/google/requests/insert_target_instance.rb +25 -0
  212. data/lib/fog/compute/google/requests/insert_target_pool.rb +22 -0
  213. data/lib/fog/compute/google/requests/insert_url_map.rb +37 -0
  214. data/lib/fog/compute/google/requests/invalidate_url_map_cache.rb +24 -0
  215. data/lib/fog/compute/google/requests/list_addresses.rb +28 -0
  216. data/lib/fog/compute/google/requests/list_aggregated_addresses.rb +23 -0
  217. data/lib/fog/compute/google/requests/list_aggregated_disk_types.rb +24 -0
  218. data/lib/fog/compute/google/requests/list_aggregated_disks.rb +32 -0
  219. data/lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb +24 -0
  220. data/lib/fog/compute/google/requests/list_aggregated_instance_group_managers.rb +26 -0
  221. data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +19 -0
  222. data/lib/fog/compute/google/requests/list_aggregated_machine_types.rb +24 -0
  223. data/lib/fog/compute/google/requests/list_aggregated_servers.rb +24 -0
  224. data/lib/fog/compute/google/requests/list_aggregated_subnetworks.rb +36 -0
  225. data/lib/fog/compute/google/requests/list_aggregated_target_instances.rb +26 -0
  226. data/lib/fog/compute/google/requests/list_aggregated_target_pools.rb +26 -0
  227. data/lib/fog/compute/google/requests/list_backend_services.rb +22 -0
  228. data/lib/fog/compute/google/requests/list_disk_types.rb +24 -0
  229. data/lib/fog/compute/google/requests/list_disks.rb +28 -0
  230. data/lib/fog/compute/google/requests/list_firewalls.rb +24 -0
  231. data/lib/fog/compute/google/requests/list_forwarding_rules.rb +25 -0
  232. data/lib/fog/compute/google/requests/list_global_addresses.rb +26 -0
  233. data/lib/fog/compute/google/requests/list_global_forwarding_rules.rb +24 -0
  234. data/lib/fog/compute/google/requests/list_global_operations.rb +27 -0
  235. data/lib/fog/compute/google/requests/list_http_health_checks.rb +24 -0
  236. data/lib/fog/compute/google/requests/list_images.rb +25 -0
  237. data/lib/fog/compute/google/requests/list_instance_group_instances.rb +21 -0
  238. data/lib/fog/compute/google/requests/list_instance_group_managers.rb +22 -0
  239. data/lib/fog/compute/google/requests/list_instance_groups.rb +19 -0
  240. data/lib/fog/compute/google/requests/list_instance_templates.rb +26 -0
  241. data/lib/fog/compute/google/requests/list_machine_types.rb +25 -0
  242. data/lib/fog/compute/google/requests/list_networks.rb +24 -0
  243. data/lib/fog/compute/google/requests/list_region_operations.rb +29 -0
  244. data/lib/fog/compute/google/requests/list_regions.rb +23 -0
  245. data/lib/fog/compute/google/requests/list_routes.rb +28 -0
  246. data/lib/fog/compute/google/requests/list_servers.rb +24 -0
  247. data/lib/fog/compute/google/requests/list_snapshots.rb +22 -0
  248. data/lib/fog/compute/google/requests/list_ssl_certificates.rb +26 -0
  249. data/lib/fog/compute/google/requests/list_subnetworks.rb +39 -0
  250. data/lib/fog/compute/google/requests/list_target_http_proxies.rb +25 -0
  251. data/lib/fog/compute/google/requests/list_target_https_proxies.rb +24 -0
  252. data/lib/fog/compute/google/requests/list_target_instances.rb +27 -0
  253. data/lib/fog/compute/google/requests/list_target_pools.rb +26 -0
  254. data/lib/fog/compute/google/requests/list_url_maps.rb +25 -0
  255. data/lib/fog/compute/google/requests/list_zone_operations.rb +28 -0
  256. data/lib/fog/compute/google/requests/list_zones.rb +26 -0
  257. data/lib/fog/compute/google/requests/patch_firewall.rb +27 -0
  258. data/lib/fog/compute/google/requests/patch_url_map.rb +21 -0
  259. data/lib/fog/compute/google/requests/recreate_instances.rb +28 -0
  260. data/lib/fog/compute/google/requests/remove_instance_group_instances.rb +37 -0
  261. data/lib/fog/compute/google/requests/remove_target_pool_health_checks.rb +30 -0
  262. data/lib/fog/compute/google/requests/remove_target_pool_instance.rb +30 -0
  263. data/lib/fog/compute/google/requests/remove_target_pool_instances.rb +30 -0
  264. data/lib/fog/compute/google/requests/reset_server.rb +19 -0
  265. data/lib/fog/compute/google/requests/reset_windows_password.rb +154 -0
  266. data/lib/fog/compute/google/requests/set_common_instance_metadata.rb +23 -0
  267. data/lib/fog/compute/google/requests/set_forwarding_rule_target.rb +23 -0
  268. data/lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb +22 -0
  269. data/lib/fog/compute/google/requests/set_instance_template.rb +28 -0
  270. data/lib/fog/compute/google/requests/set_server_disk_auto_delete.rb +26 -0
  271. data/lib/fog/compute/google/requests/set_server_machine_type.rb +23 -0
  272. data/lib/fog/compute/google/requests/set_server_metadata.rb +39 -0
  273. data/lib/fog/compute/google/requests/set_server_scheduling.rb +24 -0
  274. data/lib/fog/compute/google/requests/set_server_tags.rb +25 -0
  275. data/lib/fog/compute/google/requests/set_snapshot_labels.rb +25 -0
  276. data/lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb +42 -0
  277. data/lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb +24 -0
  278. data/lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb +24 -0
  279. data/lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb +24 -0
  280. data/lib/fog/compute/google/requests/set_target_pool_backup.rb +31 -0
  281. data/lib/fog/compute/google/requests/start_server.rb +19 -0
  282. data/lib/fog/compute/google/requests/stop_server.rb +19 -0
  283. data/lib/fog/compute/google/requests/update_firewall.rb +49 -0
  284. data/lib/fog/compute/google/requests/update_http_health_check.rb +25 -0
  285. data/lib/fog/compute/google/requests/update_url_map.rb +28 -0
  286. data/lib/fog/compute/google/requests/validate_url_map.rb +24 -0
  287. data/lib/fog/dns/google.rb +67 -0
  288. data/lib/fog/dns/google/mock.rb +33 -0
  289. data/lib/fog/dns/google/models/change.rb +38 -0
  290. data/lib/fog/dns/google/models/changes.rb +50 -0
  291. data/lib/fog/dns/google/models/project.rb +73 -0
  292. data/lib/fog/dns/google/models/projects.rb +23 -0
  293. data/lib/fog/dns/google/models/record.rb +108 -0
  294. data/lib/fog/dns/google/models/records.rb +53 -0
  295. data/lib/fog/dns/google/models/zone.rb +72 -0
  296. data/lib/fog/dns/google/models/zones.rb +32 -0
  297. data/lib/fog/dns/google/real.rb +19 -0
  298. data/lib/fog/dns/google/requests/create_change.rb +29 -0
  299. data/lib/fog/dns/google/requests/create_managed_zone.rb +29 -0
  300. data/lib/fog/dns/google/requests/delete_managed_zone.rb +23 -0
  301. data/lib/fog/dns/google/requests/get_change.rb +23 -0
  302. data/lib/fog/dns/google/requests/get_managed_zone.rb +23 -0
  303. data/lib/fog/dns/google/requests/get_project.rb +24 -0
  304. data/lib/fog/dns/google/requests/list_changes.rb +30 -0
  305. data/lib/fog/dns/google/requests/list_managed_zones.rb +26 -0
  306. data/lib/fog/dns/google/requests/list_resource_record_sets.rb +30 -0
  307. data/lib/fog/google.rb +53 -0
  308. data/lib/fog/google/mock.rb +14 -0
  309. data/lib/fog/google/models/monitoring/metric_descriptor.rb +23 -0
  310. data/lib/fog/google/models/monitoring/metric_descriptors.rb +43 -0
  311. data/lib/fog/google/models/monitoring/monitored_resource_descriptor.rb +20 -0
  312. data/lib/fog/google/models/monitoring/monitored_resource_descriptors.rb +37 -0
  313. data/lib/fog/google/models/monitoring/timeseries.rb +19 -0
  314. data/lib/fog/google/models/monitoring/timeseries_collection.rb +48 -0
  315. data/lib/fog/google/models/pubsub/received_message.rb +40 -0
  316. data/lib/fog/google/models/pubsub/subscription.rb +86 -0
  317. data/lib/fog/google/models/pubsub/subscriptions.rb +33 -0
  318. data/lib/fog/google/models/pubsub/topic.rb +71 -0
  319. data/lib/fog/google/models/pubsub/topics.rb +32 -0
  320. data/lib/fog/google/models/sql/backup_run.rb +37 -0
  321. data/lib/fog/google/models/sql/backup_runs.rb +38 -0
  322. data/lib/fog/google/models/sql/flag.rb +23 -0
  323. data/lib/fog/google/models/sql/flags.rb +21 -0
  324. data/lib/fog/google/models/sql/instance.rb +339 -0
  325. data/lib/fog/google/models/sql/instances.rb +39 -0
  326. data/lib/fog/google/models/sql/operation.rb +67 -0
  327. data/lib/fog/google/models/sql/operations.rb +47 -0
  328. data/lib/fog/google/models/sql/ssl_cert.rb +77 -0
  329. data/lib/fog/google/models/sql/ssl_certs.rb +49 -0
  330. data/lib/fog/google/models/sql/tier.rb +20 -0
  331. data/lib/fog/google/models/sql/tiers.rb +21 -0
  332. data/lib/fog/google/models/sql/user.rb +52 -0
  333. data/lib/fog/google/models/sql/users.rb +21 -0
  334. data/lib/fog/google/monitoring.rb +60 -0
  335. data/lib/fog/google/monitoring/mock.rb +35 -0
  336. data/lib/fog/google/monitoring/real.rb +20 -0
  337. data/lib/fog/google/pubsub.rb +69 -0
  338. data/lib/fog/google/pubsub/mock.rb +34 -0
  339. data/lib/fog/google/pubsub/real.rb +21 -0
  340. data/lib/fog/google/requests/monitoring/create_metric_descriptor.rb +51 -0
  341. data/lib/fog/google/requests/monitoring/create_timeseries.rb +29 -0
  342. data/lib/fog/google/requests/monitoring/delete_metric_descriptor.rb +19 -0
  343. data/lib/fog/google/requests/monitoring/get_metric_descriptor.rb +19 -0
  344. data/lib/fog/google/requests/monitoring/get_monitored_resource_descriptor.rb +19 -0
  345. data/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +26 -0
  346. data/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb +29 -0
  347. data/lib/fog/google/requests/monitoring/list_timeseries.rb +55 -0
  348. data/lib/fog/google/requests/pubsub/acknowledge_subscription.rb +29 -0
  349. data/lib/fog/google/requests/pubsub/create_subscription.rb +37 -0
  350. data/lib/fog/google/requests/pubsub/create_topic.rb +23 -0
  351. data/lib/fog/google/requests/pubsub/delete_subscription.rb +21 -0
  352. data/lib/fog/google/requests/pubsub/delete_topic.rb +21 -0
  353. data/lib/fog/google/requests/pubsub/get_subscription.rb +21 -0
  354. data/lib/fog/google/requests/pubsub/get_topic.rb +21 -0
  355. data/lib/fog/google/requests/pubsub/list_subscriptions.rb +29 -0
  356. data/lib/fog/google/requests/pubsub/list_topics.rb +29 -0
  357. data/lib/fog/google/requests/pubsub/publish_topic.rb +28 -0
  358. data/lib/fog/google/requests/pubsub/pull_subscription.rb +40 -0
  359. data/lib/fog/google/requests/sql/clone_instance.rb +42 -0
  360. data/lib/fog/google/requests/sql/delete_backup_run.rb +23 -0
  361. data/lib/fog/google/requests/sql/delete_instance.rb +24 -0
  362. data/lib/fog/google/requests/sql/delete_ssl_cert.rb +24 -0
  363. data/lib/fog/google/requests/sql/delete_user.rb +24 -0
  364. data/lib/fog/google/requests/sql/export_instance.rb +55 -0
  365. data/lib/fog/google/requests/sql/get_backup_run.rb +23 -0
  366. data/lib/fog/google/requests/sql/get_instance.rb +24 -0
  367. data/lib/fog/google/requests/sql/get_operation.rb +24 -0
  368. data/lib/fog/google/requests/sql/get_ssl_cert.rb +24 -0
  369. data/lib/fog/google/requests/sql/import_instance.rb +44 -0
  370. data/lib/fog/google/requests/sql/insert_backup_run.rb +28 -0
  371. data/lib/fog/google/requests/sql/insert_instance.rb +28 -0
  372. data/lib/fog/google/requests/sql/insert_ssl_cert.rb +30 -0
  373. data/lib/fog/google/requests/sql/insert_user.rb +25 -0
  374. data/lib/fog/google/requests/sql/list_backup_runs.rb +27 -0
  375. data/lib/fog/google/requests/sql/list_flags.rb +24 -0
  376. data/lib/fog/google/requests/sql/list_instances.rb +27 -0
  377. data/lib/fog/google/requests/sql/list_operations.rb +28 -0
  378. data/lib/fog/google/requests/sql/list_ssl_certs.rb +24 -0
  379. data/lib/fog/google/requests/sql/list_tiers.rb +24 -0
  380. data/lib/fog/google/requests/sql/list_users.rb +24 -0
  381. data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +26 -0
  382. data/lib/fog/google/requests/sql/restart_instance.rb +24 -0
  383. data/lib/fog/google/requests/sql/restore_instance_backup.rb +31 -0
  384. data/lib/fog/google/requests/sql/update_instance.rb +31 -0
  385. data/lib/fog/google/requests/sql/update_user.rb +27 -0
  386. data/lib/fog/google/shared.rb +253 -0
  387. data/lib/fog/google/sql.rb +104 -0
  388. data/lib/fog/google/sql/mock.rb +40 -0
  389. data/lib/fog/google/sql/real.rb +21 -0
  390. data/lib/fog/google/version.rb +5 -0
  391. data/lib/fog/parsers/storage/google.rb +15 -0
  392. data/lib/fog/parsers/storage/google/access_control_list.rb +44 -0
  393. data/lib/fog/parsers/storage/google/copy_object.rb +18 -0
  394. data/lib/fog/parsers/storage/google/get_bucket.rb +58 -0
  395. data/lib/fog/parsers/storage/google/get_bucket_logging.rb +36 -0
  396. data/lib/fog/parsers/storage/google/get_bucket_object_versions.rb +88 -0
  397. data/lib/fog/parsers/storage/google/get_bucket_versioning.rb +20 -0
  398. data/lib/fog/parsers/storage/google/get_request_payment.rb +16 -0
  399. data/lib/fog/parsers/storage/google/get_service.rb +28 -0
  400. data/lib/fog/storage/google.rb +20 -0
  401. data/lib/fog/storage/google_json.rb +74 -0
  402. data/lib/fog/storage/google_json/mock.rb +27 -0
  403. data/lib/fog/storage/google_json/models/directories.rb +41 -0
  404. data/lib/fog/storage/google_json/models/directory.rb +61 -0
  405. data/lib/fog/storage/google_json/models/file.rb +126 -0
  406. data/lib/fog/storage/google_json/models/files.rb +64 -0
  407. data/lib/fog/storage/google_json/real.rb +171 -0
  408. data/lib/fog/storage/google_json/requests/copy_object.rb +34 -0
  409. data/lib/fog/storage/google_json/requests/delete_bucket.rb +23 -0
  410. data/lib/fog/storage/google_json/requests/delete_object.rb +24 -0
  411. data/lib/fog/storage/google_json/requests/delete_object_url.rb +39 -0
  412. data/lib/fog/storage/google_json/requests/get_bucket.rb +43 -0
  413. data/lib/fog/storage/google_json/requests/get_bucket_acl.rb +32 -0
  414. data/lib/fog/storage/google_json/requests/get_object.rb +85 -0
  415. data/lib/fog/storage/google_json/requests/get_object_acl.rb +35 -0
  416. data/lib/fog/storage/google_json/requests/get_object_http_url.rb +32 -0
  417. data/lib/fog/storage/google_json/requests/get_object_https_url.rb +33 -0
  418. data/lib/fog/storage/google_json/requests/get_object_metadata.rb +32 -0
  419. data/lib/fog/storage/google_json/requests/get_object_url.rb +21 -0
  420. data/lib/fog/storage/google_json/requests/list_bucket_acl.rb +26 -0
  421. data/lib/fog/storage/google_json/requests/list_buckets.rb +30 -0
  422. data/lib/fog/storage/google_json/requests/list_object_acl.rb +29 -0
  423. data/lib/fog/storage/google_json/requests/list_objects.rb +48 -0
  424. data/lib/fog/storage/google_json/requests/put_bucket.rb +42 -0
  425. data/lib/fog/storage/google_json/requests/put_bucket_acl.rb +29 -0
  426. data/lib/fog/storage/google_json/requests/put_object.rb +102 -0
  427. data/lib/fog/storage/google_json/requests/put_object_acl.rb +35 -0
  428. data/lib/fog/storage/google_json/requests/put_object_url.rb +42 -0
  429. data/lib/fog/storage/google_json/utils.rb +40 -0
  430. data/lib/fog/storage/google_xml.rb +38 -0
  431. data/lib/fog/storage/google_xml/mock.rb +102 -0
  432. data/lib/fog/storage/google_xml/models/directories.rb +34 -0
  433. data/lib/fog/storage/google_xml/models/directory.rb +65 -0
  434. data/lib/fog/storage/google_xml/models/file.rb +130 -0
  435. data/lib/fog/storage/google_xml/models/files.rb +95 -0
  436. data/lib/fog/storage/google_xml/real.rb +108 -0
  437. data/lib/fog/storage/google_xml/requests/copy_object.rb +62 -0
  438. data/lib/fog/storage/google_xml/requests/delete_bucket.rb +39 -0
  439. data/lib/fog/storage/google_xml/requests/delete_object.rb +44 -0
  440. data/lib/fog/storage/google_xml/requests/delete_object_url.rb +42 -0
  441. data/lib/fog/storage/google_xml/requests/get_bucket.rb +95 -0
  442. data/lib/fog/storage/google_xml/requests/get_bucket_acl.rb +53 -0
  443. data/lib/fog/storage/google_xml/requests/get_object.rb +96 -0
  444. data/lib/fog/storage/google_xml/requests/get_object_acl.rb +62 -0
  445. data/lib/fog/storage/google_xml/requests/get_object_http_url.rb +37 -0
  446. data/lib/fog/storage/google_xml/requests/get_object_https_url.rb +37 -0
  447. data/lib/fog/storage/google_xml/requests/get_object_url.rb +31 -0
  448. data/lib/fog/storage/google_xml/requests/get_service.rb +44 -0
  449. data/lib/fog/storage/google_xml/requests/head_object.rb +55 -0
  450. data/lib/fog/storage/google_xml/requests/put_bucket.rb +71 -0
  451. data/lib/fog/storage/google_xml/requests/put_bucket_acl.rb +58 -0
  452. data/lib/fog/storage/google_xml/requests/put_object.rb +85 -0
  453. data/lib/fog/storage/google_xml/requests/put_object_acl.rb +58 -0
  454. data/lib/fog/storage/google_xml/requests/put_object_url.rb +42 -0
  455. data/lib/fog/storage/google_xml/utils.rb +83 -0
  456. data/tasks/bundler.rake +3 -0
  457. data/tasks/changelog.rake +39 -0
  458. data/tasks/console.rake +17 -0
  459. data/tasks/lint.rake +9 -0
  460. data/tasks/test.rake +115 -0
  461. data/test/helpers/client_helper.rb +63 -0
  462. data/test/helpers/integration_test_helper.rb +108 -0
  463. data/test/helpers/test_collection.rb +60 -0
  464. data/test/helpers/test_helper.rb +24 -0
  465. data/test/integration/compute/core_compute/test_client_options.rb +12 -0
  466. data/test/integration/compute/core_compute/test_coverage.rb +6 -0
  467. data/test/integration/compute/core_compute/test_disk_types.rb +43 -0
  468. data/test/integration/compute/core_compute/test_disks.rb +53 -0
  469. data/test/integration/compute/core_compute/test_images.rb +32 -0
  470. data/test/integration/compute/core_compute/test_machine_types.rb +55 -0
  471. data/test/integration/compute/core_compute/test_operations.rb +45 -0
  472. data/test/integration/compute/core_compute/test_projects.rb +19 -0
  473. data/test/integration/compute/core_compute/test_regions.rb +33 -0
  474. data/test/integration/compute/core_compute/test_servers.rb +149 -0
  475. data/test/integration/compute/core_compute/test_snapshots.rb +21 -0
  476. data/test/integration/compute/core_compute/test_zones.rb +35 -0
  477. data/test/integration/compute/core_networking/test_addresses.rb +107 -0
  478. data/test/integration/compute/core_networking/test_coverage.rb +6 -0
  479. data/test/integration/compute/core_networking/test_firewalls.rb +11 -0
  480. data/test/integration/compute/core_networking/test_networks.rb +41 -0
  481. data/test/integration/compute/core_networking/test_routes.rb +26 -0
  482. data/test/integration/compute/core_networking/test_subnetworks.rb +11 -0
  483. data/test/integration/compute/instance_groups/test_coverage.rb +6 -0
  484. data/test/integration/compute/instance_groups/test_instance_group_managers.rb +11 -0
  485. data/test/integration/compute/instance_groups/test_instance_groups.rb +11 -0
  486. data/test/integration/compute/instance_groups/test_instance_templates.rb +11 -0
  487. data/test/integration/compute/loadbalancing/test_backend_services.rb +11 -0
  488. data/test/integration/compute/loadbalancing/test_coverage.rb +6 -0
  489. data/test/integration/compute/loadbalancing/test_forwarding_rules.rb +11 -0
  490. data/test/integration/compute/loadbalancing/test_global_addresses.rb +11 -0
  491. data/test/integration/compute/loadbalancing/test_global_forwarding_rules.rb +11 -0
  492. data/test/integration/compute/loadbalancing/test_http_health_checks.rb +11 -0
  493. data/test/integration/compute/loadbalancing/test_ssl_certificates.rb +11 -0
  494. data/test/integration/compute/loadbalancing/test_target_http_proxies.rb +11 -0
  495. data/test/integration/compute/loadbalancing/test_target_https_proxies.rb +11 -0
  496. data/test/integration/compute/loadbalancing/test_target_instances.rb +11 -0
  497. data/test/integration/compute/loadbalancing/test_target_pools.rb +55 -0
  498. data/test/integration/compute/loadbalancing/test_url_maps.rb +11 -0
  499. data/test/integration/factories/addresses_factory.rb +20 -0
  500. data/test/integration/factories/backend_services_factory.rb +19 -0
  501. data/test/integration/factories/collection_factory.rb +52 -0
  502. data/test/integration/factories/disks_factory.rb +22 -0
  503. data/test/integration/factories/firewalls_factory.rb +13 -0
  504. data/test/integration/factories/forwarding_rules_factory.rb +25 -0
  505. data/test/integration/factories/global_addresses_factory.rb +15 -0
  506. data/test/integration/factories/global_forwarding_rules_factory.rb +20 -0
  507. data/test/integration/factories/http_health_checks_factory.rb +11 -0
  508. data/test/integration/factories/images_factory.rb +16 -0
  509. data/test/integration/factories/instance_group_manager_factory.rb +30 -0
  510. data/test/integration/factories/instance_groups_factory.rb +20 -0
  511. data/test/integration/factories/instance_template_factory.rb +24 -0
  512. data/test/integration/factories/networks_factory.rb +16 -0
  513. data/test/integration/factories/servers_factory.rb +30 -0
  514. data/test/integration/factories/sql_certs_factory.rb +20 -0
  515. data/test/integration/factories/sql_instances_factory.rb +19 -0
  516. data/test/integration/factories/sql_users_factory.rb +23 -0
  517. data/test/integration/factories/ssl_certificates_factory.rb +13 -0
  518. data/test/integration/factories/subnetworks_factory.rb +26 -0
  519. data/test/integration/factories/target_http_proxies_factory.rb +19 -0
  520. data/test/integration/factories/target_https_proxies_factory.rb +26 -0
  521. data/test/integration/factories/target_instances_factory.rb +24 -0
  522. data/test/integration/factories/target_pools_factory.rb +28 -0
  523. data/test/integration/factories/url_maps_factory.rb +19 -0
  524. data/test/integration/monitoring/test_coverage.rb +6 -0
  525. data/test/integration/monitoring/test_metric_descriptors.rb +131 -0
  526. data/test/integration/monitoring/test_monitored_resource_descriptors.rb +37 -0
  527. data/test/integration/monitoring/test_timeseries.rb +238 -0
  528. data/test/integration/pubsub/pubsub_shared.rb +75 -0
  529. data/test/integration/pubsub/test_coverage.rb +6 -0
  530. data/test/integration/pubsub/test_pubsub_models.rb +135 -0
  531. data/test/integration/pubsub/test_pubsub_requests.rb +105 -0
  532. data/test/integration/sql/test_certs.rb +50 -0
  533. data/test/integration/sql/test_common_flags.rb +31 -0
  534. data/test/integration/sql/test_common_tiers.rb +26 -0
  535. data/test/integration/sql/test_coverage.rb +6 -0
  536. data/test/integration/sql/test_instances.rb +101 -0
  537. data/test/integration/sql/test_users.rb +37 -0
  538. data/test/integration/storage/storage_shared.rb +96 -0
  539. data/test/integration/storage/test_buckets.rb +112 -0
  540. data/test/integration/storage/test_coverage.rb +6 -0
  541. data/test/integration/storage/test_directories.rb +67 -0
  542. data/test/integration/storage/test_files.rb +168 -0
  543. data/test/integration/storage/test_objects.rb +203 -0
  544. data/test/integration/test_authentication.rb +38 -0
  545. data/test/unit/compute/test_common_collections.rb +42 -0
  546. data/test/unit/compute/test_common_models.rb +35 -0
  547. data/test/unit/compute/test_server.rb +29 -0
  548. data/test/unit/dns/test_common_collections.rb +43 -0
  549. data/test/unit/monitoring/test_comon_collections.rb +44 -0
  550. data/test/unit/pubsub/test_common_collections.rb +35 -0
  551. data/test/unit/sql/test_common_collections.rb +46 -0
  552. data/test/unit/storage/test_common_json_collections.rb +38 -0
  553. data/test/unit/storage/test_common_xml_collections.rb +50 -0
  554. data/test/unit/storage/test_json_requests.rb +44 -0
  555. data/test/unit/storage/test_xml_requests.rb +60 -0
  556. metadata +897 -0
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Networks < Fog::Collection
5
+ model Fog::Compute::Google::Network
6
+
7
+ def all
8
+ data = service.list_networks.to_h[:items]
9
+ load(data || [])
10
+ end
11
+
12
+ def get(identity)
13
+ if identity
14
+ network = service.get_network(identity).to_h
15
+ return new(network)
16
+ end
17
+ rescue ::Google::Apis::ClientError => e
18
+ raise e unless e.status_code == 404
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,73 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Operation < Fog::Model
5
+ identity :name
6
+
7
+ attribute :kind
8
+ attribute :id
9
+ attribute :client_operation_id, :aliases => "clientOperationId"
10
+ attribute :creation_timestamp, :aliases => "creationTimestamp"
11
+ attribute :end_time, :aliases => "endTime"
12
+ attribute :error
13
+ attribute :http_error_message, :aliases => "httpErrorMessage"
14
+ attribute :http_error_status_code, :aliases => "httpErrorStatusCode"
15
+ attribute :insert_time, :aliases => "insertTime"
16
+ attribute :operation_type, :aliases => "operationType"
17
+ attribute :progress
18
+ attribute :region
19
+ attribute :self_link, :aliases => "selfLink"
20
+ attribute :start_time, :aliases => "startTime"
21
+ attribute :status
22
+ attribute :status_message, :aliases => "statusMessage"
23
+ attribute :target_id, :aliases => "targetId"
24
+ attribute :target_link, :aliases => "targetLink"
25
+ attribute :user
26
+ attribute :warnings
27
+ attribute :zone
28
+
29
+ def ready?
30
+ status == DONE_STATE
31
+ end
32
+
33
+ def pending?
34
+ status == PENDING_STATE
35
+ end
36
+
37
+ def region_name
38
+ region.nil? ? nil : region.split("/")[-1]
39
+ end
40
+
41
+ def zone_name
42
+ zone.nil? ? nil : zone.split("/")[-1]
43
+ end
44
+
45
+ def destroy
46
+ requires :identity
47
+
48
+ if zone
49
+ service.delete_zone_operation(zone, identity)
50
+ elsif region
51
+ service.delete_region_operation(region, identity)
52
+ else
53
+ service.delete_global_operation(identity)
54
+ end
55
+ true
56
+ end
57
+
58
+ def reload
59
+ requires :identity
60
+
61
+ data = collection.get(identity, zone, region)
62
+ new_attributes = data.attributes
63
+ merge_attributes(new_attributes)
64
+ self
65
+ end
66
+
67
+ PENDING_STATE = "PENDING".freeze
68
+ RUNNING_STATE = "RUNNING".freeze
69
+ DONE_STATE = "DONE".freeze
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Operations < Fog::Collection
5
+ model Fog::Compute::Google::Operation
6
+
7
+ def all(zone: nil, region: nil, filter: nil, max_results: nil,
8
+ order_by: nil, page_token: nil)
9
+ opts = {
10
+ :filter => filter,
11
+ :max_results => max_results,
12
+ :order_by => order_by,
13
+ :page_token => page_token
14
+ }
15
+
16
+ if zone
17
+ data = service.list_zone_operations(zone, opts).to_h[:items]
18
+ elsif region
19
+ data = service.list_region_operations(region, opts).to_h[:items]
20
+ else
21
+ data = service.list_global_operations(opts).to_h[:items]
22
+ end
23
+
24
+ load(data || [])
25
+ end
26
+
27
+ def get(identity, zone = nil, region = nil)
28
+ if !zone.nil?
29
+ operation = service.get_zone_operation(zone, identity).to_h
30
+ return new(operation)
31
+ elsif !region.nil?
32
+ operation = service.get_region_operation(region, identity).to_h
33
+ return new(operation)
34
+ elsif identity
35
+ operation = service.get_global_operation(identity).to_h
36
+ return new(operation)
37
+ end
38
+ rescue ::Google::Apis::ClientError => e
39
+ raise e unless e.status_code == 404
40
+ nil
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ ##
5
+ # Represents a Project resource
6
+ #
7
+ # @see https://developers.google.com/compute/docs/reference/latest/projects
8
+ class Project < Fog::Model
9
+ identity :name
10
+
11
+ attribute :kind
12
+ attribute :id
13
+ attribute :common_instance_metadata, :aliases => "commonInstanceMetadata"
14
+ attribute :creation_timestamp, :aliases => "creationTimestamp"
15
+ attribute :description
16
+ attribute :quotas
17
+ attribute :self_link, :aliases => "selfLink"
18
+
19
+ def set_metadata(metadata = {})
20
+ requires :identity
21
+
22
+ operation = service.set_common_instance_metadata(identity, common_instance_metadata["fingerprint"], metadata)
23
+ Fog::Compute::Google::Operations.new(:service => service).get(operation.id)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Projects < Fog::Collection
5
+ model Fog::Compute::Google::Project
6
+
7
+ def get(identity)
8
+ if identity
9
+ project = service.get_project(identity).to_h
10
+ return new(project)
11
+ end
12
+ rescue ::Google::Apis::ClientError => e
13
+ raise e unless e.status_code == 404
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ ##
5
+ # Represents a Region resource
6
+ #
7
+ # @see https://developers.google.com/compute/docs/reference/latest/regions
8
+ class Region < Fog::Model
9
+ identity :name
10
+
11
+ attribute :kind
12
+ attribute :id
13
+ attribute :creation_timestamp, :aliases => "creationTimestamp"
14
+ attribute :deprecated
15
+ attribute :description
16
+ attribute :quotas
17
+ attribute :self_link, :aliases => "selfLink"
18
+ attribute :status
19
+ attribute :zones
20
+
21
+ DOWN_STATE = "DOWN".freeze
22
+ UP_STATE = "UP".freeze
23
+
24
+ def up?
25
+ status == UP_STATE
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Regions < Fog::Collection
5
+ model Fog::Compute::Google::Region
6
+
7
+ def all
8
+ data = service.list_regions.to_h
9
+ load(data[:items] || [])
10
+ end
11
+
12
+ def get(identity)
13
+ if identity
14
+ region = service.get_region(identity).to_h
15
+ return new(region)
16
+ end
17
+ rescue ::Google::Apis::ClientError => e
18
+ raise e unless e.status_code == 404
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ ##
5
+ # Represents a Route resource
6
+ #
7
+ # @see https://developers.google.com/compute/docs/reference/latest/routes
8
+ class Route < Fog::Model
9
+ identity :name
10
+
11
+ attribute :kind
12
+ attribute :id
13
+ attribute :creation_timestamp, :aliases => "creationTimestamp"
14
+ attribute :description
15
+ attribute :dest_range, :aliases => "destRange"
16
+ attribute :network
17
+ attribute :next_hop_gateway, :aliases => "nextHopGateway"
18
+ attribute :next_hop_instance, :aliases => "nextHopInstance"
19
+ attribute :next_hop_ip, :aliases => "nextHopIp"
20
+ attribute :next_hop_network, :aliases => "nextHopNetwork"
21
+ attribute :next_hop_vpn_tunnel, :aliases => "nextHopVpnTunnel"
22
+ attribute :priority
23
+ attribute :self_link, :aliases => "selfLink"
24
+ attribute :tags
25
+ attribute :warnings
26
+
27
+ def save
28
+ requires :identity, :network, :dest_range, :priority
29
+
30
+ data = service.insert_route(identity, network, dest_range, priority, attributes)
31
+ operation = Fog::Compute::Google::Operations.new(:service => service)
32
+ .get(data.name)
33
+ operation.wait_for { ready? }
34
+ reload
35
+ end
36
+
37
+ def destroy(async = true)
38
+ requires :identity
39
+
40
+ data = service.delete_route(identity)
41
+ operation = Fog::Compute::Google::Operations.new(:service => service)
42
+ .get(data.name)
43
+ operation.wait_for { ready? } unless async
44
+ operation
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Routes < Fog::Collection
5
+ model Fog::Compute::Google::Route
6
+
7
+ def all
8
+ data = service.list_routes.to_h
9
+ load(data[:items] || [])
10
+ end
11
+
12
+ def get(identity)
13
+ if identity
14
+ route = service.get_route(identity).to_h
15
+ return new(route)
16
+ end
17
+ rescue ::Google::Apis::ClientError => e
18
+ raise e unless e.status_code == 404
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,604 @@
1
+ require "fog/compute/models/server"
2
+
3
+ module Fog
4
+ module Compute
5
+ class Google
6
+ class Server < Fog::Compute::Server
7
+ identity :name
8
+
9
+ # @return [Boolean]
10
+ attribute :can_ip_forward, :aliases => "canIpForward"
11
+
12
+ # @return [String]
13
+ attribute :cpu_platform, :aliases => "cpuPlatform"
14
+
15
+ # @return [String]
16
+ attribute :creation_timestamp, :aliases => "creationTimestamp"
17
+
18
+ # @return [Boolean]
19
+ attribute :deletion_protection, :aliases => "deletionProtection"
20
+
21
+ # @return [String]
22
+ attribute :description
23
+
24
+ # New disks may include :initialize_params before save.
25
+ #
26
+ # @example Minimal disks pre-creation:
27
+ # [
28
+ # {
29
+ # :initialize_params => {
30
+ # :source_image => "projects/debian-cloud/global/images/family/debian-9"
31
+ # }
32
+ # }
33
+ # ]
34
+ #
35
+ # @example disks post-creation:
36
+ # [
37
+ # {
38
+ # :auto_delete => false,
39
+ # :boot => true,
40
+ # :device_name => "persistent-disk-0",
41
+ # :index => 0,
42
+ # :interface => "SCSI",
43
+ # :kind => "compute#attachedDisk",
44
+ # :licenses => ["https://www.googleapis.com/compute/v1/..."],
45
+ # :mode => "READ_WRITE",
46
+ # :source => "https://www.googleapis.com/compute/v1/.../mydisk",
47
+ # :type => "PERSISTENT"
48
+ # }
49
+ # ]
50
+ # @return [Array<Hash>]
51
+ attribute :disks
52
+
53
+ # @example Guest accelerators
54
+ # [
55
+ # {
56
+ # :accelerator_count => 1,
57
+ # :accelerator_type => "...my/accelerator/type"
58
+ # }
59
+ # ]
60
+ # @return [Array<Hash>]
61
+ attribute :guest_accelerators, :aliases => "guestAccelerators"
62
+
63
+ # @return [Fixnum]
64
+ attribute :id
65
+
66
+ # @return [String]
67
+ attribute :kind
68
+
69
+ # @return [String]
70
+ attribute :label_fingerprint, :aliases => "labelFingerprint"
71
+
72
+ # @return [Hash<String,String>]
73
+ attribute :labels
74
+
75
+ # @return [String]
76
+ attribute :machine_type, :aliases => "machineType"
77
+
78
+ # If set initially before save, the expected format
79
+ # is the API format as shown below.
80
+ #
81
+ # If you want to pass in a Hash, see {#set_metadata}.
82
+ # If you want to access the metadata items as a Hash, see
83
+ # {#metadata_as_h}.
84
+ #
85
+ # @example Metadata in API format
86
+ #
87
+ # {
88
+ # :fingerprint => "...",
89
+ # :items => [
90
+ # { :key => "foo", :value => "bar" },
91
+ # ]
92
+ # }
93
+ # @return [Hash]
94
+ attribute :metadata
95
+
96
+ # @return [String]
97
+ attribute :min_cpu_platform, :aliases => "minCpuPlatform"
98
+
99
+ # @example Network interfaces
100
+ # [
101
+ # {
102
+ # :kind => "compute#networkInterface",
103
+ # :name => "nic0",
104
+ # :network => "https://www.googleapis.com/compute/v1/.../my-network/"
105
+ # :network_ip => "0.0.0.0",
106
+ # :subnetwork => "https://www.googleapis.com/compute/v1/.../my-subnetwork"
107
+ # }
108
+ # ],
109
+ # @return [Array<Hash>]
110
+ attribute :network_interfaces, :aliases => "networkInterfaces"
111
+
112
+ # @example Scheduling object
113
+ # {
114
+ # :automatic_restart => true,
115
+ # :on_host_maintenance => "MIGRATE",
116
+ # :preemptible=>false
117
+ # }
118
+ # @return [Hash]
119
+ attribute :scheduling
120
+
121
+ # @return [String]
122
+ attribute :self_link, :aliases => "selfLink"
123
+
124
+ # @example Service accounts in API format
125
+ # [
126
+ # {
127
+ # :email => "my-service-account@developer.gserviceaccount.com",
128
+ # :scopes => [],
129
+ # }
130
+ # ]
131
+ # @return [Array<Hash>]
132
+ attribute :service_accounts, :aliases => "serviceAccounts"
133
+
134
+ # @return [Boolean]
135
+ attribute :start_restricted, :aliases => "startRestricted"
136
+
137
+ # @return [String]
138
+ attribute :status, :aliases => "status"
139
+
140
+ # @return [String]
141
+ attribute :status_message, :aliases => "statusMessage"
142
+
143
+ # @example Tags in API format
144
+ # @return [Hash]
145
+ attribute :tags
146
+
147
+ # @return [String]
148
+ attribute :zone, :aliases => :zone_name
149
+
150
+ GCE_SCOPE_ALIASES = {
151
+ "default" => %w(
152
+ https://www.googleapis.com/auth/cloud.useraccounts.readonly
153
+ https://www.googleapis.com/auth/devstorage.read_only
154
+ https://www.googleapis.com/auth/logging.write
155
+ https://www.googleapis.com/auth/monitoring.write
156
+ https://www.googleapis.com/auth/pubsub
157
+ https://www.googleapis.com/auth/service.management.readonly
158
+ https://www.googleapis.com/auth/servicecontrol
159
+ https://www.googleapis.com/auth/trace.append
160
+ ),
161
+ "bigquery" => ["https://www.googleapis.com/auth/bigquery"],
162
+ "cloud-platform" => ["https://www.googleapis.com/auth/cloud-platform"],
163
+ "compute-ro" => ["https://www.googleapis.com/auth/compute.readonly"],
164
+ "compute-rw" => ["https://www.googleapis.com/auth/compute"],
165
+ "datastore" => ["https://www.googleapis.com/auth/datastore"],
166
+ "logging-write" => ["https://www.googleapis.com/auth/logging.write"],
167
+ "monitoring" => ["https://www.googleapis.com/auth/monitoring"],
168
+ "monitoring-write" => ["https://www.googleapis.com/auth/monitoring.write"],
169
+ "service-control" => ["https://www.googleapis.com/auth/servicecontrol"],
170
+ "service-management" => ["https://www.googleapis.com/auth/service.management.readonly"],
171
+ "sql" => ["https://www.googleapis.com/auth/sqlservice"],
172
+ "sql-admin" => ["https://www.googleapis.com/auth/sqlservice.admin"],
173
+ "storage-full" => ["https://www.googleapis.com/auth/devstorage.full_control"],
174
+ "storage-ro" => ["https://www.googleapis.com/auth/devstorage.read_only"],
175
+ "storage-rw" => ["https://www.googleapis.com/auth/devstorage.read_write"],
176
+ "taskqueue" => ["https://www.googleapis.com/auth/taskqueue"],
177
+ "useraccounts-ro" => ["https://www.googleapis.com/auth/cloud.useraccounts.readonly"],
178
+ "useraccounts-rw" => ["https://www.googleapis.com/auth/cloud.useraccounts"],
179
+ "userinfo-email" => ["https://www.googleapis.com/auth/userinfo.email"]
180
+ }.freeze
181
+
182
+ # Return the source image of the server's boot disk
183
+ #
184
+ # @return [String] image self link
185
+ def image_name
186
+ boot_disk = disks.first
187
+ unless boot_disk.is_a?(Disk)
188
+ source = boot_disk[:source]
189
+ match = source.match(%r{/zones/(.*)/disks/(.*)$})
190
+ boot_disk = service.disks.get(match[2], match[1])
191
+ end
192
+ boot_disk.source_image.nil? ? nil : boot_disk.source_image
193
+ end
194
+
195
+ # Destroy a server.
196
+ #
197
+ # @param async [TrueClass] execute the command asynchronously
198
+ # @return [Fog::Compute::Google::Operation]
199
+ def destroy(async = true)
200
+ requires :name, :zone
201
+
202
+ data = service.delete_server(name, zone_name)
203
+ operation = Fog::Compute::Google::Operations
204
+ .new(:service => service)
205
+ .get(data.name, data.zone)
206
+ operation.wait_for { ready? } unless async
207
+ operation
208
+ end
209
+
210
+ # Helper method that returns first public ip address needed for
211
+ # Fog::Compute::Server.ssh default behavior.
212
+ #
213
+ # @return [String]
214
+ def public_ip_address
215
+ public_ip_addresses.first
216
+ end
217
+
218
+ # Helper method that returns all of server's public ip addresses.
219
+ #
220
+ # @return [Array]
221
+ def public_ip_addresses
222
+ addresses = []
223
+ if network_interfaces.respond_to? :flat_map
224
+ addresses = network_interfaces.flat_map do |nic|
225
+ if nic[:access_configs].respond_to? :each
226
+ nic[:access_configs].select { |config| config[:name] == "External NAT" }
227
+ .map { |config| config[:nat_ip] }
228
+ else
229
+ []
230
+ end
231
+ end
232
+ end
233
+ addresses
234
+ end
235
+
236
+ # Helper method that returns the first private ip address of the
237
+ # instance.
238
+ #
239
+ # @return [String]
240
+ def private_ip_address
241
+ private_ip_addresses.first
242
+ end
243
+
244
+ # Helper method that returns all of server's private ip addresses.
245
+ #
246
+ # @return [Array]
247
+ def private_ip_addresses
248
+ addresses = []
249
+ if network_interfaces.respond_to? :map
250
+ addresses = network_interfaces.map { |nic| nic[:network_ip] }
251
+ end
252
+ addresses
253
+ end
254
+
255
+ # Helper method that returns all of server's ip addresses,
256
+ # both private and public.
257
+ #
258
+ # @return [Array]
259
+ def addresses
260
+ private_ip_addresses + public_ip_addresses
261
+ end
262
+
263
+ # Attach a disk to a running server
264
+ #
265
+ # @param disk [Object, String] disk object or a self-link
266
+ # @param async [TrueClass] execute the api call asynchronously
267
+ # @param options [Hash]
268
+ # @return [Object]
269
+ def attach_disk(disk, async = true, attached_disk_options = {})
270
+ requires :identity, :zone
271
+
272
+ if disk.is_a? Disk
273
+ disk_obj = disk.get_attached_disk
274
+ elsif disk.is_a? String
275
+ disk_obj = service.disks.attached_disk_obj(disk, attached_disk_options)
276
+ end
277
+
278
+ data = service.attach_disk(identity, zone_name, disk_obj)
279
+ operation = Fog::Compute::Google::Operations
280
+ .new(:service => service)
281
+ .get(data.name, data.zone)
282
+ operation.wait_for { ready? } unless async
283
+ reload
284
+ end
285
+
286
+ # Detach disk from a running instance
287
+ #
288
+ # @param device_name [Object]
289
+ # @param async [TrueClass]
290
+ # @returns [Fog::Compute::Google::Server] server object
291
+ def detach_disk(device_name, async = true)
292
+ requires :identity, :zone
293
+
294
+ data = service.detach_disk(identity, zone, device_name)
295
+ operation = Fog::Compute::Google::Operations
296
+ .new(:service => service)
297
+ .get(data.name, data.zone)
298
+ operation.wait_for { ready? } unless async
299
+ reload
300
+ end
301
+
302
+ # Returns metadata items as a Hash.
303
+ #
304
+ # @return [Hash<String, String>] items
305
+ def metadata_as_h
306
+ if metadata.nil? || metadata[:items].nil? || metadata[:items].empty?
307
+ return {}
308
+ end
309
+
310
+ Hash[metadata[:items].map { |item| [item[:key], item[:value]] }]
311
+ end
312
+
313
+ def reboot(async = true)
314
+ requires :identity, :zone
315
+
316
+ data = service.reset_server(identity, zone_name)
317
+ operation = Fog::Compute::Google::Operations
318
+ .new(:service => service)
319
+ .get(data.name, data.zone)
320
+ operation.wait_for { ready? } unless async
321
+ operation
322
+ end
323
+
324
+ def start(async = true)
325
+ requires :identity, :zone
326
+
327
+ data = service.start_server(identity, zone_name)
328
+ operation = Fog::Compute::Google::Operations
329
+ .new(:service => service)
330
+ .get(data.name, data.zone)
331
+ operation.wait_for { ready? } unless async
332
+ operation
333
+ end
334
+
335
+ def stop(async = true)
336
+ requires :identity, :zone
337
+
338
+ data = service.stop_server(identity, zone_name)
339
+ operation = Fog::Compute::Google::Operations
340
+ .new(:service => service)
341
+ .get(data.name, data.zone)
342
+ operation.wait_for { ready? } unless async
343
+ operation
344
+ end
345
+
346
+ def serial_port_output(port: 1)
347
+ requires :identity, :zone
348
+
349
+ service.get_server_serial_port_output(identity, zone_name, :port => port).to_h[:contents]
350
+ end
351
+
352
+ def set_disk_auto_delete(auto_delete, device_name = nil, async = true)
353
+ requires :identity, :zone
354
+
355
+ if device_name.nil? && disks.count > 1
356
+ raise ArgumentError.new("Device name is required if multiple disks are attached")
357
+ end
358
+
359
+ device_name ||= disks.first[:device_name]
360
+ data = service.set_server_disk_auto_delete(
361
+ identity, zone_name, auto_delete, device_name
362
+ )
363
+
364
+ operation = Fog::Compute::Google::Operations
365
+ .new(:service => service)
366
+ .get(data.name, data.zone)
367
+ operation.wait_for { ready? } unless async
368
+ reload
369
+ end
370
+
371
+ def set_scheduling(async = true,
372
+ on_host_maintenance: nil,
373
+ automatic_restart: nil,
374
+ preemptible: nil)
375
+ requires :identity, :zone
376
+ data = service.set_server_scheduling(
377
+ identity, zone_name,
378
+ :on_host_maintenance => on_host_maintenance,
379
+ :automatic_restart => automatic_restart,
380
+ :preemptible => preemptible
381
+ )
382
+
383
+ operation = Fog::Compute::Google::Operations
384
+ .new(:service => service)
385
+ .get(data.name, data.zone)
386
+ operation.wait_for { ready? } unless async
387
+ reload
388
+ end
389
+
390
+ # Set an instance metadata
391
+ #
392
+ # @param [Bool] async Perform the operation asyncronously
393
+ # @param [Hash] new_metadata A new metadata object
394
+ # Format: {'foo' => 'bar', 'baz'=>'foo'}
395
+ #
396
+ # @returns [Fog::Compute::Google::Server] server object
397
+ def set_metadata(new_metadata = {}, async = true)
398
+ requires :identity, :zone
399
+
400
+ unless new_metadata.is_a?(Hash)
401
+ raise Fog::Errors::Error.new("Instance metadata should be a hash")
402
+ end
403
+
404
+ # If metadata is presented in {'foo' => 'bar', 'baz'=>'foo'}
405
+ new_metadata_items = new_metadata.each.map { |k, v| { :key => k.to_s, :value => v.to_s } }
406
+
407
+ data = service.set_server_metadata(
408
+ identity, zone_name, metadata[:fingerprint], new_metadata_items
409
+ )
410
+ operation = Fog::Compute::Google::Operations
411
+ .new(:service => service)
412
+ .get(data.name, data.zone)
413
+ operation.wait_for { ready? } unless async
414
+ reload
415
+ end
416
+
417
+ def set_machine_type(new_machine_type, async = true)
418
+ requires :identity, :zone
419
+
420
+ raise Fog::Errors::Error.new("Instance must be stopped to change machine type") unless stopped?
421
+
422
+ data = service.set_server_machine_type(
423
+ identity, zone_name, new_machine_type
424
+ )
425
+ operation = Fog::Compute::Google::Operations
426
+ .new(:service => service)
427
+ .get(data.name, data.zone)
428
+ operation.wait_for { ready? } unless async
429
+ reload
430
+ end
431
+
432
+ def set_tags(new_tags = [], async = true)
433
+ requires :identity, :zone
434
+
435
+ data = service.set_server_tags(
436
+ identity, zone_name, tags[:fingerprint], new_tags
437
+ )
438
+ operation = Fog::Compute::Google::Operations
439
+ .new(:service => service)
440
+ .get(data.name, data.zone)
441
+ operation.wait_for { ready? } unless async
442
+ reload
443
+ end
444
+
445
+ # Check if instance is provisioning. On staging vs. provisioning difference:
446
+ # https://cloud.google.com/compute/docs/instances/checking-instance-status
447
+ #
448
+ # @return [TrueClass or FalseClass]
449
+ def provisioning?
450
+ status == "PROVISIONING"
451
+ end
452
+
453
+ # Check if instance is staging. On staging vs. provisioning difference:
454
+ # https://cloud.google.com/compute/docs/instances/checking-instance-status
455
+ #
456
+ # @return [TrueClass or FalseClass]
457
+ def staging?
458
+ status == "STAGING"
459
+ end
460
+
461
+ # Check if instance is stopped.
462
+ #
463
+ # @return [TrueClass or FalseClass]
464
+ def stopped?
465
+ status == "TERMINATED"
466
+ end
467
+
468
+ # Check if instance is ready.
469
+ #
470
+ # @return [TrueClass or FalseClass]
471
+ def ready?
472
+ status == "RUNNING"
473
+ end
474
+
475
+ def zone_name
476
+ zone.nil? ? nil : zone.split("/")[-1]
477
+ end
478
+
479
+ def add_ssh_key(username, key, async = true)
480
+ metadata = generate_ssh_key_metadata(username, key)
481
+
482
+ data = service.set_server_metadata(
483
+ identity, zone_name, metadata[:fingerprint], metadata[:items]
484
+ )
485
+
486
+ operation = Fog::Compute::Google::Operations
487
+ .new(:service => service)
488
+ .get(data.name, data.zone)
489
+ operation.wait_for { ready? } unless async
490
+ reload
491
+ end
492
+
493
+ def reload
494
+ data = service.get_server(name, zone_name).to_h
495
+ merge_attributes(data)
496
+ end
497
+
498
+ def map_scopes(scopes)
499
+ return [] if scopes.nil?
500
+ scopes.flat_map do |scope|
501
+ if GCE_SCOPE_ALIASES.key? scope
502
+ # Expand scope alias to list of related scopes
503
+ GCE_SCOPE_ALIASES[scope]
504
+ else
505
+ [scope_url(scope)]
506
+ end
507
+ end
508
+ end
509
+
510
+ def save(username: nil, public_key: nil)
511
+ requires :name
512
+ requires :machine_type
513
+ requires :disks
514
+ requires :zone
515
+
516
+ generate_ssh_key_metadata(self.username, self.public_key) if self.public_key
517
+
518
+ # XXX HACK This is a relic of 1.0 change that for some reason added those arguments
519
+ # to `save` method. This is left in place to keep things backwards-compatible
520
+ # TODO(2.0): Remove arguments from save
521
+ generate_ssh_key_metadata(username, public_key) if public_key
522
+
523
+ options = attributes.reject { |_, v| v.nil? }
524
+
525
+ if service_accounts && service_accounts[0]
526
+ service_accounts[0][:scopes] = map_scopes(service_accounts[0][:scopes])
527
+ options[:service_accounts] = service_accounts
528
+ end
529
+
530
+ if attributes[:external_ip]
531
+ if options[:network_interfaces].nil? || options[:network_interfaces].empty?
532
+ options[:network_interfaces] = [
533
+ {
534
+ :network => "global/networks/#{GOOGLE_COMPUTE_DEFAULT_NETWORK}"
535
+ }
536
+ ]
537
+ end
538
+
539
+ # Add external IP as default access config if given
540
+ options[:network_interfaces][0][:access_configs] = [
541
+ {
542
+ :name => "External NAT",
543
+ :type => "ONE_TO_ONE_NAT",
544
+ :nat_ip => attributes[:external_ip]
545
+ }
546
+ ]
547
+ end
548
+
549
+ if attributes[:network_ip]
550
+ options[:network_interfaces][0][:network_ip] = attributes[:network_ip]
551
+ end
552
+
553
+ data = service.insert_server(name, zone_name, options)
554
+
555
+ operation = Fog::Compute::Google::Operations
556
+ .new(:service => service)
557
+ .get(data.name, data.zone)
558
+ operation.wait_for { ready? }
559
+ reload
560
+ end
561
+
562
+ def generate_ssh_key_metadata(username, key)
563
+ if metadata.nil?
564
+ self.metadata = Hash.new
565
+ end
566
+ metadata[:items] = [] if metadata[:items].nil?
567
+ metadata_map = Hash[metadata[:items].map { |item| [item[:key], item[:value]] }]
568
+
569
+ ssh_keys = metadata_map["ssh-keys"] || metadata_map["sshKeys"] || ""
570
+ ssh_keys += "\n" unless ssh_keys.empty?
571
+ ssh_keys += "#{username}:#{ensure_key_comment(key, username)}"
572
+
573
+ metadata_map["ssh-keys"] = ssh_keys
574
+ metadata[:items] = metadata_to_item_list(metadata_map)
575
+ metadata
576
+ end
577
+
578
+ def ensure_key_comment(key, default_comment = "fog-user")
579
+ parts = key.strip.split
580
+ parts << default_comment if parts.size < 3
581
+ parts.join(" ")
582
+ end
583
+
584
+ def reset_windows_password(user)
585
+ service.reset_windows_password(:server => self, :user => user)
586
+ end
587
+
588
+ private
589
+
590
+ def metadata_to_item_list(metadata)
591
+ metadata.map { |k, v| { :key => k, :value => v } }
592
+ end
593
+
594
+ def scope_url(scope)
595
+ if scope.start_with?("https://")
596
+ scope
597
+ else
598
+ "https://www.googleapis.com/auth/#{scope}"
599
+ end
600
+ end
601
+ end
602
+ end
603
+ end
604
+ end