fog-google 1.8.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +5 -5
  2. data/.fog.example +1 -3
  3. data/.rubocop.yml +3 -3
  4. data/.travis.yml +5 -3
  5. data/CHANGELOG.md +126 -2
  6. data/CONTRIBUTING.md +0 -1
  7. data/README.md +59 -8
  8. data/SECURITY.md +16 -0
  9. data/ci/README.md +8 -8
  10. data/ci/build-head-pipeline.yml +173 -0
  11. data/ci/credentials.yml.template +0 -2
  12. data/ci/docker-image/Dockerfile +3 -3
  13. data/ci/{pipeline.yml → integration-pipeline.yml} +0 -33
  14. data/ci/pipeline-dev.yml +58 -0
  15. data/ci/tasks/run-int.sh +20 -3
  16. data/ci/tasks/run-int.yml +3 -1
  17. data/examples/sql/flags.rb +10 -6
  18. data/examples/sql/instances.rb +38 -34
  19. data/examples/sql/operations.rb +20 -16
  20. data/examples/sql/ssl_certs.rb +32 -28
  21. data/examples/sql/tiers.rb +10 -6
  22. data/fog-google.gemspec +3 -3
  23. data/lib/fog/compute/google.rb +5 -5
  24. data/lib/fog/compute/google/mock.rb +2 -1
  25. data/lib/fog/compute/google/models/address.rb +15 -2
  26. data/lib/fog/compute/google/models/disk.rb +6 -2
  27. data/lib/fog/compute/google/models/images.rb +6 -1
  28. data/lib/fog/compute/google/models/instance_groups.rb +2 -2
  29. data/lib/fog/compute/google/models/server.rb +33 -9
  30. data/lib/fog/compute/google/real.rb +2 -1
  31. data/lib/fog/compute/google/requests/abandon_instances.rb +2 -0
  32. data/lib/fog/compute/google/requests/add_backend_service_backends.rb +2 -0
  33. data/lib/fog/compute/google/requests/add_instance_group_instances.rb +2 -0
  34. data/lib/fog/compute/google/requests/add_server_access_config.rb +2 -0
  35. data/lib/fog/compute/google/requests/add_target_pool_health_checks.rb +2 -0
  36. data/lib/fog/compute/google/requests/add_target_pool_instances.rb +2 -0
  37. data/lib/fog/compute/google/requests/attach_disk.rb +2 -0
  38. data/lib/fog/compute/google/requests/create_disk_snapshot.rb +2 -0
  39. data/lib/fog/compute/google/requests/delete_address.rb +2 -0
  40. data/lib/fog/compute/google/requests/delete_backend_service.rb +2 -0
  41. data/lib/fog/compute/google/requests/delete_disk.rb +2 -0
  42. data/lib/fog/compute/google/requests/delete_firewall.rb +2 -0
  43. data/lib/fog/compute/google/requests/delete_forwarding_rule.rb +2 -0
  44. data/lib/fog/compute/google/requests/delete_global_address.rb +2 -0
  45. data/lib/fog/compute/google/requests/delete_global_forwarding_rule.rb +2 -0
  46. data/lib/fog/compute/google/requests/delete_global_operation.rb +2 -0
  47. data/lib/fog/compute/google/requests/delete_http_health_check.rb +2 -0
  48. data/lib/fog/compute/google/requests/delete_image.rb +2 -0
  49. data/lib/fog/compute/google/requests/delete_instance_group.rb +2 -0
  50. data/lib/fog/compute/google/requests/delete_instance_group_manager.rb +2 -0
  51. data/lib/fog/compute/google/requests/delete_instance_template.rb +2 -0
  52. data/lib/fog/compute/google/requests/delete_network.rb +2 -0
  53. data/lib/fog/compute/google/requests/delete_region_operation.rb +2 -0
  54. data/lib/fog/compute/google/requests/delete_route.rb +2 -0
  55. data/lib/fog/compute/google/requests/delete_server.rb +2 -0
  56. data/lib/fog/compute/google/requests/delete_server_access_config.rb +2 -0
  57. data/lib/fog/compute/google/requests/delete_snapshot.rb +2 -0
  58. data/lib/fog/compute/google/requests/delete_ssl_certificate.rb +2 -0
  59. data/lib/fog/compute/google/requests/delete_subnetwork.rb +2 -0
  60. data/lib/fog/compute/google/requests/delete_target_http_proxy.rb +2 -0
  61. data/lib/fog/compute/google/requests/delete_target_https_proxy.rb +2 -0
  62. data/lib/fog/compute/google/requests/delete_target_instance.rb +2 -0
  63. data/lib/fog/compute/google/requests/delete_target_pool.rb +2 -0
  64. data/lib/fog/compute/google/requests/delete_url_map.rb +2 -0
  65. data/lib/fog/compute/google/requests/delete_zone_operation.rb +2 -0
  66. data/lib/fog/compute/google/requests/deprecate_image.rb +2 -0
  67. data/lib/fog/compute/google/requests/detach_disk.rb +2 -0
  68. data/lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb +2 -0
  69. data/lib/fog/compute/google/requests/get_address.rb +2 -0
  70. data/lib/fog/compute/google/requests/get_backend_service_health.rb +2 -0
  71. data/lib/fog/compute/google/requests/get_disk.rb +2 -0
  72. data/lib/fog/compute/google/requests/get_disk_type.rb +2 -0
  73. data/lib/fog/compute/google/requests/get_firewall.rb +2 -0
  74. data/lib/fog/compute/google/requests/get_forwarding_rule.rb +2 -0
  75. data/lib/fog/compute/google/requests/get_global_address.rb +2 -0
  76. data/lib/fog/compute/google/requests/get_global_forwarding_rule.rb +2 -0
  77. data/lib/fog/compute/google/requests/get_global_operation.rb +2 -0
  78. data/lib/fog/compute/google/requests/get_http_health_check.rb +2 -0
  79. data/lib/fog/compute/google/requests/get_image.rb +2 -0
  80. data/lib/fog/compute/google/requests/get_image_from_family.rb +2 -0
  81. data/lib/fog/compute/google/requests/get_instance_group.rb +2 -0
  82. data/lib/fog/compute/google/requests/get_instance_group_manager.rb +2 -0
  83. data/lib/fog/compute/google/requests/get_instance_template.rb +2 -0
  84. data/lib/fog/compute/google/requests/get_machine_type.rb +2 -0
  85. data/lib/fog/compute/google/requests/get_network.rb +2 -0
  86. data/lib/fog/compute/google/requests/get_project.rb +2 -0
  87. data/lib/fog/compute/google/requests/get_region.rb +2 -0
  88. data/lib/fog/compute/google/requests/get_route.rb +2 -0
  89. data/lib/fog/compute/google/requests/get_server.rb +2 -0
  90. data/lib/fog/compute/google/requests/get_server_serial_port_output.rb +2 -0
  91. data/lib/fog/compute/google/requests/get_snapshot.rb +2 -0
  92. data/lib/fog/compute/google/requests/get_ssl_certificate.rb +2 -0
  93. data/lib/fog/compute/google/requests/get_subnetwork.rb +2 -0
  94. data/lib/fog/compute/google/requests/get_target_http_proxy.rb +2 -0
  95. data/lib/fog/compute/google/requests/get_target_https_proxy.rb +2 -0
  96. data/lib/fog/compute/google/requests/get_target_instance.rb +2 -0
  97. data/lib/fog/compute/google/requests/get_target_pool.rb +2 -0
  98. data/lib/fog/compute/google/requests/get_target_pool_health.rb +2 -0
  99. data/lib/fog/compute/google/requests/get_url_map.rb +2 -0
  100. data/lib/fog/compute/google/requests/get_zone.rb +2 -0
  101. data/lib/fog/compute/google/requests/get_zone_operation.rb +2 -0
  102. data/lib/fog/compute/google/requests/insert_address.rb +2 -0
  103. data/lib/fog/compute/google/requests/insert_backend_service.rb +2 -0
  104. data/lib/fog/compute/google/requests/insert_disk.rb +8 -5
  105. data/lib/fog/compute/google/requests/insert_firewall.rb +2 -0
  106. data/lib/fog/compute/google/requests/insert_forwarding_rule.rb +2 -0
  107. data/lib/fog/compute/google/requests/insert_global_address.rb +2 -0
  108. data/lib/fog/compute/google/requests/insert_global_forwarding_rule.rb +2 -0
  109. data/lib/fog/compute/google/requests/insert_http_health_check.rb +2 -0
  110. data/lib/fog/compute/google/requests/insert_image.rb +2 -0
  111. data/lib/fog/compute/google/requests/insert_instance_group.rb +2 -0
  112. data/lib/fog/compute/google/requests/insert_instance_group_manager.rb +2 -0
  113. data/lib/fog/compute/google/requests/insert_instance_template.rb +2 -0
  114. data/lib/fog/compute/google/requests/insert_network.rb +2 -0
  115. data/lib/fog/compute/google/requests/insert_route.rb +2 -0
  116. data/lib/fog/compute/google/requests/insert_server.rb +6 -0
  117. data/lib/fog/compute/google/requests/insert_ssl_certificate.rb +2 -0
  118. data/lib/fog/compute/google/requests/insert_subnetwork.rb +2 -0
  119. data/lib/fog/compute/google/requests/insert_target_http_proxy.rb +2 -0
  120. data/lib/fog/compute/google/requests/insert_target_https_proxy.rb +2 -0
  121. data/lib/fog/compute/google/requests/insert_target_instance.rb +2 -0
  122. data/lib/fog/compute/google/requests/insert_target_pool.rb +2 -0
  123. data/lib/fog/compute/google/requests/insert_url_map.rb +2 -0
  124. data/lib/fog/compute/google/requests/invalidate_url_map_cache.rb +2 -0
  125. data/lib/fog/compute/google/requests/list_addresses.rb +2 -0
  126. data/lib/fog/compute/google/requests/list_aggregated_addresses.rb +2 -0
  127. data/lib/fog/compute/google/requests/list_aggregated_disk_types.rb +2 -0
  128. data/lib/fog/compute/google/requests/list_aggregated_disks.rb +2 -0
  129. data/lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb +2 -0
  130. data/lib/fog/compute/google/requests/list_aggregated_instance_group_managers.rb +2 -0
  131. data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +2 -0
  132. data/lib/fog/compute/google/requests/list_aggregated_machine_types.rb +2 -0
  133. data/lib/fog/compute/google/requests/list_aggregated_servers.rb +2 -0
  134. data/lib/fog/compute/google/requests/list_aggregated_subnetworks.rb +2 -0
  135. data/lib/fog/compute/google/requests/list_aggregated_target_instances.rb +2 -0
  136. data/lib/fog/compute/google/requests/list_aggregated_target_pools.rb +2 -0
  137. data/lib/fog/compute/google/requests/list_disk_types.rb +2 -0
  138. data/lib/fog/compute/google/requests/list_disks.rb +2 -0
  139. data/lib/fog/compute/google/requests/list_firewalls.rb +2 -0
  140. data/lib/fog/compute/google/requests/list_forwarding_rules.rb +2 -0
  141. data/lib/fog/compute/google/requests/list_global_addresses.rb +2 -0
  142. data/lib/fog/compute/google/requests/list_global_forwarding_rules.rb +2 -0
  143. data/lib/fog/compute/google/requests/list_global_operations.rb +2 -0
  144. data/lib/fog/compute/google/requests/list_http_health_checks.rb +2 -0
  145. data/lib/fog/compute/google/requests/list_images.rb +2 -0
  146. data/lib/fog/compute/google/requests/list_instance_group_instances.rb +2 -0
  147. data/lib/fog/compute/google/requests/list_instance_group_managers.rb +2 -0
  148. data/lib/fog/compute/google/requests/list_instance_groups.rb +2 -0
  149. data/lib/fog/compute/google/requests/list_instance_templates.rb +2 -0
  150. data/lib/fog/compute/google/requests/list_machine_types.rb +2 -0
  151. data/lib/fog/compute/google/requests/list_networks.rb +2 -0
  152. data/lib/fog/compute/google/requests/list_region_operations.rb +2 -0
  153. data/lib/fog/compute/google/requests/list_regions.rb +2 -0
  154. data/lib/fog/compute/google/requests/list_routes.rb +2 -0
  155. data/lib/fog/compute/google/requests/list_servers.rb +2 -0
  156. data/lib/fog/compute/google/requests/list_snapshots.rb +2 -0
  157. data/lib/fog/compute/google/requests/list_ssl_certificates.rb +2 -0
  158. data/lib/fog/compute/google/requests/list_subnetworks.rb +2 -0
  159. data/lib/fog/compute/google/requests/list_target_http_proxies.rb +2 -0
  160. data/lib/fog/compute/google/requests/list_target_https_proxies.rb +2 -0
  161. data/lib/fog/compute/google/requests/list_target_instances.rb +2 -0
  162. data/lib/fog/compute/google/requests/list_target_pools.rb +2 -0
  163. data/lib/fog/compute/google/requests/list_url_maps.rb +2 -0
  164. data/lib/fog/compute/google/requests/list_zone_operations.rb +2 -0
  165. data/lib/fog/compute/google/requests/list_zones.rb +2 -0
  166. data/lib/fog/compute/google/requests/patch_firewall.rb +2 -0
  167. data/lib/fog/compute/google/requests/patch_url_map.rb +2 -0
  168. data/lib/fog/compute/google/requests/recreate_instances.rb +2 -0
  169. data/lib/fog/compute/google/requests/remove_instance_group_instances.rb +2 -0
  170. data/lib/fog/compute/google/requests/remove_target_pool_health_checks.rb +2 -0
  171. data/lib/fog/compute/google/requests/remove_target_pool_instance.rb +2 -0
  172. data/lib/fog/compute/google/requests/remove_target_pool_instances.rb +2 -0
  173. data/lib/fog/compute/google/requests/reset_server.rb +2 -0
  174. data/lib/fog/compute/google/requests/reset_windows_password.rb +154 -0
  175. data/lib/fog/compute/google/requests/set_common_instance_metadata.rb +2 -0
  176. data/lib/fog/compute/google/requests/set_forwarding_rule_target.rb +2 -0
  177. data/lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb +2 -0
  178. data/lib/fog/compute/google/requests/set_instance_template.rb +2 -0
  179. data/lib/fog/compute/google/requests/set_server_disk_auto_delete.rb +2 -0
  180. data/lib/fog/compute/google/requests/set_server_machine_type.rb +23 -0
  181. data/lib/fog/compute/google/requests/set_server_metadata.rb +3 -1
  182. data/lib/fog/compute/google/requests/set_server_scheduling.rb +2 -0
  183. data/lib/fog/compute/google/requests/set_server_tags.rb +2 -0
  184. data/lib/fog/compute/google/requests/set_snapshot_labels.rb +2 -0
  185. data/lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb +2 -0
  186. data/lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb +2 -0
  187. data/lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb +2 -0
  188. data/lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb +2 -0
  189. data/lib/fog/compute/google/requests/set_target_pool_backup.rb +2 -0
  190. data/lib/fog/compute/google/requests/start_server.rb +2 -0
  191. data/lib/fog/compute/google/requests/stop_server.rb +2 -0
  192. data/lib/fog/compute/google/requests/update_firewall.rb +2 -0
  193. data/lib/fog/compute/google/requests/update_http_health_check.rb +2 -0
  194. data/lib/fog/compute/google/requests/update_url_map.rb +2 -0
  195. data/lib/fog/compute/google/requests/validate_url_map.rb +2 -0
  196. data/lib/fog/dns/google.rb +1 -1
  197. data/lib/fog/dns/google/requests/create_change.rb +2 -0
  198. data/lib/fog/dns/google/requests/create_managed_zone.rb +2 -0
  199. data/lib/fog/dns/google/requests/delete_managed_zone.rb +2 -0
  200. data/lib/fog/dns/google/requests/get_change.rb +2 -0
  201. data/lib/fog/dns/google/requests/get_managed_zone.rb +2 -0
  202. data/lib/fog/dns/google/requests/get_project.rb +2 -0
  203. data/lib/fog/dns/google/requests/list_changes.rb +2 -0
  204. data/lib/fog/dns/google/requests/list_managed_zones.rb +2 -0
  205. data/lib/fog/dns/google/requests/list_resource_record_sets.rb +2 -0
  206. data/lib/fog/google/models/sql/ssl_cert.rb +7 -1
  207. data/lib/fog/google/models/sql/user.rb +2 -0
  208. data/lib/fog/google/monitoring.rb +2 -1
  209. data/lib/fog/google/pubsub.rb +1 -1
  210. data/lib/fog/google/requests/monitoring/create_metric_descriptor.rb +2 -0
  211. data/lib/fog/google/requests/monitoring/create_timeseries.rb +3 -1
  212. data/lib/fog/google/requests/monitoring/delete_metric_descriptor.rb +2 -0
  213. data/lib/fog/google/requests/monitoring/get_metric_descriptor.rb +2 -0
  214. data/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb +2 -0
  215. data/lib/fog/google/requests/monitoring/list_timeseries.rb +2 -0
  216. data/lib/fog/google/requests/pubsub/pull_subscription.rb +5 -1
  217. data/lib/fog/google/requests/sql/clone_instance.rb +2 -0
  218. data/lib/fog/google/requests/sql/delete_backup_run.rb +2 -0
  219. data/lib/fog/google/requests/sql/delete_instance.rb +2 -0
  220. data/lib/fog/google/requests/sql/delete_ssl_cert.rb +2 -0
  221. data/lib/fog/google/requests/sql/delete_user.rb +3 -1
  222. data/lib/fog/google/requests/sql/export_instance.rb +2 -0
  223. data/lib/fog/google/requests/sql/get_backup_run.rb +2 -0
  224. data/lib/fog/google/requests/sql/get_instance.rb +2 -0
  225. data/lib/fog/google/requests/sql/get_operation.rb +2 -0
  226. data/lib/fog/google/requests/sql/get_ssl_cert.rb +2 -0
  227. data/lib/fog/google/requests/sql/import_instance.rb +2 -0
  228. data/lib/fog/google/requests/sql/insert_backup_run.rb +2 -0
  229. data/lib/fog/google/requests/sql/insert_instance.rb +2 -0
  230. data/lib/fog/google/requests/sql/insert_ssl_cert.rb +2 -0
  231. data/lib/fog/google/requests/sql/insert_user.rb +2 -0
  232. data/lib/fog/google/requests/sql/list_backup_runs.rb +2 -0
  233. data/lib/fog/google/requests/sql/list_flags.rb +2 -0
  234. data/lib/fog/google/requests/sql/list_instances.rb +2 -0
  235. data/lib/fog/google/requests/sql/list_operations.rb +2 -0
  236. data/lib/fog/google/requests/sql/list_ssl_certs.rb +2 -0
  237. data/lib/fog/google/requests/sql/list_tiers.rb +2 -0
  238. data/lib/fog/google/requests/sql/list_users.rb +2 -0
  239. data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +2 -0
  240. data/lib/fog/google/requests/sql/restart_instance.rb +2 -0
  241. data/lib/fog/google/requests/sql/restore_instance_backup.rb +2 -0
  242. data/lib/fog/google/requests/sql/update_instance.rb +2 -0
  243. data/lib/fog/google/requests/sql/update_user.rb +2 -0
  244. data/lib/fog/google/shared.rb +115 -55
  245. data/lib/fog/google/sql.rb +1 -1
  246. data/lib/fog/google/version.rb +1 -1
  247. data/lib/fog/storage/google_json.rb +5 -1
  248. data/lib/fog/storage/google_json/mock.rb +6 -0
  249. data/lib/fog/storage/google_json/real.rb +106 -3
  250. data/lib/fog/storage/google_json/requests/copy_object.rb +2 -0
  251. data/lib/fog/storage/google_json/requests/delete_bucket.rb +2 -0
  252. data/lib/fog/storage/google_json/requests/delete_object.rb +2 -0
  253. data/lib/fog/storage/google_json/requests/get_bucket.rb +2 -0
  254. data/lib/fog/storage/google_json/requests/get_bucket_acl.rb +2 -0
  255. data/lib/fog/storage/google_json/requests/get_object.rb +2 -0
  256. data/lib/fog/storage/google_json/requests/get_object_acl.rb +2 -0
  257. data/lib/fog/storage/google_json/requests/get_object_metadata.rb +2 -0
  258. data/lib/fog/storage/google_json/requests/list_bucket_acl.rb +2 -0
  259. data/lib/fog/storage/google_json/requests/list_buckets.rb +2 -0
  260. data/lib/fog/storage/google_json/requests/list_object_acl.rb +2 -0
  261. data/lib/fog/storage/google_json/requests/list_objects.rb +2 -0
  262. data/lib/fog/storage/google_json/requests/put_bucket.rb +2 -0
  263. data/lib/fog/storage/google_json/requests/put_bucket_acl.rb +2 -0
  264. data/lib/fog/storage/google_json/requests/put_object.rb +2 -0
  265. data/lib/fog/storage/google_json/requests/put_object_acl.rb +2 -0
  266. data/lib/fog/storage/google_json/utils.rb +1 -1
  267. data/lib/fog/storage/google_xml/models/file.rb +1 -1
  268. data/lib/fog/storage/google_xml/requests/get_bucket.rb +0 -1
  269. data/lib/fog/storage/google_xml/requests/head_object.rb +7 -6
  270. data/lib/fog/storage/google_xml/requests/put_bucket_acl.rb +2 -0
  271. data/tasks/changelog.rake +37 -0
  272. data/tasks/test.rake +6 -2
  273. data/test/helpers/integration_test_helper.rb +17 -6
  274. data/test/helpers/test_helper.rb +1 -0
  275. data/test/integration/compute/core_compute/test_servers.rb +40 -0
  276. data/test/integration/compute/core_compute/test_zones.rb +1 -1
  277. data/test/integration/compute/core_networking/test_addresses.rb +23 -0
  278. data/test/integration/factories/{sql_v1_certs_factory.rb → sql_certs_factory.rb} +3 -3
  279. data/test/integration/factories/{sql_v1_instances_factory.rb → sql_instances_factory.rb} +3 -3
  280. data/test/integration/factories/{sql_v1_users_factory.rb → sql_users_factory.rb} +6 -3
  281. data/test/integration/monitoring/test_metric_descriptors.rb +2 -0
  282. data/test/integration/monitoring/test_timeseries.rb +14 -26
  283. data/test/integration/pubsub/test_pubsub_models.rb +3 -3
  284. data/test/integration/pubsub/test_pubsub_requests.rb +2 -2
  285. data/test/integration/sql/{sqlv1/test_v1_certs.rb → test_certs.rb} +3 -3
  286. data/test/integration/sql/{sqlv1/test_common_flags.rb → test_common_flags.rb} +0 -0
  287. data/test/integration/sql/{sqlv1/test_common_tiers.rb → test_common_tiers.rb} +0 -0
  288. data/test/integration/sql/{sqlv1/test_coverage.rb → test_coverage.rb} +1 -1
  289. data/test/integration/sql/{sqlv2/test_v2_instances.rb → test_instances.rb} +22 -2
  290. data/test/integration/sql/{sqlv1/test_v1_users.rb → test_users.rb} +4 -4
  291. data/test/integration/test_authentication.rb +0 -7
  292. data/test/unit/storage/test_common_xml_collections.rb +11 -0
  293. data/test/unit/storage/test_json_requests.rb +0 -1
  294. metadata +50 -31
  295. data/test/integration/factories/sql_v2_instances_factory.rb +0 -19
  296. data/test/integration/sql/sqlv1/test_v1_instances.rb +0 -31
  297. data/test/integration/sql/sqlv2/test_coverage.rb +0 -6
@@ -17,7 +17,9 @@ module Fog
17
17
 
18
18
  class Mock
19
19
  def list_backup_runs(_instance_id, _backup_configuration_id)
20
+ # :no-coverage:
20
21
  Fog::Mock.not_implemented
22
+ # :no-coverage:
21
23
  end
22
24
  end
23
25
  end
@@ -14,7 +14,9 @@ module Fog
14
14
 
15
15
  class Mock
16
16
  def list_flags
17
+ # :no-coverage:
17
18
  Fog::Mock.not_implemented
19
+ # :no-coverage:
18
20
  end
19
21
  end
20
22
  end
@@ -17,7 +17,9 @@ module Fog
17
17
 
18
18
  class Mock
19
19
  def list_instances(_options: {})
20
+ # :no-coverage:
20
21
  Fog::Mock.not_implemented
22
+ # :no-coverage:
21
23
  end
22
24
  end
23
25
  end
@@ -18,7 +18,9 @@ module Fog
18
18
 
19
19
  class Mock
20
20
  def list_operations(_instance_id, _options: {})
21
+ # :no-coverage:
21
22
  Fog::Mock.not_implemented
23
+ # :no-coverage:
22
24
  end
23
25
  end
24
26
  end
@@ -14,7 +14,9 @@ module Fog
14
14
 
15
15
  class Mock
16
16
  def list_ssl_certs(_instance_id)
17
+ # :no-coverage:
17
18
  Fog::Mock.not_implemented
19
+ # :no-coverage:
18
20
  end
19
21
  end
20
22
  end
@@ -14,7 +14,9 @@ module Fog
14
14
 
15
15
  class Mock
16
16
  def list_tiers
17
+ # :no-coverage:
17
18
  Fog::Mock.not_implemented
19
+ # :no-coverage:
18
20
  end
19
21
  end
20
22
  end
@@ -14,7 +14,9 @@ module Fog
14
14
 
15
15
  class Mock
16
16
  def list_operations(_instance_id)
17
+ # :no-coverage:
17
18
  Fog::Mock.not_implemented
19
+ # :no-coverage:
18
20
  end
19
21
  end
20
22
  end
@@ -16,7 +16,9 @@ module Fog
16
16
 
17
17
  class Mock
18
18
  def reset_instance_ssl_config(_instance_id)
19
+ # :no-coverage:
19
20
  Fog::Mock.not_implemented
21
+ # :no-coverage:
20
22
  end
21
23
  end
22
24
  end
@@ -14,7 +14,9 @@ module Fog
14
14
 
15
15
  class Mock
16
16
  def restart_instance(_instance_id)
17
+ # :no-coverage:
17
18
  Fog::Mock.not_implemented
19
+ # :no-coverage:
18
20
  end
19
21
  end
20
22
  end
@@ -21,7 +21,9 @@ module Fog
21
21
 
22
22
  class Mock
23
23
  def restore_instance_backup(_instance_id, _backup_run_id)
24
+ # :no-coverage:
24
25
  Fog::Mock.not_implemented
26
+ # :no-coverage:
25
27
  end
26
28
  end
27
29
  end
@@ -21,7 +21,9 @@ module Fog
21
21
 
22
22
  class Mock
23
23
  def update_instance(_instance_id, _settings_version, _tier, _settings = {})
24
+ # :no-coverage:
24
25
  Fog::Mock.not_implemented
26
+ # :no-coverage:
25
27
  end
26
28
  end
27
29
  end
@@ -17,7 +17,9 @@ module Fog
17
17
 
18
18
  class Mock
19
19
  def update_user(_instance_id, _host, _name, _user)
20
+ # :no-coverage:
20
21
  Fog::Mock.not_implemented
22
+ # :no-coverage:
21
23
  end
22
24
  end
23
25
  end
@@ -1,3 +1,5 @@
1
+ require "google-cloud-env"
2
+
1
3
  module Fog
2
4
  module Google
3
5
  module Shared
@@ -14,61 +16,43 @@ module Fog
14
16
  @project = project
15
17
  @api_version = api_version
16
18
  @api_url = base_url + api_version + "/projects/"
19
+ # google-cloud-env allows us to figure out which GCP runtime we're running in and query metadata
20
+ # e.g. whether we're running in GCE/GKE/AppEngine or what region the instance is running in
21
+ @google_cloud_env = ::Google::Cloud::Env.get
17
22
  end
18
23
 
19
24
  ##
20
25
  # Initializes the Google API Client
21
26
  #
22
27
  # @param [Hash] options Google API options
28
+ # @option options [Bool] :google_application_default Explicitly use application default credentials
23
29
  # @option options [Google::Auth|Signet] :google_auth Manually created authorization to use
24
- # @option options [String] :google_client_email A @developer.gserviceaccount.com email address to use
25
- # @option options [String] :google_key_location The location of a pkcs12 key file
26
- # @option options [String] :google_key_string The content of the pkcs12 key file
27
30
  # @option options [String] :google_json_key_location The location of a JSON key file
28
31
  # @option options [String] :google_json_key_string The content of the JSON key file
29
32
  # @option options [String] :google_api_scope_url The access scope URLs
30
33
  # @option options [String] :app_name The app name to set in the user agent
31
34
  # @option options [String] :app_version The app version to set in the user agent
32
- # @option options [Google::APIClient] :google_client Existing Google API Client
33
35
  # @option options [Hash] :google_client_options A hash to send additional options to Google API Client
34
36
  # @return [Google::APIClient] Google API Client
35
37
  # @raises [ArgumentError] If there is any missing argument
36
38
  def initialize_google_client(options)
37
39
  # NOTE: loaded here to avoid requiring this as a core Fog dependency
38
40
  begin
39
- # Because of how Google API gem was rewritten, we get to do all sorts
40
- # of funky things, like this nonsense.
41
+ # TODO: google-api-client is in gemspec now, re-assess if this initialization logic is still needed
41
42
  require "google/apis/monitoring_#{Fog::Google::Monitoring::GOOGLE_MONITORING_API_VERSION}"
42
43
  require "google/apis/compute_#{Fog::Compute::Google::GOOGLE_COMPUTE_API_VERSION}"
43
44
  require "google/apis/dns_#{Fog::DNS::Google::GOOGLE_DNS_API_VERSION}"
44
45
  require "google/apis/pubsub_#{Fog::Google::Pubsub::GOOGLE_PUBSUB_API_VERSION}"
45
46
  require "google/apis/sqladmin_#{Fog::Google::SQL::GOOGLE_SQL_API_VERSION}"
46
47
  require "google/apis/storage_#{Fog::Storage::GoogleJSON::GOOGLE_STORAGE_JSON_API_VERSION}"
48
+ require "google/apis/iamcredentials_#{Fog::Storage::GoogleJSON::GOOGLE_STORAGE_JSON_IAM_API_VERSION}"
47
49
  require "googleauth"
48
50
  rescue LoadError => error
49
51
  Fog::Errors::Error.new("Please install the google-api-client (>= 0.9) gem before using this provider")
50
52
  raise error
51
53
  end
52
54
 
53
- # Users can no longer provide their own clients due to rewrite of auth
54
- # in https://github.com/google/google-api-ruby-client/ version 0.9.
55
- if options[:google_client]
56
- raise ArgumentError.new("Deprecated argument no longer works: google_client")
57
- end
58
-
59
- # They can also no longer use pkcs12 files, because Google's new auth
60
- # library doesn't support them either.
61
- if options[:google_key_location]
62
- raise ArgumentError.new("Deprecated argument no longer works: google_key_location")
63
- end
64
- if options[:google_key_string]
65
- raise ArgumentError.new("Deprecated argument no longer works: google_key_string")
66
- end
67
-
68
- # Validate required arguments
69
- unless options[:google_api_scope_url]
70
- raise ArgumentError.new("Missing required arguments: google_api_scope_url")
71
- end
55
+ validate_client_options(options)
72
56
 
73
57
  application_name = "fog"
74
58
  unless options[:app_name].nil?
@@ -78,41 +62,21 @@ module Fog
78
62
  ::Google::Apis::ClientOptions.default.application_name = application_name
79
63
  ::Google::Apis::ClientOptions.default.application_version = Fog::Google::VERSION
80
64
 
81
- auth = nil
82
- if options[:google_json_key_location] || options[:google_json_key_string]
83
- if options[:google_json_key_location]
84
- json_key_location = File.expand_path(options[:google_json_key_location])
85
- json_key = File.open(json_key_location, "r", &:read)
86
- else
87
- json_key = options[:google_json_key_string]
88
- end
89
-
90
- json_key_hash = Fog::JSON.decode(json_key)
91
- unless json_key_hash.key?("client_email") || json_key_hash.key?("private_key")
92
- raise ArgumentError.new("Invalid Google JSON key")
93
- end
94
-
95
- options[:google_client_email] = json_key_hash["client_email"]
96
- unless options[:google_client_email]
97
- raise ArgumentError.new("Missing required arguments: google_client_email")
98
- end
65
+ if ENV["DEBUG"]
66
+ ::Google::Apis.logger = ::Logger.new(::STDERR)
67
+ ::Google::Apis.logger.level = ::Logger::DEBUG
68
+ end
99
69
 
100
- if ENV["DEBUG"]
101
- ::Google::Apis.logger = ::Logger.new(::STDERR)
102
- ::Google::Apis.logger.level = ::Logger::DEBUG
103
- end
70
+ auth = nil
104
71
 
105
- auth = ::Google::Auth::ServiceAccountCredentials.make_creds(
106
- :json_key_io => StringIO.new(json_key_hash.to_json),
107
- :scope => options[:google_api_scope_url]
108
- )
72
+ if options[:google_json_key_location] || options[:google_json_key_string]
73
+ auth = process_key_auth(options)
109
74
  elsif options[:google_auth]
110
75
  auth = options[:google_auth]
76
+ elsif options[:google_application_default]
77
+ auth = process_application_default_auth(options)
111
78
  else
112
- raise ArgumentError.new(
113
- "Missing required arguments: google_json_key_location, "\
114
- "google_json_key_string or google_auth"
115
- )
79
+ auth = process_fallback_auth(options)
116
80
  end
117
81
 
118
82
  ::Google::Apis::RequestOptions.default.authorization = auth
@@ -188,6 +152,102 @@ module Fog
188
152
 
189
153
  response
190
154
  end
155
+
156
+ private
157
+
158
+ # Helper method to process application default authentication
159
+ #
160
+ # @param [Hash] options - client options hash
161
+ # @return [Google::Auth::DefaultCredentials] - google auth object
162
+ def process_application_default_auth(options)
163
+ ::Google::Auth.get_application_default(options[:google_api_scope_url])
164
+ end
165
+
166
+ # Helper method to process fallback authentication
167
+ # Current fallback is application default authentication
168
+ #
169
+ # @param [Hash] options - client options hash
170
+ # @return [Google::Auth::DefaultCredentials] - google auth object
171
+ def process_fallback_auth(options)
172
+ Fog::Logger.warning(
173
+ "Didn't detect any client auth settings, " \
174
+ "trying to fall back to application default credentials..."
175
+ )
176
+ begin
177
+ return process_application_default_auth(options)
178
+ rescue
179
+ raise Fog::Errors::Error.new(
180
+ "Fallback auth failed, could not configure authentication for Fog client.\n" \
181
+ "Check your auth options, must be one of:\n" \
182
+ "- :google_json_key_location,\n" \
183
+ "- :google_json_key_string,\n" \
184
+ "- :google_auth,\n" \
185
+ "- :google_application_default,\n" \
186
+ "If credentials are valid - please, file a bug to fog-google." \
187
+ )
188
+ end
189
+ end
190
+
191
+ # Helper method to process key authentication
192
+ #
193
+ # @param [Hash] options - client options hash
194
+ # @return [Google::Auth::ServiceAccountCredentials] - google auth object
195
+ def process_key_auth(options)
196
+ if options[:google_json_key_location]
197
+ json_key = File.read(File.expand_path(options[:google_json_key_location]))
198
+ elsif options[:google_json_key_string]
199
+ json_key = options[:google_json_key_string]
200
+ end
201
+
202
+ validate_json_credentials(json_key)
203
+
204
+ ::Google::Auth::ServiceAccountCredentials.make_creds(
205
+ :json_key_io => StringIO.new(json_key),
206
+ :scope => options[:google_api_scope_url]
207
+ )
208
+ end
209
+
210
+ # Helper method to sort out deprecated and missing auth options
211
+ #
212
+ # @param [Hash] options - client options hash
213
+ def validate_client_options(options)
214
+ # Users can no longer provide their own clients due to rewrite of auth
215
+ # in https://github.com/google/google-api-ruby-client/ version 0.9.
216
+ if options[:google_client]
217
+ raise ArgumentError.new("Deprecated argument no longer works: google_client")
218
+ end
219
+
220
+ # They can also no longer use pkcs12 files, because Google's new auth
221
+ # library doesn't support them either.
222
+ if options[:google_key_location]
223
+ raise ArgumentError.new("Deprecated auth method no longer works: google_key_location")
224
+ end
225
+ if options[:google_key_string]
226
+ raise ArgumentError.new("Deprecated auth method no longer works: google_key_string")
227
+ end
228
+
229
+ # Google client email option is no longer needed
230
+ if options[:google_client_email]
231
+ Fog::Logger.deprecation("Argument no longer needed for auth: google_client_email")
232
+ end
233
+
234
+ # Validate required arguments
235
+ unless options[:google_api_scope_url]
236
+ raise ArgumentError.new("Missing required arguments: google_api_scope_url")
237
+ end
238
+ end
239
+
240
+ # Helper method to checks whether the necessary fields are present in
241
+ # JSON key credentials
242
+ #
243
+ # @param [String] json_key - Google json auth key string
244
+ def validate_json_credentials(json_key)
245
+ json_key_hash = Fog::JSON.decode(json_key)
246
+
247
+ unless json_key_hash.key?("client_email") || json_key_hash.key?("private_key")
248
+ raise ArgumentError.new("Invalid Google JSON key")
249
+ end
250
+ end
191
251
  end
192
252
  end
193
253
  end
@@ -8,9 +8,9 @@ module Fog
8
8
  recognizes(
9
9
  :app_name,
10
10
  :app_version,
11
+ :google_application_default,
11
12
  :google_auth,
12
13
  :google_client,
13
- :google_client_email,
14
14
  :google_client_options,
15
15
  :google_key_location,
16
16
  :google_key_string,
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.8.2".freeze
3
+ VERSION = "1.12.0".freeze
4
4
  end
5
5
  end
@@ -9,9 +9,9 @@ module Fog
9
9
  recognizes(
10
10
  :app_name,
11
11
  :app_version,
12
+ :google_application_default,
12
13
  :google_auth,
13
14
  :google_client,
14
- :google_client_email,
15
15
  :google_client_options,
16
16
  :google_key_location,
17
17
  :google_key_string,
@@ -27,6 +27,10 @@ module Fog
27
27
  GOOGLE_STORAGE_JSON_BASE_URL = "https://www.googleapis.com/storage/".freeze
28
28
  GOOGLE_STORAGE_BUCKET_BASE_URL = "https://storage.googleapis.com/".freeze
29
29
 
30
+ # Version of IAM API used for blob signing, see Fog::Storage::GoogleJSON::Real#iam_signer
31
+ GOOGLE_STORAGE_JSON_IAM_API_VERSION = "v1".freeze
32
+ GOOGLE_STORAGE_JSON_IAM_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/devstorage.full_control).freeze
33
+
30
34
  # TODO: Come up with a way to only request a subset of permissions.
31
35
  # https://cloud.google.com/storage/docs/json_api/v1/how-tos/authorizing
32
36
  GOOGLE_STORAGE_JSON_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/devstorage.full_control).freeze
@@ -10,11 +10,17 @@ module Fog
10
10
  def initialize(options = {})
11
11
  shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
12
12
  @client = MockClient.new('test')
13
+ @storage_json = MockClient.new('test')
14
+ @iam_service = MockClient.new('test')
13
15
  end
14
16
 
15
17
  def signature(_params)
16
18
  "foo"
17
19
  end
20
+
21
+ def google_access_id
22
+ "my-account@project.iam.gserviceaccount"
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -13,7 +13,14 @@ module Fog
13
13
  options[:google_api_scope_url] = GOOGLE_STORAGE_JSON_API_SCOPE_URLS.join(" ")
14
14
  @host = options[:host] || "storage.googleapis.com"
15
15
 
16
+ # TODO(temikus): Do we even need this client?
16
17
  @client = initialize_google_client(options)
18
+ # IAM client used for SignBlob API
19
+ @iam_service = ::Google::Apis::IamcredentialsV1::IAMCredentialsService.new
20
+ apply_client_options(@iam_service, {
21
+ google_api_scope_url: GOOGLE_STORAGE_JSON_IAM_API_SCOPE_URLS.join(" ")
22
+ })
23
+
17
24
  @storage_json = ::Google::Apis::StorageV1::StorageService.new
18
25
  apply_client_options(@storage_json, options)
19
26
 
@@ -56,12 +63,108 @@ DATA
56
63
  canonical_resource.chop!
57
64
  string_to_sign << canonical_resource.to_s
58
65
 
59
- key = OpenSSL::PKey::RSA.new(@client.signing_key)
60
- digest = OpenSSL::Digest::SHA256.new
61
- signed_string = key.sign(digest, string_to_sign)
66
+ # TODO(temikus): make signer configurable or add ability to supply your own via lambda
67
+ if !@storage_json.authorization.signing_key.nil?
68
+ signed_string = default_signer(string_to_sign)
69
+ else
70
+ # If client doesn't contain signing key attempt to auth via IAM SignBlob API
71
+ signed_string = iam_signer(string_to_sign)
72
+ end
62
73
 
63
74
  Base64.encode64(signed_string).chomp!
64
75
  end
76
+
77
+ private
78
+
79
+ def google_access_id
80
+ @google_access_id ||= get_google_access_id
81
+ end
82
+
83
+ ##
84
+ # Fetches the google service account name
85
+ #
86
+ # @return [String] Service account name, typically needed for GoogleAccessId, e.g.
87
+ # my-account@project.iam.gserviceaccount
88
+ # @raises [Fog::Errors::Error] If authorisation is incorrect or inapplicable for current action
89
+ def get_google_access_id
90
+ if @storage_json.authorization.is_a?(::Google::Auth::UserRefreshCredentials)
91
+ raise Fog::Errors::Error.new("User / Application Default Credentials are not supported for storage"\
92
+ "url signing, please use a service account or metadata authentication.")
93
+ end
94
+
95
+ if !@storage_json.authorization.issuer.nil?
96
+ return @storage_json.authorization.issuer
97
+ else
98
+ get_access_id_from_metadata
99
+ end
100
+ end
101
+
102
+ ##
103
+ # Attempts to fetch the google service account name from metadata using Google::Cloud::Env
104
+ #
105
+ # @return [String] Service account name, typically needed for GoogleAccessId, e.g.
106
+ # my-account@project.iam.gserviceaccount
107
+ # @raises [Fog::Errors::Error] If Metadata service is not available or returns an invalid response
108
+ def get_access_id_from_metadata
109
+ if @google_cloud_env.metadata?
110
+ access_id = @google_cloud_env.lookup_metadata("instance", "service-accounts/default/email")
111
+ else
112
+ raise Fog::Errors::Error.new("Metadata service not available, unable to retrieve service account info.")
113
+ end
114
+
115
+ if access_id.nil?
116
+ raise Fog::Errors::Error.new("Metadata service found but didn't return data." \
117
+ "Please file a bug: https://github.com/fog/fog-google")
118
+ end
119
+
120
+ return access_id
121
+ end
122
+
123
+ ##
124
+ # Default url signer using service account keys
125
+ #
126
+ # @param [String] string_to_sign Special collection of headers and options for V2 storage signing, e.g.:
127
+ #
128
+ # StringToSign = HTTP_Verb + "\n" +
129
+ # Content_MD5 + "\n" +
130
+ # Content_Type + "\n" +
131
+ # Expires + "\n" +
132
+ # Canonicalized_Extension_Headers +
133
+ # Canonicalized_Resource
134
+ #
135
+ # See https://cloud.google.com/storage/docs/access-control/signed-urls-v2
136
+ # @return [String] Signature binary blob
137
+ def default_signer(string_to_sign)
138
+ key = OpenSSL::PKey::RSA.new(@storage_json.authorization.signing_key)
139
+ digest = OpenSSL::Digest::SHA256.new
140
+ return key.sign(digest, string_to_sign)
141
+ end
142
+
143
+ ##
144
+ # Fallback URL signer using the IAM SignServiceAccountBlob API, see
145
+ # Google::Apis::IamcredentialsV1::IAMCredentialsService#sign_service_account_blob
146
+ #
147
+ # @param [String] string_to_sign Special collection of headers and options for V2 storage signing, e.g.:
148
+ #
149
+ # StringToSign = HTTP_Verb + "\n" +
150
+ # Content_MD5 + "\n" +
151
+ # Content_Type + "\n" +
152
+ # Expires + "\n" +
153
+ # Canonicalized_Extension_Headers +
154
+ # Canonicalized_Resource
155
+ #
156
+ # See https://cloud.google.com/storage/docs/access-control/signed-urls-v2
157
+ # @return [String] Signature binary blob
158
+ def iam_signer(string_to_sign)
159
+ request = {
160
+ "payload": string_to_sign
161
+ }
162
+
163
+ resource = "projects/-/serviceAccounts/#{google_access_id}"
164
+ response = @iam_service.sign_service_account_blob resource, request, {}
165
+
166
+ return response.signed_blob
167
+ end
65
168
  end
66
169
  end
67
170
  end