fog-google 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (479) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +11 -0
  3. data/.gitignore +1 -0
  4. data/.hound.yml +2 -0
  5. data/.rubocop.yml +225 -5
  6. data/.travis.yml +13 -11
  7. data/CONTRIBUTORS.md +1 -0
  8. data/Gemfile +1 -1
  9. data/README.md +31 -16
  10. data/Rakefile +15 -39
  11. data/examples/backend_services.rb +12 -11
  12. data/examples/bootstrap.rb +11 -1
  13. data/examples/{create.rb → create_instance.rb} +20 -11
  14. data/examples/dns/project.rb +2 -3
  15. data/examples/dns/zones.rb +21 -21
  16. data/examples/get_list_images.rb +31 -15
  17. data/examples/get_list_snapshots.rb +20 -10
  18. data/examples/image_create.rb +5 -5
  19. data/examples/l7_load_balance.rb +56 -58
  20. data/examples/load-balance.rb +22 -23
  21. data/examples/metadata.rb +17 -9
  22. data/examples/monitoring/metric_descriptors.rb +19 -6
  23. data/examples/monitoring/timeseries_collection.rb +23 -11
  24. data/examples/monitoring/timeseries_descriptors.rb +23 -11
  25. data/examples/network.rb +25 -29
  26. data/examples/precreated_client.rb +3 -6
  27. data/examples/sql/flags.rb +2 -2
  28. data/examples/sql/instances.rb +18 -18
  29. data/examples/sql/operations.rb +9 -9
  30. data/examples/sql/ssl_certs.rb +13 -13
  31. data/examples/sql/tiers.rb +2 -2
  32. data/examples/storage.rb +37 -0
  33. data/examples/storage_json.rb +37 -0
  34. data/fog-google.gemspec +24 -21
  35. data/lib/fog/bin/google.rb +34 -32
  36. data/lib/fog/{google/compute.rb → compute/google.rb} +207 -151
  37. data/lib/fog/{google/models/compute → compute/google/models}/address.rb +24 -28
  38. data/lib/fog/{google/models/compute → compute/google/models}/addresses.rb +10 -14
  39. data/lib/fog/{google/models/compute → compute/google/models}/backend_service.rb +28 -34
  40. data/lib/fog/{google/models/compute → compute/google/models}/backend_services.rb +2 -5
  41. data/lib/fog/{google/models/compute → compute/google/models}/disk.rb +35 -39
  42. data/lib/fog/{google/models/compute → compute/google/models}/disk_type.rb +4 -6
  43. data/lib/fog/{google/models/compute → compute/google/models}/disk_types.rb +7 -10
  44. data/lib/fog/{google/models/compute → compute/google/models}/disks.rb +9 -12
  45. data/lib/fog/{google/models/compute → compute/google/models}/firewall.rb +10 -14
  46. data/lib/fog/{google/models/compute → compute/google/models}/firewalls.rb +1 -4
  47. data/lib/fog/compute/google/models/flavor.rb +31 -0
  48. data/lib/fog/{google/models/compute → compute/google/models}/flavors.rb +2 -5
  49. data/lib/fog/{google/models/compute → compute/google/models}/forwarding_rule.rb +24 -28
  50. data/lib/fog/{google/models/compute → compute/google/models}/forwarding_rules.rb +8 -11
  51. data/lib/fog/compute/google/models/global_forwarding_rule.rb +82 -0
  52. data/lib/fog/{google/models/compute → compute/google/models}/global_forwarding_rules.rb +2 -5
  53. data/lib/fog/compute/google/models/http_health_check.rb +80 -0
  54. data/lib/fog/{google/models/compute → compute/google/models}/http_health_checks.rb +2 -5
  55. data/lib/fog/{google/models/compute → compute/google/models}/image.rb +18 -22
  56. data/lib/fog/{google/models/compute → compute/google/models}/images.rb +24 -17
  57. data/lib/fog/{google/models/compute → compute/google/models}/instance_group.rb +5 -8
  58. data/lib/fog/{google/models/compute → compute/google/models}/instance_groups.rb +10 -13
  59. data/lib/fog/{google/models/compute → compute/google/models}/network.rb +9 -13
  60. data/lib/fog/{google/models/compute → compute/google/models}/networks.rb +1 -4
  61. data/lib/fog/{google/models/compute → compute/google/models}/operation.rb +16 -18
  62. data/lib/fog/{google/models/compute → compute/google/models}/operations.rb +8 -11
  63. data/lib/fog/{google/models/compute → compute/google/models}/project.rb +5 -7
  64. data/lib/fog/{google/models/compute → compute/google/models}/projects.rb +0 -3
  65. data/lib/fog/{google/models/compute → compute/google/models}/region.rb +5 -7
  66. data/lib/fog/{google/models/compute → compute/google/models}/regions.rb +1 -4
  67. data/lib/fog/compute/google/models/resource_view.rb +108 -0
  68. data/lib/fog/compute/google/models/resource_views.rb +54 -0
  69. data/lib/fog/{google/models/compute → compute/google/models}/route.rb +12 -16
  70. data/lib/fog/{google/models/compute → compute/google/models}/routes.rb +1 -4
  71. data/lib/fog/{google/models/compute → compute/google/models}/server.rb +81 -92
  72. data/lib/fog/{google/models/compute → compute/google/models}/servers.rb +13 -16
  73. data/lib/fog/compute/google/models/snapshot.rb +44 -0
  74. data/lib/fog/{google/models/compute → compute/google/models}/snapshots.rb +1 -4
  75. data/lib/fog/compute/google/models/subnetwork.rb +49 -0
  76. data/lib/fog/compute/google/models/subnetworks.rb +29 -0
  77. data/lib/fog/{google/models/compute → compute/google/models}/target_http_proxies.rb +2 -5
  78. data/lib/fog/{google/models/compute → compute/google/models}/target_http_proxy.rb +18 -22
  79. data/lib/fog/{google/models/compute → compute/google/models}/target_instance.rb +23 -28
  80. data/lib/fog/{google/models/compute → compute/google/models}/target_instances.rb +9 -12
  81. data/lib/fog/{google/models/compute → compute/google/models}/target_pool.rb +24 -28
  82. data/lib/fog/{google/models/compute → compute/google/models}/target_pools.rb +6 -9
  83. data/lib/fog/{google/models/compute → compute/google/models}/url_map.rb +32 -36
  84. data/lib/fog/{google/models/compute → compute/google/models}/url_maps.rb +1 -4
  85. data/lib/fog/compute/google/models/zone.rb +21 -0
  86. data/lib/fog/{google/models/compute → compute/google/models}/zones.rb +0 -3
  87. data/lib/fog/{google/requests/compute → compute/google/requests}/add_backend_service_backends.rb +5 -5
  88. data/lib/fog/{google/requests/compute → compute/google/requests}/add_instance_group_instance.rb +4 -4
  89. data/lib/fog/compute/google/requests/add_region_view_resources.rb +27 -0
  90. data/lib/fog/{google/requests/compute → compute/google/requests}/add_server_access_config.rb +8 -8
  91. data/lib/fog/{google/requests/compute → compute/google/requests}/add_target_pool_health_checks.rb +6 -6
  92. data/lib/fog/{google/requests/compute → compute/google/requests}/add_target_pool_instances.rb +6 -6
  93. data/lib/fog/{google/requests/compute → compute/google/requests}/add_url_map_host_rules.rb +6 -6
  94. data/lib/fog/{google/requests/compute → compute/google/requests}/add_url_map_path_matchers.rb +7 -7
  95. data/lib/fog/compute/google/requests/add_zone_view_resources.rb +27 -0
  96. data/lib/fog/compute/google/requests/attach_disk.rb +34 -0
  97. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_address.rb +4 -4
  98. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_backend_service.rb +8 -8
  99. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_disk.rb +9 -11
  100. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_firewall.rb +3 -3
  101. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_forwarding_rule.rb +8 -8
  102. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_global_forwarding_rule.rb +12 -12
  103. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_global_operation.rb +3 -3
  104. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_http_health_check.rb +7 -7
  105. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_image.rb +7 -7
  106. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_instance_group.rb +4 -4
  107. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_network.rb +3 -3
  108. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_region_operation.rb +6 -6
  109. data/lib/fog/compute/google/requests/delete_region_view.rb +24 -0
  110. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_route.rb +3 -3
  111. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_server.rb +15 -17
  112. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_server_access_config.rb +6 -6
  113. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_snapshot.rb +3 -3
  114. data/lib/fog/compute/google/requests/delete_subnetwork.rb +49 -0
  115. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_target_http_proxy.rb +7 -7
  116. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_target_instance.rb +9 -11
  117. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_target_pool.rb +8 -8
  118. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_url_map.rb +7 -7
  119. data/lib/fog/{google/requests/compute → compute/google/requests}/delete_zone_operation.rb +5 -7
  120. data/lib/fog/compute/google/requests/delete_zone_view.rb +24 -0
  121. data/lib/fog/{google/requests/compute → compute/google/requests}/detach_disk.rb +5 -5
  122. data/lib/fog/{google/requests/compute → compute/google/requests}/get_address.rb +4 -4
  123. data/lib/fog/{google/requests/compute → compute/google/requests}/get_backend_service.rb +5 -7
  124. data/lib/fog/{google/requests/compute → compute/google/requests}/get_backend_service_health.rb +6 -6
  125. data/lib/fog/{google/requests/compute → compute/google/requests}/get_backend_services.rb +6 -6
  126. data/lib/fog/compute/google/requests/get_disk.rb +46 -0
  127. data/lib/fog/compute/google/requests/get_disk_type.rb +40 -0
  128. data/lib/fog/{google/requests/compute → compute/google/requests}/get_firewall.rb +3 -3
  129. data/lib/fog/compute/google/requests/get_forwarding_rule.rb +44 -0
  130. data/lib/fog/compute/google/requests/get_global_forwarding_rule.rb +30 -0
  131. data/lib/fog/{google/requests/compute → compute/google/requests}/get_global_operation.rb +8 -8
  132. data/lib/fog/compute/google/requests/get_http_health_check.rb +37 -0
  133. data/lib/fog/{google/requests/compute → compute/google/requests}/get_image.rb +4 -4
  134. data/lib/fog/{google/requests/compute → compute/google/requests}/get_instance_group.rb +5 -5
  135. data/lib/fog/compute/google/requests/get_machine_type.rb +41 -0
  136. data/lib/fog/{google/requests/compute → compute/google/requests}/get_network.rb +3 -3
  137. data/lib/fog/{google/requests/compute → compute/google/requests}/get_project.rb +2 -2
  138. data/lib/fog/{google/requests/compute → compute/google/requests}/get_region.rb +9 -9
  139. data/lib/fog/{google/requests/compute → compute/google/requests}/get_region_operation.rb +11 -11
  140. data/lib/fog/compute/google/requests/get_region_view.rb +24 -0
  141. data/lib/fog/{google/requests/compute → compute/google/requests}/get_route.rb +3 -3
  142. data/lib/fog/compute/google/requests/get_server.rb +71 -0
  143. data/lib/fog/{google/requests/compute → compute/google/requests}/get_server_serial_port_output.rb +4 -4
  144. data/lib/fog/{google/requests/compute → compute/google/requests}/get_snapshot.rb +5 -7
  145. data/lib/fog/compute/google/requests/get_subnetwork.rb +45 -0
  146. data/lib/fog/{google/requests/compute → compute/google/requests}/get_target_http_proxy.rb +4 -6
  147. data/lib/fog/compute/google/requests/get_target_instance.rb +28 -0
  148. data/lib/fog/{google/requests/compute → compute/google/requests}/get_target_pool.rb +6 -6
  149. data/lib/fog/{google/requests/compute → compute/google/requests}/get_target_pool_health.rb +7 -7
  150. data/lib/fog/{google/requests/compute → compute/google/requests}/get_url_map.rb +4 -6
  151. data/lib/fog/{google/requests/compute → compute/google/requests}/get_zone.rb +8 -8
  152. data/lib/fog/{google/requests/compute → compute/google/requests}/get_zone_operation.rb +10 -12
  153. data/lib/fog/compute/google/requests/get_zone_view.rb +24 -0
  154. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_address.rb +5 -5
  155. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_backend_service.rb +17 -17
  156. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_disk.rb +26 -30
  157. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_firewall.rb +4 -4
  158. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_forwarding_rule.rb +13 -13
  159. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_global_forwarding_rule.rb +13 -13
  160. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_http_health_check.rb +11 -11
  161. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_image.rb +14 -14
  162. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_instance_group.rb +6 -6
  163. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_network.rb +6 -6
  164. data/lib/fog/compute/google/requests/insert_region_view.rb +25 -0
  165. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_route.rb +11 -11
  166. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_server.rb +57 -57
  167. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_snapshot.rb +8 -8
  168. data/lib/fog/compute/google/requests/insert_subnetwork.rb +75 -0
  169. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_target_http_proxy.rb +9 -9
  170. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_target_instance.rb +11 -11
  171. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_target_pool.rb +11 -11
  172. data/lib/fog/{google/requests/compute → compute/google/requests}/insert_url_map.rb +9 -9
  173. data/lib/fog/compute/google/requests/insert_zone_view.rb +26 -0
  174. data/lib/fog/{google/requests/compute → compute/google/requests}/list_addresses.rb +3 -3
  175. data/lib/fog/{google/requests/compute → compute/google/requests}/list_aggregated_addresses.rb +3 -3
  176. data/lib/fog/compute/google/requests/list_aggregated_disk_types.rb +38 -0
  177. data/lib/fog/compute/google/requests/list_aggregated_disks.rb +37 -0
  178. data/lib/fog/{google/requests/compute → compute/google/requests}/list_aggregated_instance_groups.rb +3 -3
  179. data/lib/fog/{google/requests/compute → compute/google/requests}/list_aggregated_machine_types.rb +1 -1
  180. data/lib/fog/compute/google/requests/list_aggregated_servers.rb +37 -0
  181. data/lib/fog/compute/google/requests/list_aggregated_subnetworks.rb +34 -0
  182. data/lib/fog/{google/requests/compute → compute/google/requests}/list_aggregated_target_instances.rb +10 -13
  183. data/lib/fog/compute/google/requests/list_backend_services.rb +27 -0
  184. data/lib/fog/compute/google/requests/list_disk_types.rb +44 -0
  185. data/lib/fog/compute/google/requests/list_disks.rb +27 -0
  186. data/lib/fog/{google/requests/compute → compute/google/requests}/list_firewalls.rb +1 -1
  187. data/lib/fog/compute/google/requests/list_forwarding_rules.rb +27 -0
  188. data/lib/fog/compute/google/requests/list_global_forwarding_rules.rb +28 -0
  189. data/lib/fog/{google/requests/compute → compute/google/requests}/list_global_operations.rb +1 -1
  190. data/lib/fog/compute/google/requests/list_http_health_checks.rb +27 -0
  191. data/lib/fog/compute/google/requests/list_images.rb +27 -0
  192. data/lib/fog/{google/requests/compute → compute/google/requests}/list_instance_group_instances.rb +4 -4
  193. data/lib/fog/{google/requests/compute → compute/google/requests}/list_instance_groups.rb +3 -3
  194. data/lib/fog/{google/requests/compute → compute/google/requests}/list_machine_types.rb +6 -8
  195. data/lib/fog/{google/requests/compute → compute/google/requests}/list_networks.rb +1 -1
  196. data/lib/fog/{google/requests/compute → compute/google/requests}/list_region_operations.rb +3 -3
  197. data/lib/fog/compute/google/requests/list_region_view_resources.rb +24 -0
  198. data/lib/fog/compute/google/requests/list_region_views.rb +23 -0
  199. data/lib/fog/compute/google/requests/list_regions.rb +83 -0
  200. data/lib/fog/{google/requests/compute → compute/google/requests}/list_routes.rb +2 -2
  201. data/lib/fog/compute/google/requests/list_servers.rb +29 -0
  202. data/lib/fog/{google/requests/compute → compute/google/requests}/list_snapshots.rb +3 -3
  203. data/lib/fog/compute/google/requests/list_subnetworks.rb +35 -0
  204. data/lib/fog/compute/google/requests/list_target_http_proxies.rb +27 -0
  205. data/lib/fog/compute/google/requests/list_target_instances.rb +28 -0
  206. data/lib/fog/compute/google/requests/list_target_pools.rb +27 -0
  207. data/lib/fog/compute/google/requests/list_url_maps.rb +27 -0
  208. data/lib/fog/{google/requests/compute → compute/google/requests}/list_zone_operations.rb +3 -3
  209. data/lib/fog/compute/google/requests/list_zone_view_resources.rb +24 -0
  210. data/lib/fog/compute/google/requests/list_zone_views.rb +23 -0
  211. data/lib/fog/compute/google/requests/list_zones.rb +26 -0
  212. data/lib/fog/{google/requests/compute → compute/google/requests}/remove_instance_group_instance.rb +4 -4
  213. data/lib/fog/{google/requests/compute → compute/google/requests}/remove_target_pool_health_checks.rb +6 -6
  214. data/lib/fog/{google/requests/compute → compute/google/requests}/remove_target_pool_instance.rb +6 -6
  215. data/lib/fog/{google/requests/compute → compute/google/requests}/remove_target_pool_instances.rb +6 -6
  216. data/lib/fog/{google/requests/compute → compute/google/requests}/reset_server.rb +4 -4
  217. data/lib/fog/{google/requests/compute → compute/google/requests}/set_common_instance_metadata.rb +3 -3
  218. data/lib/fog/{google/requests/compute → compute/google/requests}/set_forwarding_rule_target.rb +6 -6
  219. data/lib/fog/{google/requests/compute → compute/google/requests}/set_global_forwarding_rule_target.rb +6 -6
  220. data/lib/fog/{google/requests/compute → compute/google/requests}/set_metadata.rb +8 -8
  221. data/lib/fog/{google/requests/compute → compute/google/requests}/set_server_disk_auto_delete.rb +6 -6
  222. data/lib/fog/{google/requests/compute → compute/google/requests}/set_server_scheduling.rb +7 -7
  223. data/lib/fog/{google/requests/compute → compute/google/requests}/set_tags.rb +6 -6
  224. data/lib/fog/{google/requests/compute → compute/google/requests}/set_target_http_proxy_url_map.rb +5 -5
  225. data/lib/fog/{google/requests/compute → compute/google/requests}/start_server.rb +4 -4
  226. data/lib/fog/{google/requests/compute → compute/google/requests}/stop_server.rb +4 -4
  227. data/lib/fog/{google/requests/compute → compute/google/requests}/update_url_map.rb +8 -8
  228. data/lib/fog/{google/requests/compute → compute/google/requests}/validate_url_map.rb +5 -5
  229. data/lib/fog/{google/dns.rb → dns/google.rb} +9 -9
  230. data/lib/fog/{google/models/dns → dns/google/models}/change.rb +5 -7
  231. data/lib/fog/{google/models/dns → dns/google/models}/changes.rb +1 -4
  232. data/lib/fog/{google/models/dns → dns/google/models}/project.rb +6 -8
  233. data/lib/fog/{google/models/dns → dns/google/models}/projects.rb +0 -3
  234. data/lib/fog/{google/models/dns → dns/google/models}/record.rb +17 -27
  235. data/lib/fog/{google/models/dns → dns/google/models}/records.rb +2 -5
  236. data/lib/fog/{google/models/dns → dns/google/models}/zone.rb +6 -8
  237. data/lib/fog/{google/models/dns → dns/google/models}/zones.rb +1 -4
  238. data/lib/fog/{google/requests/dns → dns/google/requests}/create_change.rb +17 -17
  239. data/lib/fog/dns/google/requests/create_managed_zone.rb +82 -0
  240. data/lib/fog/{google/requests/dns → dns/google/requests}/delete_managed_zone.rb +6 -6
  241. data/lib/fog/{google/requests/dns → dns/google/requests}/get_change.rb +7 -7
  242. data/lib/fog/{google/requests/dns → dns/google/requests}/get_managed_zone.rb +4 -4
  243. data/lib/fog/{google/requests/dns → dns/google/requests}/get_project.rb +12 -12
  244. data/lib/fog/{google/requests/dns → dns/google/requests}/list_changes.rb +7 -7
  245. data/lib/fog/{google/requests/dns → dns/google/requests}/list_managed_zones.rb +5 -5
  246. data/lib/fog/{google/requests/dns → dns/google/requests}/list_resource_record_sets.rb +11 -11
  247. data/lib/fog/google.rb +78 -71
  248. data/lib/fog/google/models/monitoring/metric_descriptor.rb +3 -3
  249. data/lib/fog/google/models/monitoring/metric_descriptors.rb +3 -3
  250. data/lib/fog/google/models/monitoring/timeseries.rb +2 -2
  251. data/lib/fog/google/models/monitoring/timeseries_collection.rb +3 -3
  252. data/lib/fog/google/models/monitoring/timeseries_descriptor.rb +1 -1
  253. data/lib/fog/google/models/monitoring/timeseries_descriptors.rb +3 -3
  254. data/lib/fog/google/models/sql/backup_run.rb +8 -8
  255. data/lib/fog/google/models/sql/backup_runs.rb +3 -3
  256. data/lib/fog/google/models/sql/flag.rb +5 -5
  257. data/lib/fog/google/models/sql/flags.rb +3 -3
  258. data/lib/fog/google/models/sql/instance.rb +54 -68
  259. data/lib/fog/google/models/sql/instances.rb +4 -4
  260. data/lib/fog/google/models/sql/operation.rb +15 -15
  261. data/lib/fog/google/models/sql/operations.rb +5 -5
  262. data/lib/fog/google/models/sql/ssl_cert.rb +17 -19
  263. data/lib/fog/google/models/sql/ssl_certs.rb +5 -5
  264. data/lib/fog/google/models/sql/tier.rb +3 -3
  265. data/lib/fog/google/models/sql/tiers.rb +3 -3
  266. data/lib/fog/google/monitoring.rb +8 -8
  267. data/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +131 -131
  268. data/lib/fog/google/requests/monitoring/list_timeseries.rb +32 -32
  269. data/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb +50 -50
  270. data/lib/fog/google/requests/sql/clone_instance.rb +41 -41
  271. data/lib/fog/google/requests/sql/delete_instance.rb +26 -26
  272. data/lib/fog/google/requests/sql/delete_ssl_cert.rb +27 -27
  273. data/lib/fog/google/requests/sql/export_instance.rb +22 -22
  274. data/lib/fog/google/requests/sql/get_backup_run.rb +5 -5
  275. data/lib/fog/google/requests/sql/get_instance.rb +12 -12
  276. data/lib/fog/google/requests/sql/get_operation.rb +21 -21
  277. data/lib/fog/google/requests/sql/get_ssl_cert.rb +21 -21
  278. data/lib/fog/google/requests/sql/import_instance.rb +21 -21
  279. data/lib/fog/google/requests/sql/insert_instance.rb +76 -78
  280. data/lib/fog/google/requests/sql/insert_ssl_cert.rb +33 -33
  281. data/lib/fog/google/requests/sql/list_backup_runs.rb +4 -4
  282. data/lib/fog/google/requests/sql/list_flags.rb +84 -84
  283. data/lib/fog/google/requests/sql/list_instances.rb +3 -3
  284. data/lib/fog/google/requests/sql/list_operations.rb +13 -13
  285. data/lib/fog/google/requests/sql/list_ssl_certs.rb +13 -13
  286. data/lib/fog/google/requests/sql/list_tiers.rb +39 -39
  287. data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +16 -16
  288. data/lib/fog/google/requests/sql/restart_instance.rb +16 -16
  289. data/lib/fog/google/requests/sql/restore_instance_backup.rb +5 -5
  290. data/lib/fog/google/requests/sql/set_instance_root_password.rb +20 -20
  291. data/lib/fog/google/requests/sql/update_instance.rb +52 -52
  292. data/lib/fog/google/sql.rb +7 -7
  293. data/lib/fog/google/version.rb +1 -1
  294. data/lib/fog/parsers/storage/google.rb +15 -0
  295. data/lib/fog/{google/parsers/storage → parsers/storage/google}/access_control_list.rb +13 -13
  296. data/lib/fog/{google/parsers/storage → parsers/storage/google}/copy_object.rb +3 -3
  297. data/lib/fog/parsers/storage/google/get_bucket.rb +58 -0
  298. data/lib/fog/parsers/storage/google/get_bucket_logging.rb +36 -0
  299. data/lib/fog/parsers/storage/google/get_bucket_object_versions.rb +84 -0
  300. data/lib/fog/{google/parsers/storage → parsers/storage/google}/get_bucket_versioning.rb +3 -3
  301. data/lib/fog/{google/parsers/storage → parsers/storage/google}/get_request_payment.rb +1 -1
  302. data/lib/fog/{google/parsers/storage → parsers/storage/google}/get_service.rb +8 -8
  303. data/lib/fog/storage/google.rb +20 -0
  304. data/lib/fog/storage/google_json.rb +146 -0
  305. data/lib/fog/storage/google_json/models/directories.rb +26 -0
  306. data/lib/fog/storage/google_json/models/directory.rb +65 -0
  307. data/lib/fog/storage/google_json/models/file.rb +148 -0
  308. data/lib/fog/storage/google_json/models/files.rb +89 -0
  309. data/lib/fog/storage/google_json/requests/copy_object.rb +66 -0
  310. data/lib/fog/storage/google_json/requests/delete_bucket.rb +42 -0
  311. data/lib/fog/{google/requests/storage → storage/google_json/requests}/delete_object.rb +12 -12
  312. data/lib/fog/storage/google_json/requests/get_bucket.rb +86 -0
  313. data/lib/fog/{google/requests/storage → storage/google_json/requests}/get_bucket_acl.rb +12 -17
  314. data/lib/fog/storage/google_json/requests/get_object.rb +98 -0
  315. data/lib/fog/storage/google_json/requests/get_object_acl.rb +59 -0
  316. data/lib/fog/storage/google_json/requests/get_object_http_url.rb +40 -0
  317. data/lib/fog/storage/google_json/requests/get_object_https_url.rb +41 -0
  318. data/lib/fog/storage/google_json/requests/get_object_torrent.rb +13 -0
  319. data/lib/fog/storage/google_json/requests/get_object_url.rb +22 -0
  320. data/lib/fog/storage/google_json/requests/get_service.rb +54 -0
  321. data/lib/fog/storage/google_json/requests/head_object.rb +54 -0
  322. data/lib/fog/storage/google_json/requests/put_bucket.rb +68 -0
  323. data/lib/fog/storage/google_json/requests/put_bucket_acl.rb +34 -0
  324. data/lib/fog/storage/google_json/requests/put_object.rb +118 -0
  325. data/lib/fog/storage/google_json/requests/put_object_acl.rb +31 -0
  326. data/lib/fog/storage/google_json/requests/put_object_url.rb +45 -0
  327. data/lib/fog/{google/storage.rb → storage/google_xml.rb} +49 -53
  328. data/lib/fog/storage/google_xml/models/directories.rb +34 -0
  329. data/lib/fog/{google/models/storage → storage/google_xml/models}/directory.rb +13 -21
  330. data/lib/fog/{google/models/storage → storage/google_xml/models}/file.rb +34 -46
  331. data/lib/fog/{google/models/storage → storage/google_xml/models}/files.rb +21 -30
  332. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/copy_object.rb +15 -21
  333. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/delete_bucket.rb +10 -12
  334. data/lib/fog/storage/google_xml/requests/delete_object.rb +44 -0
  335. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_bucket.rb +33 -43
  336. data/lib/fog/storage/google_xml/requests/get_bucket_acl.rb +53 -0
  337. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object.rb +25 -37
  338. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object_acl.rb +16 -24
  339. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object_http_url.rb +8 -12
  340. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object_https_url.rb +8 -12
  341. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object_torrent.rb +10 -16
  342. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_object_url.rb +1 -1
  343. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/get_service.rb +13 -17
  344. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/head_object.rb +14 -20
  345. data/lib/fog/storage/google_xml/requests/put_bucket.rb +71 -0
  346. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/put_bucket_acl.rb +12 -14
  347. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/put_object.rb +23 -27
  348. data/lib/fog/{google/requests/storage → storage/google_xml/requests}/put_object_acl.rb +12 -14
  349. data/lib/fog/storage/google_xml/requests/put_object_url.rb +42 -0
  350. data/tasks/bundler.rake +3 -0
  351. data/tasks/console.rake +12 -0
  352. data/tasks/lint.rake +3 -0
  353. data/tasks/smoke.rake +15 -0
  354. data/tasks/test.rake +13 -0
  355. data/test/helpers/integration_test_helper.rb +3 -3
  356. data/test/helpers/test_collection.rb +1 -1
  357. data/test/helpers/test_helper.rb +8 -8
  358. data/test/integration/compute/test_servers.rb +1 -1
  359. data/test/integration/factories/backend_services_factory.rb +2 -2
  360. data/test/integration/factories/collection_factory.rb +4 -4
  361. data/test/integration/factories/disks_factory.rb +3 -3
  362. data/test/integration/factories/forwarding_rules_factory.rb +3 -4
  363. data/test/integration/factories/global_forwarding_rules_factory.rb +2 -2
  364. data/test/integration/factories/http_health_checks_factory.rb +1 -1
  365. data/test/integration/factories/images_factory.rb +2 -2
  366. data/test/integration/factories/servers_factory.rb +4 -4
  367. data/test/integration/factories/target_http_proxies_factory.rb +2 -2
  368. data/test/integration/factories/target_instances_factory.rb +3 -3
  369. data/test/integration/factories/target_pools_factory.rb +4 -4
  370. data/test/integration/factories/url_maps_factory.rb +2 -2
  371. data/test/integration/storage/test_buckets.rb +56 -0
  372. data/test/integration/storage/test_directories.rb +60 -0
  373. data/test/integration/storage/test_files.rb +132 -0
  374. data/test/integration/storage/test_objects.rb +111 -0
  375. data/test/integration/test_authentication.rb +14 -10
  376. data/tests/helper.rb +40 -42
  377. data/tests/helpers/collection_helper.rb +26 -37
  378. data/tests/helpers/compute/flavors_helper.rb +4 -8
  379. data/tests/helpers/compute/server_helper.rb +1 -5
  380. data/tests/helpers/compute/servers_helper.rb +0 -2
  381. data/tests/helpers/formats_helper.rb +12 -12
  382. data/tests/helpers/formats_helper_tests.rb +43 -47
  383. data/tests/helpers/mock_helper.rb +6 -8
  384. data/tests/helpers/model_helper.rb +6 -10
  385. data/tests/helpers/schema_validator_tests.rb +41 -47
  386. data/tests/helpers/succeeds_helper.rb +1 -1
  387. data/tests/models/dns/change_tests.rb +8 -10
  388. data/tests/models/dns/changes_tests.rb +8 -12
  389. data/tests/models/dns/projects_tests.rb +2 -5
  390. data/tests/models/dns/record_tests.rb +9 -10
  391. data/tests/models/dns/records_tests.rb +9 -13
  392. data/tests/models/dns/zone_tests.rb +6 -6
  393. data/tests/models/dns/zones_tests.rb +5 -5
  394. data/tests/models/monitoring/metric_descriptors_tests.rb +2 -5
  395. data/tests/models/monitoring/timeseries_collection_tests.rb +3 -6
  396. data/tests/models/monitoring/timeseries_descriptors_tests.rb +3 -6
  397. data/tests/models/sql/flags_tests.rb +2 -5
  398. data/tests/models/sql/instance_tests.rb +4 -7
  399. data/tests/models/sql/instances_tests.rb +4 -9
  400. data/tests/models/sql/operation_tests.rb +3 -6
  401. data/tests/models/sql/operations_tests.rb +4 -9
  402. data/tests/models/sql/ssl_cert_tests.rb +3 -6
  403. data/tests/models/sql/ssl_certs_tests.rb +4 -9
  404. data/tests/models/sql/tiers_tests.rb +2 -5
  405. data/tests/requests/compute/backend_service_tests.rb +43 -47
  406. data/tests/requests/compute/disk_tests.rb +42 -46
  407. data/tests/requests/compute/disk_type_tests.rb +18 -21
  408. data/tests/requests/compute/firewall_tests.rb +42 -45
  409. data/tests/requests/compute/forwarding_rules_tests.rb +44 -48
  410. data/tests/requests/compute/global_forwarding_rules_tests.rb +44 -48
  411. data/tests/requests/compute/http_health_checks_tests.rb +44 -48
  412. data/tests/requests/compute/image_tests.rb +41 -45
  413. data/tests/requests/compute/network_tests.rb +38 -41
  414. data/tests/requests/compute/operation_tests.rb +2 -3
  415. data/tests/requests/compute/region_tests.rb +18 -18
  416. data/tests/requests/compute/server_tests.rb +45 -47
  417. data/tests/requests/compute/target_http_proxies_test.rb +39 -43
  418. data/tests/requests/compute/target_instances_tests.rb +43 -47
  419. data/tests/requests/compute/target_pools_tests.rb +43 -47
  420. data/tests/requests/compute/url_maps_tests.rb +42 -46
  421. data/tests/requests/compute/zone_tests.rb +15 -19
  422. data/tests/requests/dns/change_tests.rb +18 -22
  423. data/tests/requests/dns/managed_zone_tests.rb +27 -30
  424. data/tests/requests/dns/project_tests.rb +13 -16
  425. data/tests/requests/dns/record_tests.rb +15 -18
  426. data/tests/requests/monitoring/metric_descriptor_tests.rb +9 -12
  427. data/tests/requests/monitoring/timeseries_collection_tests.rb +9 -12
  428. data/tests/requests/monitoring/timeseries_descriptor_tests.rb +10 -13
  429. data/tests/requests/sql/flag_tests.rb +11 -14
  430. data/tests/requests/sql/instance_tests.rb +36 -39
  431. data/tests/requests/sql/operation_tests.rb +17 -20
  432. data/tests/requests/sql/ssl_cert_tests.rb +21 -24
  433. data/tests/requests/sql/tier_tests.rb +9 -12
  434. data/tests/requests/storage/bucket_tests.rb +30 -36
  435. data/tests/requests/storage/object_tests.rb +21 -27
  436. metadata +309 -235
  437. data/examples/eric-fail.rb +0 -36
  438. data/examples/image_all.rb +0 -6
  439. data/examples/launch_micro_instance.rb +0 -29
  440. data/gemfiles/Gemfile.2.0.0+ +0 -6
  441. data/gemfiles/Gemfile.2.0.0- +0 -10
  442. data/lib/fog/google/models/compute/flavor.rb +0 -33
  443. data/lib/fog/google/models/compute/global_forwarding_rule.rb +0 -86
  444. data/lib/fog/google/models/compute/http_health_check.rb +0 -84
  445. data/lib/fog/google/models/compute/snapshot.rb +0 -48
  446. data/lib/fog/google/models/compute/zone.rb +0 -23
  447. data/lib/fog/google/models/storage/directories.rb +0 -39
  448. data/lib/fog/google/parsers/storage/get_bucket.rb +0 -58
  449. data/lib/fog/google/parsers/storage/get_bucket_logging.rb +0 -36
  450. data/lib/fog/google/parsers/storage/get_bucket_object_versions.rb +0 -84
  451. data/lib/fog/google/requests/compute/attach_disk.rb +0 -34
  452. data/lib/fog/google/requests/compute/get_disk.rb +0 -52
  453. data/lib/fog/google/requests/compute/get_disk_type.rb +0 -42
  454. data/lib/fog/google/requests/compute/get_forwarding_rule.rb +0 -46
  455. data/lib/fog/google/requests/compute/get_global_forwarding_rule.rb +0 -32
  456. data/lib/fog/google/requests/compute/get_http_health_check.rb +0 -39
  457. data/lib/fog/google/requests/compute/get_machine_type.rb +0 -43
  458. data/lib/fog/google/requests/compute/get_server.rb +0 -75
  459. data/lib/fog/google/requests/compute/get_target_instance.rb +0 -32
  460. data/lib/fog/google/requests/compute/list_aggregated_disk_types.rb +0 -40
  461. data/lib/fog/google/requests/compute/list_aggregated_disks.rb +0 -40
  462. data/lib/fog/google/requests/compute/list_aggregated_servers.rb +0 -40
  463. data/lib/fog/google/requests/compute/list_backend_services.rb +0 -29
  464. data/lib/fog/google/requests/compute/list_disk_types.rb +0 -46
  465. data/lib/fog/google/requests/compute/list_disks.rb +0 -29
  466. data/lib/fog/google/requests/compute/list_forwarding_rules.rb +0 -29
  467. data/lib/fog/google/requests/compute/list_global_forwarding_rules.rb +0 -30
  468. data/lib/fog/google/requests/compute/list_http_health_checks.rb +0 -29
  469. data/lib/fog/google/requests/compute/list_images.rb +0 -29
  470. data/lib/fog/google/requests/compute/list_regions.rb +0 -85
  471. data/lib/fog/google/requests/compute/list_servers.rb +0 -31
  472. data/lib/fog/google/requests/compute/list_target_http_proxies.rb +0 -30
  473. data/lib/fog/google/requests/compute/list_target_instances.rb +0 -30
  474. data/lib/fog/google/requests/compute/list_target_pools.rb +0 -29
  475. data/lib/fog/google/requests/compute/list_url_maps.rb +0 -29
  476. data/lib/fog/google/requests/compute/list_zones.rb +0 -28
  477. data/lib/fog/google/requests/dns/create_managed_zone.rb +0 -82
  478. data/lib/fog/google/requests/storage/put_bucket.rb +0 -71
  479. data/lib/fog/google/requests/storage/put_object_url.rb +0 -50
@@ -0,0 +1,54 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Real
5
+ # Get headers for an object from Google Storage
6
+ # https://cloud.google.com/storage/docs/json_api/v1/objects/get
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - Name of bucket to read from
10
+ # * object_name<~String> - Name of object to read
11
+ # * options<~Hash>:
12
+ # * 'If-Match'<~String> - Returns object only if its etag matches this value, otherwise returns 412 (Precondition Failed).
13
+ # * 'If-Modified-Since'<~Time> - Returns object only if it has been modified since this time, otherwise returns 304 (Not Modified).
14
+ # * 'If-None-Match'<~String> - Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
15
+ # * 'If-Unmodified-Since'<~Time> - Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
16
+ # * 'Range'<~String> - Range of object to download
17
+ # * 'versionId'<~String> - specify a particular version to retrieve
18
+ #
19
+ # ==== Returns
20
+ # * response<~Excon::Response>:
21
+ # * body<~String> - Contents of object
22
+ # * headers<~Hash>:
23
+ # * 'Content-Length'<~String> - Size of object contents
24
+ # * 'Content-Type'<~String> - MIME type of object
25
+ # * 'ETag'<~String> - Etag of object
26
+ # * 'Last-Modified'<~String> - Last modified timestamp for object
27
+ def head_object(bucket_name, object_name, _options = {})
28
+ raise ArgumentError.new("bucket_name is required") unless bucket_name
29
+ raise ArgumentError.new("object_name is required") unless object_name
30
+
31
+ api_method = @storage_json.objects.get
32
+ parameters = {
33
+ "bucket" => bucket_name,
34
+ "object" => object_name,
35
+ "projection" => "full"
36
+ }
37
+
38
+ object = request(api_method, parameters)
39
+ object.headers = object.body
40
+ object.body = nil
41
+ object
42
+ end
43
+ end
44
+
45
+ class Mock
46
+ def head_object(bucket_name, object_name, options = {})
47
+ response = get_object(bucket_name, object_name, options)
48
+ response.body = nil
49
+ response
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Real
5
+ # Create an Google Storage bucket
6
+ # https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to create
10
+ # * options<~Hash> - config arguments for bucket. Defaults to {}.
11
+ # * 'LocationConstraint'<~Symbol> - sets the location for the bucket
12
+ # * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * status<~Integer> - 200
17
+ def put_bucket(bucket_name, options = {})
18
+ location = options["LocationConstraint"] if options["LocationConstraint"]
19
+
20
+ api_method = @storage_json.buckets.insert
21
+ parameters = {
22
+ "project" => @project,
23
+ "projection" => "full"
24
+ }
25
+ body_object = {
26
+ "name" => bucket_name,
27
+ "location" => location
28
+ }
29
+ parameters.merge! options
30
+
31
+ request(api_method, parameters, body_object = body_object)
32
+ end
33
+ end
34
+
35
+ class Mock
36
+ def put_bucket(bucket_name, options = {})
37
+ acl = options["x-goog-acl"] || "private"
38
+ if !%w(private publicRead publicReadWrite authenticatedRead).include?(acl)
39
+ raise Excon::Errors::BadRequest.new("invalid x-goog-acl")
40
+ else
41
+ data[:acls][:bucket][bucket_name] = self.class.acls(options[acl])
42
+ end
43
+ response = Excon::Response.new
44
+ response.status = 200
45
+ bucket = {
46
+ :objects => {},
47
+ "Name" => bucket_name,
48
+ "CreationDate" => Time.now,
49
+ "Owner" => { "DisplayName" => "owner", "ID" => "some_id" },
50
+ "Payer" => "BucketOwner"
51
+ }
52
+ if options["LocationConstraint"]
53
+ bucket["LocationConstraint"] = options["LocationConstraint"]
54
+ else
55
+ bucket["LocationConstraint"] = ""
56
+ end
57
+ if data[:buckets][bucket_name].nil?
58
+ data[:buckets][bucket_name] = bucket
59
+ else
60
+ response.status = 409
61
+ raise(Excon::Errors.status_error({ :expects => 200 }, response))
62
+ end
63
+ response
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Mock
5
+ def put_bucket_acl(_bucket_name, _acl)
6
+ Fog::Mock.not_implemented
7
+ end
8
+ end
9
+
10
+ class Real
11
+ # Change access control list for an Google Storage bucket
12
+ # https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/insert
13
+ #
14
+ # ==== Parameters
15
+ # * bucket_name<~String> - name of bucket to create
16
+ # * acl<~Hash> - ACL hash to add to bucket, see GCS documentation above
17
+ # * entity
18
+ # * role
19
+ def put_bucket_acl(bucket_name, acl)
20
+ raise ArgumentError.new("bucket_name is required") unless bucket_name
21
+ raise ArgumentError.new("acl is required") unless acl
22
+
23
+ api_method = @storage_json.bucket_access_controls.insert
24
+ parameters = {
25
+ "bucket" => bucket_name
26
+ }
27
+ body_object = acl
28
+
29
+ request(api_method, parameters, body_object = body_object)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,118 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Real
5
+ # Create an object in an Google Storage bucket
6
+ # https://cloud.google.com/storage/docs/json_api/v1/objects/insert
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - Name of bucket to create object in
10
+ # * object_name<~String> - Name of object to create
11
+ # * data<~File> - File or String to create object from
12
+ # * options<~Hash>:
13
+ # * 'Cache-Control'<~String> - Caching behaviour
14
+ # * 'Content-Disposition'<~String> - Presentational information for the object
15
+ # * 'Content-Encoding'<~String> - Encoding of object data
16
+ # * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)
17
+ # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
18
+ # * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
19
+ # * 'x-goog-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
20
+ # * "x-goog-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
21
+ #
22
+ # ==== Returns
23
+ # * response<~Excon::Response>:
24
+ # * headers<~Hash>:
25
+ # * 'ETag'<~String> - etag of new object
26
+ def put_object(bucket_name, object_name, data, options = {})
27
+ if options["contentType"]
28
+ mime_type = options["contentType"]
29
+ if data.is_a? String
30
+ data = StringIO.new(data)
31
+ end
32
+ elsif data.is_a? String
33
+ data = StringIO.new(data)
34
+ mime_type = "text/plain"
35
+ elsif data.is_a? File
36
+ mime_type = Fog::Storage.parse_data(data)[:headers]["Content-Type"]
37
+ end
38
+
39
+ media = ::Google::APIClient::UploadIO.new(data, mime_type, object_name)
40
+ api_method = @storage_json.objects.insert
41
+ parameters = {
42
+ "uploadType" => "multipart",
43
+ "bucket" => bucket_name,
44
+ "name" => object_name
45
+ }
46
+
47
+ body_object = {
48
+ :contentType => mime_type,
49
+ :contentEncoding => options["contentEncoding"],
50
+ }
51
+ body_object.merge! options
52
+
53
+ acl = []
54
+ case options["predefinedAcl"]
55
+ when "publicRead"
56
+ acl.push({ "entity" => "allUsers", "role" => "READER" })
57
+ when "publicReadWrite"
58
+ acl.push({ "entity" => "allUsers", "role" => "OWNER" })
59
+ when "authenticatedRead"
60
+ acl.push({ "entity" => "allAuthenticatedUsers", "role" => "READER" })
61
+ end
62
+
63
+ unless acl.empty?
64
+ body_object[:acl] = acl
65
+ end
66
+
67
+ request(api_method, parameters, body_object = body_object, media = media)
68
+ end
69
+ end
70
+
71
+ class Mock
72
+ def put_object(bucket_name, object_name, data, options = {})
73
+ acl = options["x-goog-acl"] || "private"
74
+ if !%w(private publicRead publicReadWrite authenticatedRead).include?(acl)
75
+ raise Excon::Errors::BadRequest.new("invalid x-goog-acl")
76
+ else
77
+ self.data[:acls][:object][bucket_name] ||= {}
78
+ self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
79
+ end
80
+
81
+ data = Fog::Storage.parse_data(data)
82
+ data[:body] = data[:body].read unless data[:body].is_a?(String)
83
+ response = Excon::Response.new
84
+ if (bucket = self.data[:buckets][bucket_name])
85
+ response.status = 200
86
+ object = {
87
+ :body => data[:body],
88
+ "Content-Type" => options["Content-Type"] || data[:headers]["Content-Type"],
89
+ "ETag" => Fog::Google::Mock.etag,
90
+ "Key" => object_name,
91
+ "Last-Modified" => Fog::Time.now.to_date_header,
92
+ "Content-Length" => options["Content-Length"] || data[:headers]["Content-Length"]
93
+ }
94
+
95
+ for key, value in options
96
+ case key
97
+ when "Cache-Control", "Content-Disposition", "Content-Encoding", "Content-MD5", "Expires", /^x-goog-meta-/
98
+ object[key] = value
99
+ end
100
+ end
101
+
102
+ bucket[:objects][object_name] = object
103
+ response.headers = {
104
+ "Content-Length" => object["Content-Length"],
105
+ "Content-Type" => object["Content-Type"],
106
+ "ETag" => object["ETag"],
107
+ "Last-Modified" => object["Last-Modified"]
108
+ }
109
+ else
110
+ response.status = 404
111
+ raise(Excon::Errors.status_error({ :expects => 200 }, response))
112
+ end
113
+ response
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Real
5
+ # Change access control list for an Google Storage object
6
+ # https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/insert
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket object is in
10
+ # * object_name<~String> - name of object to add ACL to
11
+ # * acl<~Hash> - ACL hash to add to bucket, see GCS documentation above
12
+ # * entity
13
+ # * role
14
+ def put_object_acl(bucket_name, object_name, acl)
15
+ raise ArgumentError.new("bucket_name is required") unless bucket_name
16
+ raise ArgumentError.new("object_name is required") unless object_name
17
+ raise ArgumentError.new("acl is required") unless acl
18
+
19
+ api_method = @storage_json.object_access_controls.insert
20
+ parameters = {
21
+ "bucket" => bucket_name,
22
+ "object" => object_name
23
+ }
24
+ body_object = acl
25
+
26
+ request(api_method, parameters, body_object = body_object)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Storage
3
+ class GoogleJSON
4
+ class Real
5
+ # Get an expiring object url from Google Storage for putting an object
6
+ #
7
+ # ==== Parameters
8
+ # * bucket_name<~String> - Name of bucket containing object
9
+ # * object_name<~String> - Name of object to get expiring url for
10
+ # * expires<~Time> - An expiry time for this url
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~String> - url for object
15
+ #
16
+ # ==== See Also
17
+ # https://cloud.google.com/storage/docs/access-control#Signed-URLs
18
+ #
19
+ def put_object_url(bucket_name, object_name, headers = {})
20
+ raise ArgumentError.new("bucket_name is required") unless bucket_name
21
+ raise ArgumentError.new("object_name is required") unless object_name
22
+ https_url({
23
+ :headers => headers,
24
+ :host => @host,
25
+ :method => "PUT",
26
+ :path => "#{bucket_name}/#{object_name}"
27
+ }, expires)
28
+ end
29
+ end
30
+
31
+ class Mock
32
+ def put_object_url(bucket_name, object_name, expires, headers = {})
33
+ raise ArgumentError.new("bucket_name is required") unless bucket_name
34
+ raise ArgumentError.new("object_name is required") unless object_name
35
+ https_url({
36
+ :headers => headers,
37
+ :host => @host,
38
+ :method => "PUT",
39
+ :path => "#{bucket_name}/#{object_name}"
40
+ }, expires)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,16 +1,16 @@
1
1
  module Fog
2
2
  module Storage
3
- class Google < Fog::Service
3
+ class GoogleXML < Fog::Service
4
4
  requires :google_storage_access_key_id, :google_storage_secret_access_key
5
5
  recognizes :host, :port, :scheme, :persistent, :path_style
6
6
 
7
- model_path 'fog/google/models/storage'
8
- collection :directories
9
- model :directory
10
- collection :files
11
- model :file
7
+ model_path "fog/storage/google_xml/models"
8
+ collection :directories
9
+ model :directory
10
+ collection :files
11
+ model :file
12
12
 
13
- request_path 'fog/google/requests/storage'
13
+ request_path "fog/storage/google_xml/requests"
14
14
  request :copy_object
15
15
  request :delete_bucket
16
16
  request :delete_object
@@ -47,8 +47,8 @@ module Fog
47
47
  private
48
48
 
49
49
  def host_path_query(params, expires)
50
- params[:headers]['Date'] = expires.to_i
51
- params[:path] = CGI.escape(params[:path]).gsub('%2F', '/')
50
+ params[:headers]["Date"] = expires.to_i
51
+ params[:path] = CGI.escape(params[:path]).gsub("%2F", "/")
52
52
  query = [params[:query]].compact
53
53
  query << "GoogleAccessId=#{@google_storage_access_key_id}"
54
54
  query << "Signature=#{CGI.escape(signature(params))}"
@@ -58,7 +58,7 @@ module Fog
58
58
 
59
59
  def request_params(params)
60
60
  subdomain = params[:host].split(".#{@host}").first
61
- if @path_style or subdomain !~ /^(?!goog)(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
61
+ if @path_style || subdomain !~ /^(?!goog)(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
62
62
  if subdomain =~ /_/
63
63
  # https://github.com/fog/fog/pull/1258#issuecomment-10248620.
64
64
  Fog::Logger.warning("fog: the specified google storage bucket name (#{subdomain}) is not DNS compliant (only characters a through z, digits 0 through 9, and the hyphen).")
@@ -81,12 +81,10 @@ module Fog
81
81
  subdomain = nil
82
82
  end
83
83
 
84
- if subdomain && subdomain != @host
85
- params[:subdomain] = subdomain
86
- end
84
+ params[:subdomain] = subdomain if subdomain && subdomain != @host
87
85
 
88
86
  params[:scheme] ||= @scheme
89
- params[:port] ||= @port
87
+ params[:port] ||= @port
90
88
  params
91
89
  end
92
90
  end
@@ -96,61 +94,61 @@ module Fog
96
94
 
97
95
  def self.acls(type)
98
96
  case type
99
- when 'private'
97
+ when "private"
100
98
  {
101
- "AccessControlList"=> [
99
+ "AccessControlList" => [
102
100
  {
103
101
  "Permission" => "FULL_CONTROL",
104
- "Scope" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById"}
102
+ "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
105
103
  }
106
104
  ],
107
- "Owner" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
105
+ "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
108
106
  }
109
- when 'public-read'
107
+ when "public-read"
110
108
  {
111
- "AccessControlList"=> [
109
+ "AccessControlList" => [
112
110
  {
113
111
  "Permission" => "FULL_CONTROL",
114
- "Scope" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById"}
112
+ "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
115
113
  },
116
114
  {
117
115
  "Permission" => "READ",
118
- "Scope" => {"type" => "AllUsers"}
116
+ "Scope" => { "type" => "AllUsers" }
119
117
  }
120
118
  ],
121
- "Owner" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
119
+ "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
122
120
  }
123
- when 'public-read-write'
121
+ when "public-read-write"
124
122
  {
125
- "AccessControlList"=> [
123
+ "AccessControlList" => [
126
124
  {
127
125
  "Permission" => "FULL_CONTROL",
128
- "Scope" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById"}
126
+ "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
129
127
  },
130
128
  {
131
129
  "Permission" => "READ",
132
- "Scope" => {"type" => "AllUsers"}
130
+ "Scope" => { "type" => "AllUsers" }
133
131
  },
134
132
  {
135
133
  "Permission" => "WRITE",
136
- "Scope" => {"type" => "AllUsers"}
134
+ "Scope" => { "type" => "AllUsers" }
137
135
  }
138
136
  ],
139
- "Owner" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
137
+ "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
140
138
  }
141
- when 'authenticated-read'
139
+ when "authenticated-read"
142
140
  {
143
- "AccessControlList"=> [
141
+ "AccessControlList" => [
144
142
  {
145
143
  "Permission" => "FULL_CONTROL",
146
- "Scope" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById"}
144
+ "Scope" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById" }
147
145
  },
148
146
  {
149
147
  "Permission" => "READ",
150
- "Scope" => {"type" => "AllAuthenticatedUsers"}
148
+ "Scope" => { "type" => "AllAuthenticatedUsers" }
151
149
  }
152
150
  ],
153
- "Owner" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
151
+ "Owner" => { "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0" }
154
152
  }
155
153
  end
156
154
  end
@@ -171,7 +169,7 @@ module Fog
171
169
  @data = nil
172
170
  end
173
171
 
174
- def initialize(options={})
172
+ def initialize(options = {})
175
173
  @google_storage_access_key_id = options[:google_storage_access_key_id]
176
174
  end
177
175
 
@@ -183,7 +181,7 @@ module Fog
183
181
  self.class.data.delete(@google_storage_access_key_id)
184
182
  end
185
183
 
186
- def signature(params)
184
+ def signature(_params)
187
185
  "foo"
188
186
  end
189
187
  end
@@ -208,17 +206,16 @@ module Fog
208
206
  #
209
207
  # ==== Returns
210
208
  # * Storage object with connection to google.
211
- def initialize(options={})
212
-
209
+ def initialize(options = {})
213
210
  @google_storage_access_key_id = options[:google_storage_access_key_id]
214
211
  @google_storage_secret_access_key = options[:google_storage_secret_access_key]
215
212
  @connection_options = options[:connection_options] || {}
216
- @hmac = Fog::HMAC.new('sha1', @google_storage_secret_access_key)
217
- @host = options[:host] || 'storage.googleapis.com'
213
+ @hmac = Fog::HMAC.new("sha1", @google_storage_secret_access_key)
214
+ @host = options[:host] || "storage.googleapis.com"
218
215
  @persistent = options.fetch(:persistent, true)
219
- @port = options[:port] || 443
220
- @scheme = options[:scheme] || 'https'
221
- @path_style = options[:path_style] || false
216
+ @port = options[:port] || 443
217
+ @scheme = options[:scheme] || "https"
218
+ @path_style = options[:path_style] || false
222
219
  end
223
220
 
224
221
  def reload
@@ -234,27 +231,26 @@ module Fog
234
231
  #{params[:headers]['Date']}
235
232
  DATA
236
233
 
237
- google_headers, canonical_google_headers = {}, ''
234
+ google_headers = {}
235
+ canonical_google_headers = ""
238
236
  for key, value in params[:headers]
239
- if key[0..6] == 'x-goog-'
240
- google_headers[key] = value
241
- end
237
+ google_headers[key] = value if key[0..6] == "x-goog-"
242
238
  end
243
239
 
244
- google_headers = google_headers.sort {|x, y| x[0] <=> y[0]}
240
+ google_headers = google_headers.sort { |x, y| x[0] <=> y[0] }
245
241
  for key, value in google_headers
246
242
  canonical_google_headers << "#{key}:#{value}\n"
247
243
  end
248
244
  string_to_sign << "#{canonical_google_headers}"
249
245
 
250
- canonical_resource = "/"
246
+ canonical_resource = "/"
251
247
  if subdomain = params.delete(:subdomain)
252
248
  canonical_resource << "#{CGI.escape(subdomain).downcase}/"
253
249
  end
254
250
  canonical_resource << "#{params[:path]}"
255
- canonical_resource << '?'
251
+ canonical_resource << "?"
256
252
  for key in (params[:query] || {}).keys
257
- if ['acl', 'cors', 'location', 'logging', 'requestPayment', 'torrent', 'versions', 'versioning'].include?(key)
253
+ if %w(acl cors location logging requestPayment torrent versions versioning).include?(key)
258
254
  canonical_resource << "#{key}&"
259
255
  end
260
256
  end
@@ -287,8 +283,8 @@ DATA
287
283
  host = params.delete(:host)
288
284
  port = params.delete(:port)
289
285
 
290
- params[:headers]['Date'] = Fog::Time.now.to_date_header
291
- params[:headers]['Authorization'] = "GOOG1 #{@google_storage_access_key_id}:#{signature(params)}"
286
+ params[:headers]["Date"] = Fog::Time.now.to_date_header
287
+ params[:headers]["Authorization"] = "GOOG1 #{@google_storage_access_key_id}:#{signature(params)}"
292
288
 
293
289
  connection(scheme, host, port).request(params, &block)
294
290
  end