fog-google 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (401) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rubocop.yml +20 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CONTRIBUTING.md +18 -0
  8. data/CONTRIBUTORS.md +41 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.md +20 -0
  11. data/README.md +55 -0
  12. data/Rakefile +34 -0
  13. data/examples/backend_services.rb +22 -0
  14. data/examples/bootstrap.rb +9 -0
  15. data/examples/create.rb +49 -0
  16. data/examples/dns/project.rb +8 -0
  17. data/examples/dns/zones.rb +43 -0
  18. data/examples/eric-fail.rb +36 -0
  19. data/examples/get_list_images.rb +26 -0
  20. data/examples/get_list_snapshots.rb +18 -0
  21. data/examples/image_all.rb +6 -0
  22. data/examples/image_create.rb +17 -0
  23. data/examples/l7_load_balance.rb +73 -0
  24. data/examples/launch_micro_instance.rb +29 -0
  25. data/examples/load-balance.rb +98 -0
  26. data/examples/metadata.rb +30 -0
  27. data/examples/monitoring/metric_descriptors.rb +11 -0
  28. data/examples/monitoring/timeseries_collection.rb +15 -0
  29. data/examples/monitoring/timeseries_descriptors.rb +15 -0
  30. data/examples/network.rb +38 -0
  31. data/examples/precreated_client.rb +14 -0
  32. data/examples/sql/flags.rb +7 -0
  33. data/examples/sql/instances.rb +38 -0
  34. data/examples/sql/operations.rb +20 -0
  35. data/examples/sql/ssl_certs.rb +28 -0
  36. data/examples/sql/tiers.rb +7 -0
  37. data/fog-google.gemspec +37 -0
  38. data/gemfiles/Gemfile.1.9.2+ +6 -0
  39. data/gemfiles/Gemfile.1.9.2- +9 -0
  40. data/lib/fog/bin/google.rb +88 -0
  41. data/lib/fog/google.rb +226 -0
  42. data/lib/fog/google/compute.rb +1068 -0
  43. data/lib/fog/google/dns.rb +96 -0
  44. data/lib/fog/google/models/compute/address.rb +94 -0
  45. data/lib/fog/google/models/compute/addresses.rb +40 -0
  46. data/lib/fog/google/models/compute/backend_service.rb +92 -0
  47. data/lib/fog/google/models/compute/backend_services.rb +22 -0
  48. data/lib/fog/google/models/compute/disk.rb +120 -0
  49. data/lib/fog/google/models/compute/disk_type.rb +28 -0
  50. data/lib/fog/google/models/compute/disk_types.rb +40 -0
  51. data/lib/fog/google/models/compute/disks.rb +41 -0
  52. data/lib/fog/google/models/compute/firewall.rb +46 -0
  53. data/lib/fog/google/models/compute/firewalls.rb +25 -0
  54. data/lib/fog/google/models/compute/flavor.rb +33 -0
  55. data/lib/fog/google/models/compute/flavors.rb +31 -0
  56. data/lib/fog/google/models/compute/forwarding_rule.rb +86 -0
  57. data/lib/fog/google/models/compute/forwarding_rules.rb +41 -0
  58. data/lib/fog/google/models/compute/global_forwarding_rule.rb +86 -0
  59. data/lib/fog/google/models/compute/global_forwarding_rules.rb +23 -0
  60. data/lib/fog/google/models/compute/http_health_check.rb +84 -0
  61. data/lib/fog/google/models/compute/http_health_checks.rb +26 -0
  62. data/lib/fog/google/models/compute/image.rb +90 -0
  63. data/lib/fog/google/models/compute/images.rb +73 -0
  64. data/lib/fog/google/models/compute/network.rb +43 -0
  65. data/lib/fog/google/models/compute/networks.rb +25 -0
  66. data/lib/fog/google/models/compute/operation.rb +75 -0
  67. data/lib/fog/google/models/compute/operations.rb +37 -0
  68. data/lib/fog/google/models/compute/project.rb +30 -0
  69. data/lib/fog/google/models/compute/projects.rb +20 -0
  70. data/lib/fog/google/models/compute/region.rb +32 -0
  71. data/lib/fog/google/models/compute/regions.rb +25 -0
  72. data/lib/fog/google/models/compute/resource_view.rb +116 -0
  73. data/lib/fog/google/models/compute/resource_views.rb +57 -0
  74. data/lib/fog/google/models/compute/route.rb +50 -0
  75. data/lib/fog/google/models/compute/routes.rb +25 -0
  76. data/lib/fog/google/models/compute/server.rb +258 -0
  77. data/lib/fog/google/models/compute/servers.rb +80 -0
  78. data/lib/fog/google/models/compute/snapshot.rb +48 -0
  79. data/lib/fog/google/models/compute/snapshots.rb +26 -0
  80. data/lib/fog/google/models/compute/target_http_proxies.rb +22 -0
  81. data/lib/fog/google/models/compute/target_http_proxy.rb +75 -0
  82. data/lib/fog/google/models/compute/target_instance.rb +74 -0
  83. data/lib/fog/google/models/compute/target_instances.rb +28 -0
  84. data/lib/fog/google/models/compute/target_pool.rb +113 -0
  85. data/lib/fog/google/models/compute/target_pools.rb +41 -0
  86. data/lib/fog/google/models/compute/url_map.rb +95 -0
  87. data/lib/fog/google/models/compute/url_maps.rb +22 -0
  88. data/lib/fog/google/models/compute/zone.rb +23 -0
  89. data/lib/fog/google/models/compute/zones.rb +24 -0
  90. data/lib/fog/google/models/dns/change.rb +40 -0
  91. data/lib/fog/google/models/dns/changes.rb +52 -0
  92. data/lib/fog/google/models/dns/project.rb +75 -0
  93. data/lib/fog/google/models/dns/projects.rb +25 -0
  94. data/lib/fog/google/models/dns/record.rb +112 -0
  95. data/lib/fog/google/models/dns/records.rb +52 -0
  96. data/lib/fog/google/models/dns/zone.rb +74 -0
  97. data/lib/fog/google/models/dns/zones.rb +34 -0
  98. data/lib/fog/google/models/monitoring/metric_descriptor.rb +20 -0
  99. data/lib/fog/google/models/monitoring/metric_descriptors.rb +28 -0
  100. data/lib/fog/google/models/monitoring/timeseries.rb +17 -0
  101. data/lib/fog/google/models/monitoring/timeseries_collection.rb +31 -0
  102. data/lib/fog/google/models/monitoring/timeseries_descriptor.rb +20 -0
  103. data/lib/fog/google/models/monitoring/timeseries_descriptors.rb +31 -0
  104. data/lib/fog/google/models/sql/backup_run.rb +34 -0
  105. data/lib/fog/google/models/sql/backup_runs.rb +38 -0
  106. data/lib/fog/google/models/sql/flag.rb +22 -0
  107. data/lib/fog/google/models/sql/flags.rb +21 -0
  108. data/lib/fog/google/models/sql/instance.rb +353 -0
  109. data/lib/fog/google/models/sql/instances.rb +39 -0
  110. data/lib/fog/google/models/sql/operation.rb +61 -0
  111. data/lib/fog/google/models/sql/operations.rb +49 -0
  112. data/lib/fog/google/models/sql/ssl_cert.rb +73 -0
  113. data/lib/fog/google/models/sql/ssl_certs.rb +49 -0
  114. data/lib/fog/google/models/sql/tier.rb +20 -0
  115. data/lib/fog/google/models/sql/tiers.rb +21 -0
  116. data/lib/fog/google/models/storage/directories.rb +39 -0
  117. data/lib/fog/google/models/storage/directory.rb +74 -0
  118. data/lib/fog/google/models/storage/file.rb +144 -0
  119. data/lib/fog/google/models/storage/files.rb +104 -0
  120. data/lib/fog/google/monitoring.rb +87 -0
  121. data/lib/fog/google/parsers/storage/access_control_list.rb +44 -0
  122. data/lib/fog/google/parsers/storage/copy_object.rb +18 -0
  123. data/lib/fog/google/parsers/storage/get_bucket.rb +58 -0
  124. data/lib/fog/google/parsers/storage/get_bucket_logging.rb +36 -0
  125. data/lib/fog/google/parsers/storage/get_bucket_object_versions.rb +84 -0
  126. data/lib/fog/google/parsers/storage/get_bucket_versioning.rb +20 -0
  127. data/lib/fog/google/parsers/storage/get_request_payment.rb +16 -0
  128. data/lib/fog/google/parsers/storage/get_service.rb +28 -0
  129. data/lib/fog/google/requests/compute/add_backend_service_backends.rb +29 -0
  130. data/lib/fog/google/requests/compute/add_region_view_resources.rb +27 -0
  131. data/lib/fog/google/requests/compute/add_server_access_config.rb +32 -0
  132. data/lib/fog/google/requests/compute/add_target_pool_health_checks.rb +27 -0
  133. data/lib/fog/google/requests/compute/add_target_pool_instances.rb +27 -0
  134. data/lib/fog/google/requests/compute/add_url_map_host_rules.rb +25 -0
  135. data/lib/fog/google/requests/compute/add_url_map_path_matchers.rb +29 -0
  136. data/lib/fog/google/requests/compute/add_zone_view_resources.rb +27 -0
  137. data/lib/fog/google/requests/compute/attach_disk.rb +34 -0
  138. data/lib/fog/google/requests/compute/delete_address.rb +24 -0
  139. data/lib/fog/google/requests/compute/delete_backend_service.rb +43 -0
  140. data/lib/fog/google/requests/compute/delete_disk.rb +48 -0
  141. data/lib/fog/google/requests/compute/delete_firewall.rb +23 -0
  142. data/lib/fog/google/requests/compute/delete_forwarding_rule.rb +49 -0
  143. data/lib/fog/google/requests/compute/delete_global_forwarding_rule.rb +48 -0
  144. data/lib/fog/google/requests/compute/delete_global_operation.rb +25 -0
  145. data/lib/fog/google/requests/compute/delete_http_health_check.rb +41 -0
  146. data/lib/fog/google/requests/compute/delete_image.rb +42 -0
  147. data/lib/fog/google/requests/compute/delete_network.rb +23 -0
  148. data/lib/fog/google/requests/compute/delete_region_operation.rb +29 -0
  149. data/lib/fog/google/requests/compute/delete_region_view.rb +24 -0
  150. data/lib/fog/google/requests/compute/delete_route.rb +23 -0
  151. data/lib/fog/google/requests/compute/delete_server.rb +69 -0
  152. data/lib/fog/google/requests/compute/delete_server_access_config.rb +26 -0
  153. data/lib/fog/google/requests/compute/delete_snapshot.rb +23 -0
  154. data/lib/fog/google/requests/compute/delete_target_http_proxy.rb +43 -0
  155. data/lib/fog/google/requests/compute/delete_target_instance.rb +48 -0
  156. data/lib/fog/google/requests/compute/delete_target_pool.rb +49 -0
  157. data/lib/fog/google/requests/compute/delete_url_map.rb +43 -0
  158. data/lib/fog/google/requests/compute/delete_zone_operation.rb +29 -0
  159. data/lib/fog/google/requests/compute/delete_zone_view.rb +24 -0
  160. data/lib/fog/google/requests/compute/detach_disk.rb +25 -0
  161. data/lib/fog/google/requests/compute/get_address.rb +24 -0
  162. data/lib/fog/google/requests/compute/get_backend_service.rb +26 -0
  163. data/lib/fog/google/requests/compute/get_backend_service_health.rb +27 -0
  164. data/lib/fog/google/requests/compute/get_backend_services.rb +23 -0
  165. data/lib/fog/google/requests/compute/get_disk.rb +52 -0
  166. data/lib/fog/google/requests/compute/get_disk_type.rb +42 -0
  167. data/lib/fog/google/requests/compute/get_firewall.rb +23 -0
  168. data/lib/fog/google/requests/compute/get_forwarding_rule.rb +46 -0
  169. data/lib/fog/google/requests/compute/get_global_forwarding_rule.rb +32 -0
  170. data/lib/fog/google/requests/compute/get_global_operation.rb +50 -0
  171. data/lib/fog/google/requests/compute/get_http_health_check.rb +39 -0
  172. data/lib/fog/google/requests/compute/get_image.rb +36 -0
  173. data/lib/fog/google/requests/compute/get_machine_type.rb +43 -0
  174. data/lib/fog/google/requests/compute/get_network.rb +23 -0
  175. data/lib/fog/google/requests/compute/get_project.rb +22 -0
  176. data/lib/fog/google/requests/compute/get_region.rb +37 -0
  177. data/lib/fog/google/requests/compute/get_region_operation.rb +55 -0
  178. data/lib/fog/google/requests/compute/get_region_view.rb +24 -0
  179. data/lib/fog/google/requests/compute/get_route.rb +23 -0
  180. data/lib/fog/google/requests/compute/get_server.rb +75 -0
  181. data/lib/fog/google/requests/compute/get_server_serial_port_output.rb +24 -0
  182. data/lib/fog/google/requests/compute/get_snapshot.rb +27 -0
  183. data/lib/fog/google/requests/compute/get_target_http_proxy.rb +27 -0
  184. data/lib/fog/google/requests/compute/get_target_instance.rb +32 -0
  185. data/lib/fog/google/requests/compute/get_target_pool.rb +40 -0
  186. data/lib/fog/google/requests/compute/get_target_pool_health.rb +29 -0
  187. data/lib/fog/google/requests/compute/get_url_map.rb +27 -0
  188. data/lib/fog/google/requests/compute/get_zone.rb +36 -0
  189. data/lib/fog/google/requests/compute/get_zone_operation.rb +55 -0
  190. data/lib/fog/google/requests/compute/get_zone_view.rb +24 -0
  191. data/lib/fog/google/requests/compute/insert_address.rb +25 -0
  192. data/lib/fog/google/requests/compute/insert_backend_service.rb +63 -0
  193. data/lib/fog/google/requests/compute/insert_disk.rb +113 -0
  194. data/lib/fog/google/requests/compute/insert_firewall.rb +43 -0
  195. data/lib/fog/google/requests/compute/insert_forwarding_rule.rb +60 -0
  196. data/lib/fog/google/requests/compute/insert_global_forwarding_rule.rb +56 -0
  197. data/lib/fog/google/requests/compute/insert_http_health_check.rb +59 -0
  198. data/lib/fog/google/requests/compute/insert_image.rb +64 -0
  199. data/lib/fog/google/requests/compute/insert_network.rb +29 -0
  200. data/lib/fog/google/requests/compute/insert_region_view.rb +25 -0
  201. data/lib/fog/google/requests/compute/insert_route.rb +35 -0
  202. data/lib/fog/google/requests/compute/insert_server.rb +191 -0
  203. data/lib/fog/google/requests/compute/insert_snapshot.rb +40 -0
  204. data/lib/fog/google/requests/compute/insert_target_http_proxy.rb +52 -0
  205. data/lib/fog/google/requests/compute/insert_target_instance.rb +55 -0
  206. data/lib/fog/google/requests/compute/insert_target_pool.rb +58 -0
  207. data/lib/fog/google/requests/compute/insert_url_map.rb +55 -0
  208. data/lib/fog/google/requests/compute/insert_zone_view.rb +27 -0
  209. data/lib/fog/google/requests/compute/list_addresses.rb +23 -0
  210. data/lib/fog/google/requests/compute/list_aggregated_addresses.rb +23 -0
  211. data/lib/fog/google/requests/compute/list_aggregated_disk_types.rb +40 -0
  212. data/lib/fog/google/requests/compute/list_aggregated_disks.rb +40 -0
  213. data/lib/fog/google/requests/compute/list_aggregated_machine_types.rb +22 -0
  214. data/lib/fog/google/requests/compute/list_aggregated_servers.rb +40 -0
  215. data/lib/fog/google/requests/compute/list_backend_services.rb +29 -0
  216. data/lib/fog/google/requests/compute/list_disk_types.rb +46 -0
  217. data/lib/fog/google/requests/compute/list_disks.rb +29 -0
  218. data/lib/fog/google/requests/compute/list_firewalls.rb +22 -0
  219. data/lib/fog/google/requests/compute/list_forwarding_rules.rb +29 -0
  220. data/lib/fog/google/requests/compute/list_global_forwarding_rules.rb +30 -0
  221. data/lib/fog/google/requests/compute/list_global_operations.rb +24 -0
  222. data/lib/fog/google/requests/compute/list_http_health_checks.rb +29 -0
  223. data/lib/fog/google/requests/compute/list_images.rb +29 -0
  224. data/lib/fog/google/requests/compute/list_machine_types.rb +30 -0
  225. data/lib/fog/google/requests/compute/list_networks.rb +22 -0
  226. data/lib/fog/google/requests/compute/list_region_operations.rb +25 -0
  227. data/lib/fog/google/requests/compute/list_region_view_resources.rb +25 -0
  228. data/lib/fog/google/requests/compute/list_region_views.rb +23 -0
  229. data/lib/fog/google/requests/compute/list_regions.rb +85 -0
  230. data/lib/fog/google/requests/compute/list_routes.rb +22 -0
  231. data/lib/fog/google/requests/compute/list_servers.rb +31 -0
  232. data/lib/fog/google/requests/compute/list_snapshots.rb +23 -0
  233. data/lib/fog/google/requests/compute/list_target_http_proxies.rb +30 -0
  234. data/lib/fog/google/requests/compute/list_target_instances.rb +30 -0
  235. data/lib/fog/google/requests/compute/list_target_pools.rb +29 -0
  236. data/lib/fog/google/requests/compute/list_url_maps.rb +29 -0
  237. data/lib/fog/google/requests/compute/list_zone_operations.rb +25 -0
  238. data/lib/fog/google/requests/compute/list_zone_view_resources.rb +25 -0
  239. data/lib/fog/google/requests/compute/list_zone_views.rb +23 -0
  240. data/lib/fog/google/requests/compute/list_zones.rb +28 -0
  241. data/lib/fog/google/requests/compute/remove_target_pool_health_checks.rb +27 -0
  242. data/lib/fog/google/requests/compute/remove_target_pool_instance.rb +27 -0
  243. data/lib/fog/google/requests/compute/remove_target_pool_instances.rb +27 -0
  244. data/lib/fog/google/requests/compute/reset_server.rb +24 -0
  245. data/lib/fog/google/requests/compute/set_common_instance_metadata.rb +26 -0
  246. data/lib/fog/google/requests/compute/set_forwarding_rule_target.rb +27 -0
  247. data/lib/fog/google/requests/compute/set_global_forwarding_rule_target.rb +27 -0
  248. data/lib/fog/google/requests/compute/set_metadata.rb +39 -0
  249. data/lib/fog/google/requests/compute/set_server_disk_auto_delete.rb +26 -0
  250. data/lib/fog/google/requests/compute/set_server_scheduling.rb +29 -0
  251. data/lib/fog/google/requests/compute/set_tags.rb +24 -0
  252. data/lib/fog/google/requests/compute/set_target_http_proxy_url_map.rb +27 -0
  253. data/lib/fog/google/requests/compute/start_server.rb +24 -0
  254. data/lib/fog/google/requests/compute/stop_server.rb +24 -0
  255. data/lib/fog/google/requests/compute/update_url_map.rb +39 -0
  256. data/lib/fog/google/requests/compute/validate_url_map.rb +24 -0
  257. data/lib/fog/google/requests/dns/create_change.rb +64 -0
  258. data/lib/fog/google/requests/dns/create_managed_zone.rb +82 -0
  259. data/lib/fog/google/requests/dns/delete_managed_zone.rb +35 -0
  260. data/lib/fog/google/requests/dns/get_change.rb +42 -0
  261. data/lib/fog/google/requests/dns/get_managed_zone.rb +37 -0
  262. data/lib/fog/google/requests/dns/get_project.rb +42 -0
  263. data/lib/fog/google/requests/dns/list_changes.rb +41 -0
  264. data/lib/fog/google/requests/dns/list_managed_zones.rb +31 -0
  265. data/lib/fog/google/requests/dns/list_resource_record_sets.rb +50 -0
  266. data/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +191 -0
  267. data/lib/fog/google/requests/monitoring/list_timeseries.rb +68 -0
  268. data/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb +87 -0
  269. data/lib/fog/google/requests/sql/clone_instance.rb +84 -0
  270. data/lib/fog/google/requests/sql/delete_instance.rb +67 -0
  271. data/lib/fog/google/requests/sql/delete_ssl_cert.rb +68 -0
  272. data/lib/fog/google/requests/sql/export_instance.rb +56 -0
  273. data/lib/fog/google/requests/sql/get_backup_run.rb +30 -0
  274. data/lib/fog/google/requests/sql/get_instance.rb +48 -0
  275. data/lib/fog/google/requests/sql/get_operation.rb +66 -0
  276. data/lib/fog/google/requests/sql/get_ssl_cert.rb +66 -0
  277. data/lib/fog/google/requests/sql/import_instance.rb +55 -0
  278. data/lib/fog/google/requests/sql/insert_instance.rb +165 -0
  279. data/lib/fog/google/requests/sql/insert_ssl_cert.rb +80 -0
  280. data/lib/fog/google/requests/sql/list_backup_runs.rb +30 -0
  281. data/lib/fog/google/requests/sql/list_flags.rb +143 -0
  282. data/lib/fog/google/requests/sql/list_instances.rb +32 -0
  283. data/lib/fog/google/requests/sql/list_operations.rb +52 -0
  284. data/lib/fog/google/requests/sql/list_ssl_certs.rb +51 -0
  285. data/lib/fog/google/requests/sql/list_tiers.rb +82 -0
  286. data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +49 -0
  287. data/lib/fog/google/requests/sql/restart_instance.rb +47 -0
  288. data/lib/fog/google/requests/sql/restore_instance_backup.rb +30 -0
  289. data/lib/fog/google/requests/sql/set_instance_root_password.rb +54 -0
  290. data/lib/fog/google/requests/sql/update_instance.rb +132 -0
  291. data/lib/fog/google/requests/storage/copy_object.rb +68 -0
  292. data/lib/fog/google/requests/storage/delete_bucket.rb +41 -0
  293. data/lib/fog/google/requests/storage/delete_object.rb +46 -0
  294. data/lib/fog/google/requests/storage/get_bucket.rb +106 -0
  295. data/lib/fog/google/requests/storage/get_bucket_acl.rb +59 -0
  296. data/lib/fog/google/requests/storage/get_object.rb +108 -0
  297. data/lib/fog/google/requests/storage/get_object_acl.rb +70 -0
  298. data/lib/fog/google/requests/storage/get_object_http_url.rb +44 -0
  299. data/lib/fog/google/requests/storage/get_object_https_url.rb +44 -0
  300. data/lib/fog/google/requests/storage/get_object_torrent.rb +45 -0
  301. data/lib/fog/google/requests/storage/get_object_url.rb +33 -0
  302. data/lib/fog/google/requests/storage/get_service.rb +48 -0
  303. data/lib/fog/google/requests/storage/head_object.rb +60 -0
  304. data/lib/fog/google/requests/storage/put_bucket.rb +71 -0
  305. data/lib/fog/google/requests/storage/put_bucket_acl.rb +58 -0
  306. data/lib/fog/google/requests/storage/put_object.rb +89 -0
  307. data/lib/fog/google/requests/storage/put_object_acl.rb +51 -0
  308. data/lib/fog/google/requests/storage/put_object_url.rb +50 -0
  309. data/lib/fog/google/sql.rb +130 -0
  310. data/lib/fog/google/storage.rb +298 -0
  311. data/lib/fog/google/version.rb +5 -0
  312. data/spec/minitest_helper.rb +31 -0
  313. data/tests/credentials_tests.rb +73 -0
  314. data/tests/helper.rb +126 -0
  315. data/tests/helpers/collection_helper.rb +97 -0
  316. data/tests/helpers/compute/flavors_helper.rb +32 -0
  317. data/tests/helpers/compute/server_helper.rb +25 -0
  318. data/tests/helpers/compute/servers_helper.rb +10 -0
  319. data/tests/helpers/formats_helper.rb +98 -0
  320. data/tests/helpers/formats_helper_tests.rb +110 -0
  321. data/tests/helpers/mock_helper.rb +18 -0
  322. data/tests/helpers/model_helper.rb +31 -0
  323. data/tests/helpers/responds_to_helper.rb +11 -0
  324. data/tests/helpers/schema_validator_tests.rb +107 -0
  325. data/tests/helpers/succeeds_helper.rb +9 -0
  326. data/tests/lorem.txt +1 -0
  327. data/tests/models/compute/backend_service_tests.rb +6 -0
  328. data/tests/models/compute/backend_services_tests.rb +8 -0
  329. data/tests/models/compute/disk_tests.rb +9 -0
  330. data/tests/models/compute/disk_types_tests.rb +22 -0
  331. data/tests/models/compute/disks_tests.rb +9 -0
  332. data/tests/models/compute/forwarding_rule_tests.rb +8 -0
  333. data/tests/models/compute/forwarding_rules_tests.rb +8 -0
  334. data/tests/models/compute/global_forwarding_rule_tests.rb +7 -0
  335. data/tests/models/compute/global_forwarding_rules_tests.rb +7 -0
  336. data/tests/models/compute/http_health_check_tests.rb +5 -0
  337. data/tests/models/compute/http_health_checks_tests.rb +5 -0
  338. data/tests/models/compute/image_tests.rb +6 -0
  339. data/tests/models/compute/images_tests.rb +6 -0
  340. data/tests/models/compute/region_tests.rb +10 -0
  341. data/tests/models/compute/regions_tests.rb +19 -0
  342. data/tests/models/compute/server_tests.rb +37 -0
  343. data/tests/models/compute/servers_tests.rb +14 -0
  344. data/tests/models/compute/target_http_proxies_tests.rb +7 -0
  345. data/tests/models/compute/target_http_proxy_test.rb +6 -0
  346. data/tests/models/compute/target_instance_tests.rb +7 -0
  347. data/tests/models/compute/target_instances_tests.rb +7 -0
  348. data/tests/models/compute/target_pool_tests.rb +12 -0
  349. data/tests/models/compute/target_pools_tests.rb +11 -0
  350. data/tests/models/compute/url_map_tests.rb +6 -0
  351. data/tests/models/compute/url_maps_tests.rb +7 -0
  352. data/tests/models/dns/change_tests.rb +28 -0
  353. data/tests/models/dns/changes_tests.rb +36 -0
  354. data/tests/models/dns/projects_tests.rb +12 -0
  355. data/tests/models/dns/record_tests.rb +42 -0
  356. data/tests/models/dns/records_tests.rb +36 -0
  357. data/tests/models/dns/zone_tests.rb +28 -0
  358. data/tests/models/dns/zones_tests.rb +14 -0
  359. data/tests/models/monitoring/metric_descriptors_tests.rb +12 -0
  360. data/tests/models/monitoring/timeseries_collection_tests.rb +12 -0
  361. data/tests/models/monitoring/timeseries_descriptors_tests.rb +13 -0
  362. data/tests/models/sql/flags_tests.rb +12 -0
  363. data/tests/models/sql/instance_tests.rb +56 -0
  364. data/tests/models/sql/instances_tests.rb +32 -0
  365. data/tests/models/sql/operation_tests.rb +25 -0
  366. data/tests/models/sql/operations_tests.rb +38 -0
  367. data/tests/models/sql/ssl_cert_tests.rb +24 -0
  368. data/tests/models/sql/ssl_certs_tests.rb +39 -0
  369. data/tests/models/sql/tiers_tests.rb +12 -0
  370. data/tests/requests/compute/backend_service_tests.rb +83 -0
  371. data/tests/requests/compute/disk_tests.rb +74 -0
  372. data/tests/requests/compute/disk_type_tests.rb +45 -0
  373. data/tests/requests/compute/firewall_tests.rb +88 -0
  374. data/tests/requests/compute/forwarding_rules_tests.rb +83 -0
  375. data/tests/requests/compute/global_forwarding_rules_tests.rb +83 -0
  376. data/tests/requests/compute/http_health_checks_tests.rb +83 -0
  377. data/tests/requests/compute/image_tests.rb +83 -0
  378. data/tests/requests/compute/network_tests.rb +75 -0
  379. data/tests/requests/compute/operation_tests.rb +20 -0
  380. data/tests/requests/compute/region_tests.rb +39 -0
  381. data/tests/requests/compute/server_tests.rb +84 -0
  382. data/tests/requests/compute/target_http_proxies_test.rb +79 -0
  383. data/tests/requests/compute/target_instances_tests.rb +83 -0
  384. data/tests/requests/compute/target_pools_tests.rb +82 -0
  385. data/tests/requests/compute/url_maps_tests.rb +82 -0
  386. data/tests/requests/compute/zone_tests.rb +37 -0
  387. data/tests/requests/dns/change_tests.rb +86 -0
  388. data/tests/requests/dns/managed_zone_tests.rb +66 -0
  389. data/tests/requests/dns/project_tests.rb +29 -0
  390. data/tests/requests/dns/record_tests.rb +49 -0
  391. data/tests/requests/monitoring/metric_descriptor_tests.rb +25 -0
  392. data/tests/requests/monitoring/timeseries_collection_tests.rb +25 -0
  393. data/tests/requests/monitoring/timeseries_descriptor_tests.rb +26 -0
  394. data/tests/requests/sql/flag_tests.rb +27 -0
  395. data/tests/requests/sql/instance_tests.rb +129 -0
  396. data/tests/requests/sql/operation_tests.rb +42 -0
  397. data/tests/requests/sql/ssl_cert_tests.rb +61 -0
  398. data/tests/requests/sql/tier_tests.rb +25 -0
  399. data/tests/requests/storage/bucket_tests.rb +77 -0
  400. data/tests/requests/storage/object_tests.rb +84 -0
  401. metadata +625 -0
@@ -0,0 +1,28 @@
1
+ def test
2
+ connection = Fog::Google::SQL.new
3
+
4
+ puts 'Create a Instance...'
5
+ puts '--------------------'
6
+ instance = connection.instances.create(:instance => Fog::Mock.random_letters(16), :tier => 'D1')
7
+ instance.wait_for { ready? }
8
+
9
+ puts 'Create a SSL certificate...'
10
+ puts '---------------------------'
11
+ ssl_cert = connection.ssl_certs.create(:instance => instance.instance, :common_name => Fog::Mock.random_letters(16))
12
+
13
+ puts 'Get the SSL certificate...'
14
+ puts '--------------------------'
15
+ connection.ssl_certs.get(instance.instance, ssl_cert.sha1_fingerprint)
16
+
17
+ puts 'List all SSL certificate...'
18
+ puts '---------------------------'
19
+ connection.ssl_certs.all(instance.instance)
20
+
21
+ puts 'Delete the SSL certificate...'
22
+ puts '-----------------------------'
23
+ ssl_cert.destroy
24
+
25
+ puts 'Delete the Instance...'
26
+ puts '----------------------'
27
+ instance.destroy
28
+ end
@@ -0,0 +1,7 @@
1
+ def test
2
+ connection = Fog::Google::SQL.new
3
+
4
+ puts 'Listing all Tiers...'
5
+ puts '--------------------'
6
+ connection.tiers
7
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fog/google/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fog-google"
8
+ spec.version = Fog::Google::VERSION
9
+ spec.authors = ["Nat Welch", "Daniel Broudy", "Isaac Hollander McCreery"]
10
+ spec.email = ["nat@natwelch.com", "broudy@google.com", "ihmccreery@google.com"]
11
+ spec.summary = %q{Module for the 'fog' gem to support Google.}
12
+ spec.description = %q{This library can be used as a module for `fog` or as standalone provider
13
+ to use the Google in applications.}
14
+ spec.homepage = "https://github.com/fog/fog-google"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'fog-xml'
23
+ spec.add_dependency 'fog-core'
24
+ spec.add_development_dependency 'google-api-client', '~> 0.6', '>= 0.6.2'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'shindo'
27
+ spec.add_development_dependency 'minitest'
28
+ spec.add_development_dependency 'turn'
29
+ spec.add_development_dependency 'pry'
30
+ spec.add_development_dependency 'vcr'
31
+ spec.add_development_dependency 'webmock'
32
+
33
+ if RUBY_VERSION.to_f > 1.9
34
+ spec.add_development_dependency 'coveralls'
35
+ spec.add_development_dependency 'rubocop'
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activesupport', '>= 3.0', '< 4'
4
+ gem 'mime-types', '< 2.0'
5
+
6
+ gemspec :path => '../'
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'mime-types', '< 2.0'
4
+ gem 'nokogiri', '< 1.6'
5
+ gem 'rest-client', '~> 1.6.8'
6
+ gem 'i18n', '<= 0.6.11'
7
+ gem 'activesupport', '<= 3.2.21'
8
+
9
+ gemspec :path => '../'
@@ -0,0 +1,88 @@
1
+ module Google # deviates from other bin stuff to accomodate gem
2
+ class << self
3
+ def class_for(key)
4
+ case key
5
+ when :compute
6
+ Fog::Compute::Google
7
+ when :dns
8
+ Fog::DNS::Google
9
+ when :monitoring
10
+ Fog::Google::Monitoring
11
+ when :storage
12
+ Fog::Storage::Google
13
+ when :sql
14
+ Fog::Google::SQL
15
+ else
16
+ raise ArgumentError, "Unsupported #{self} service: #{key}"
17
+ end
18
+ end
19
+
20
+ def [](service)
21
+ @@connections ||= Hash.new do |hash, key|
22
+ hash[key] = case key
23
+ when :compute
24
+ Fog::Logger.warning("Google[:compute] is not recommended, use Compute[:google] for portability")
25
+ Fog::Compute.new(:provider => 'Google')
26
+ when :dns
27
+ Fog::Logger.warning("Google[:dns] is not recommended, use DNS[:google] for portability")
28
+ Fog::DNS.new(:provider => 'Google')
29
+ when :monitoring
30
+ Fog::Google::Monitoring.new
31
+ when :sql
32
+ Fog::Google::SQL.new
33
+ when :storage
34
+ Fog::Logger.warning("Google[:storage] is not recommended, use Storage[:google] for portability")
35
+ Fog::Storage.new(:provider => 'Google')
36
+ else
37
+ raise ArgumentError, "Unrecognized service: #{key.inspect}"
38
+ end
39
+ end
40
+ @@connections[service]
41
+ end
42
+
43
+ def account
44
+ @@connections[:compute].account
45
+ end
46
+
47
+ def services
48
+ Fog::Google.services
49
+ end
50
+
51
+ # based off of virtual_box.rb
52
+ def available?
53
+ # Make sure the gem we use is enabled.
54
+ availability = if Gem::Specification.respond_to?(:find_all_by_name)
55
+ !Gem::Specification.find_all_by_name('google-api-client').empty? # newest rubygems
56
+ else
57
+ !Gem.source_index.find_name('google-api-client').empty? # legacy
58
+ end
59
+ # Then make sure we have all of the requirements
60
+ for service in services
61
+ begin
62
+ service = self.class_for(service)
63
+ availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
64
+ rescue ArgumentError => e
65
+ Fog::Logger.warning(e.message)
66
+ availability = false
67
+ rescue => e
68
+ availability = false
69
+ end
70
+ end
71
+
72
+ if availability
73
+ for service in services
74
+ for collection in self.class_for(service).collections
75
+ unless self.respond_to?(collection)
76
+ self.class_eval <<-EOS, __FILE__, __LINE__
77
+ def self.#{collection}
78
+ self[:#{service}].#{collection}
79
+ end
80
+ EOS
81
+ end
82
+ end
83
+ end
84
+ end
85
+ availability
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,226 @@
1
+ require "fog/core"
2
+ require "fog/xml"
3
+ require "fog/google/version"
4
+
5
+ module Fog
6
+ module Compute
7
+ autoload :Google, "fog/google/compute"
8
+ end
9
+
10
+ module DNS
11
+ autoload :Google, "fog/google/dns"
12
+ end
13
+
14
+ module Storage
15
+ autoload :Google, "fog/google/storage"
16
+ end
17
+
18
+ module Google
19
+ autoload :Monitoring, "fog/google/monitoring"
20
+ autoload :SQL, "fog/google/sql"
21
+
22
+ extend Fog::Provider
23
+
24
+ service(:compute, 'Compute')
25
+ service(:dns, 'DNS')
26
+ service(:monitoring, 'Monitoring')
27
+ service(:storage, 'Storage')
28
+ service(:sql, 'SQL')
29
+
30
+ class Mock
31
+ def self.etag
32
+ hex(32)
33
+ end
34
+
35
+ def self.hex(length)
36
+ max = ('f' * length).to_i(16)
37
+ rand(max).to_s(16)
38
+ end
39
+ end
40
+
41
+ module Shared
42
+ attr_reader :project, :api_version, :api_url
43
+
44
+ ##
45
+ # Initializes shared attributes
46
+ #
47
+ # @param [String] project Google Cloud Project
48
+ # @param [String] api_version Google API version
49
+ # @param [String] base_url Google API base url
50
+ # @return [void]
51
+ def shared_initialize(project, api_version, base_url)
52
+ @project = project
53
+ @api_version = api_version
54
+ @api_url = base_url + api_version + '/projects/'
55
+ end
56
+
57
+ ##
58
+ # Initializes the Google API Client
59
+ #
60
+ # @param [Hash] options Google API options
61
+ # @option options [String] :google_client_email A @developer.gserviceaccount.com email address to use
62
+ # @option options [String] :google_key_location The location of a pkcs12 key file
63
+ # @option options [String] :google_key_string The content of the pkcs12 key file
64
+ # @option options [String] :google_json_key_location The location of a JSON key file
65
+ # @option options [String] :google_json_key_string The content of the JSON key file
66
+ # @option options [String] :google_api_scope_url The access scope URLs
67
+ # @option options [String] :app_name The app name to set in the user agent
68
+ # @option options [String] :app_version The app version to set in the user agent
69
+ # @option options [Google::APIClient] :google_client Existing Google API Client
70
+ # @return [Google::APIClient] Google API Client
71
+ # @raises [ArgumentError] If there is any missing argument
72
+ def initialize_google_client(options)
73
+ # NOTE: loaded here to avoid requiring this as a core Fog dependency
74
+ begin
75
+ require 'google/api_client'
76
+ rescue LoadError => error
77
+ Fog::Logger.warning('Please install the google-api-client gem before using this provider')
78
+ raise error
79
+ end
80
+
81
+ # User can provide an existing Google API Client
82
+ client = options[:google_client]
83
+ return client unless client.nil?
84
+
85
+ # Create a signing key
86
+ signing_key = create_signing_key(options)
87
+
88
+ # Validate required arguments
89
+ unless options[:google_client_email]
90
+ raise ArgumentError.new('Missing required arguments: google_client_email')
91
+ end
92
+
93
+ unless options[:google_api_scope_url]
94
+ raise ArgumentError.new('Missing required arguments: google_api_scope_url')
95
+ end
96
+
97
+ # Create a new Google API Client
98
+ self.new_pk12_google_client(
99
+ options[:google_client_email],
100
+ signing_key,
101
+ options[:google_api_scope_url],
102
+ options[:app_name],
103
+ options[:app_version]
104
+ )
105
+ end
106
+
107
+ ##
108
+ # Creates a Google signing key
109
+ #
110
+ def create_signing_key(options)
111
+ if options[:google_json_key_location] || options[:google_json_key_string]
112
+ if options[:google_json_key_location]
113
+ json_key_location = File.expand_path(options[:google_json_key_location])
114
+ json_key = File.open(json_key_location, 'r') { |file| file.read }
115
+ else
116
+ json_key = options[:google_json_key_string]
117
+ end
118
+
119
+ json_key_hash = Fog::JSON.decode(json_key)
120
+ unless json_key_hash.has_key?('client_email') || json_key_hash.has_key?('private_key')
121
+ raise ArgumentError.new('Invalid Google JSON key')
122
+ end
123
+
124
+ options[:google_client_email] = json_key_hash['client_email']
125
+ ::Google::APIClient::KeyUtils.load_from_pem(json_key_hash['private_key'], 'notasecret')
126
+ elsif options[:google_key_location] || options[:google_key_string]
127
+ if options[:google_key_location]
128
+ google_key = File.expand_path(options[:google_key_location])
129
+ else
130
+ google_key = options[:google_key_string]
131
+ end
132
+
133
+ ::Google::APIClient::KeyUtils.load_from_pkcs12(google_key, 'notasecret')
134
+ else
135
+ raise ArgumentError.new('Missing required arguments: google_key_location, google_key_string, ' \
136
+ 'google_json_key_location or google_json_key_string')
137
+ end
138
+ end
139
+
140
+ ##
141
+ # Create a Google API Client with a user email and a pkcs12 key
142
+ #
143
+ # @param [String] google_client_email A @developer.gserviceaccount.com email address to use
144
+ # @param [OpenSSL::PKey] signing_key The private key for signing
145
+ # @param [String] google_api_scope_url Access scope URLs
146
+ # @param [String] app_name The app name to set in the user agent
147
+ # @param [String] app_version The app version to set in the user agent
148
+ # @return [Google::APIClient] Google API Client
149
+ def new_pk12_google_client(google_client_email, signing_key, google_api_scope_url, app_name = nil, app_version = nil)
150
+ application_name = app_name.nil? ? 'fog' : "#{app_name}/#{app_version || '0.0.0'} fog"
151
+ api_client_options = {
152
+ :application_name => application_name,
153
+ :application_version => Fog::VERSION,
154
+ }
155
+ client = ::Google::APIClient.new(api_client_options)
156
+
157
+ client.authorization = Signet::OAuth2::Client.new(
158
+ {
159
+ :audience => 'https://accounts.google.com/o/oauth2/token',
160
+ :auth_provider_x509_cert_url => 'https://www.googleapis.com/oauth2/v1/certs',
161
+ :client_x509_cert_url => "https://www.googleapis.com/robot/v1/metadata/x509/#{google_client_email}",
162
+ :issuer => google_client_email,
163
+ :scope => google_api_scope_url,
164
+ :signing_key => signing_key,
165
+ :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
166
+ }
167
+ )
168
+ client.authorization.fetch_access_token!
169
+
170
+ client
171
+ end
172
+
173
+ ##
174
+ # Executes a request and wraps it in a result object
175
+ #
176
+ # @param [Google::APIClient::Method] api_method The method object or the RPC name of the method being executed
177
+ # @param [Hash] parameters The parameters to send to the method
178
+ # @param [Hash] body_object The body object of the request
179
+ # @return [Excon::Response] The result from the API
180
+ def request(api_method, parameters, body_object = nil)
181
+ client_parms = {
182
+ :api_method => api_method,
183
+ :parameters => parameters,
184
+ }
185
+ client_parms[:body_object] = body_object if body_object
186
+
187
+ result = @client.execute(client_parms)
188
+
189
+ build_excon_response(result.body.nil? || result.body.empty? ? nil : Fog::JSON.decode(result.body), result.status)
190
+ end
191
+
192
+ ##
193
+ # Builds an Excon response
194
+ #
195
+ # @param [Hash] Response body
196
+ # @param [Integer] Response status
197
+ # @return [Excon::Response] Excon response
198
+ def build_excon_response(body, status = 200)
199
+ response = Excon::Response.new(:body => body, :status => status)
200
+ if body && body.has_key?('error')
201
+ msg = 'Google Cloud did not return an error message'
202
+
203
+ if body['error'].kind_of?(Hash)
204
+ response.status = body['error']['code']
205
+ if body['error'].has_key?('errors')
206
+ msg = body['error']['errors'].map{ |error| error['message'] }.join(', ')
207
+ elsif body['error'].has_key?('message')
208
+ msg = body['error']['message']
209
+ end
210
+ elsif body['error'].kind_of?(Array)
211
+ msg = body['error'].map{ |error| error['code'] }.join(', ')
212
+ end
213
+
214
+ case response.status
215
+ when 404
216
+ raise Fog::Errors::NotFound.new(msg)
217
+ else
218
+ raise Fog::Errors::Error.new(msg)
219
+ end
220
+ end
221
+
222
+ response
223
+ end
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,1068 @@
1
+ module Fog
2
+ module Compute
3
+ class Google < Fog::Service
4
+ requires :google_project
5
+ recognizes :app_name, :app_version, :google_client_email, :google_key_location, :google_key_string,
6
+ :google_client, :google_json_key_location, :google_json_key_string
7
+
8
+ GOOGLE_COMPUTE_API_VERSION = 'v1'
9
+ GOOGLE_COMPUTE_BASE_URL = 'https://www.googleapis.com/compute/'
10
+ GOOGLE_COMPUTE_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/compute
11
+ https://www.googleapis.com/auth/devstorage.read_write
12
+ https://www.googleapis.com/auth/ndev.cloudman
13
+ https://www.googleapis.com/auth/cloud-platform)
14
+ GOOGLE_COMPUTE_DEFAULT_NETWORK = 'default'
15
+
16
+ request_path 'fog/google/requests/compute'
17
+ request :list_servers
18
+ request :list_aggregated_servers
19
+ request :list_addresses
20
+ request :list_aggregated_addresses
21
+ request :list_disks
22
+ request :list_aggregated_disks
23
+ request :list_disk_types
24
+ request :list_aggregated_disk_types
25
+ request :list_firewalls
26
+ request :list_images
27
+ request :list_machine_types
28
+ request :list_aggregated_machine_types
29
+ request :list_networks
30
+ request :list_zones
31
+ request :list_regions
32
+ request :list_global_operations
33
+ request :list_region_operations
34
+ request :list_zone_operations
35
+ request :list_snapshots
36
+ request :list_http_health_checks
37
+ request :list_target_pools
38
+ request :list_forwarding_rules
39
+ request :list_routes
40
+ request :list_backend_services
41
+ request :list_global_forwarding_rules
42
+ request :list_url_maps
43
+ request :list_target_http_proxies
44
+ request :list_zone_views
45
+ request :list_region_views
46
+ request :list_region_view_resources
47
+ request :list_zone_view_resources
48
+ request :list_target_instances
49
+
50
+ request :get_server
51
+ request :get_address
52
+ request :get_disk
53
+ request :get_disk_type
54
+ request :get_firewall
55
+ request :get_image
56
+ request :get_machine_type
57
+ request :get_network
58
+ request :get_zone
59
+ request :get_region
60
+ request :get_snapshot
61
+ request :get_global_operation
62
+ request :get_region_operation
63
+ request :get_zone_operation
64
+ request :get_http_health_check
65
+ request :get_target_pool
66
+ request :get_target_pool_health
67
+ request :get_forwarding_rule
68
+ request :get_project
69
+ request :get_route
70
+ request :get_backend_service
71
+ request :get_backend_service_health
72
+ request :get_url_map
73
+ request :get_global_forwarding_rule
74
+ request :get_target_http_proxy
75
+ request :get_zone_view
76
+ request :get_region_view
77
+ request :get_target_instance
78
+
79
+ request :delete_address
80
+ request :delete_disk
81
+ request :delete_snapshot
82
+ request :delete_firewall
83
+ request :delete_image
84
+ request :delete_network
85
+ request :delete_server
86
+ request :delete_global_operation
87
+ request :delete_region_operation
88
+ request :delete_zone_operation
89
+ request :delete_http_health_check
90
+ request :delete_target_pool
91
+ request :delete_forwarding_rule
92
+ request :delete_route
93
+ request :delete_backend_service
94
+ request :delete_url_map
95
+ request :delete_target_http_proxy
96
+ request :delete_global_forwarding_rule
97
+ request :delete_zone_view
98
+ request :delete_region_view
99
+ request :delete_target_instance
100
+
101
+ request :insert_address
102
+ request :insert_disk
103
+ request :insert_firewall
104
+ request :insert_image
105
+ request :insert_network
106
+ request :insert_server
107
+ request :insert_snapshot
108
+ request :insert_http_health_check
109
+ request :insert_target_pool
110
+ request :insert_forwarding_rule
111
+ request :insert_route
112
+ request :insert_backend_service
113
+ request :insert_url_map
114
+ request :insert_target_http_proxy
115
+ request :insert_global_forwarding_rule
116
+ request :insert_zone_view
117
+ request :insert_region_view
118
+ request :insert_target_instance
119
+
120
+ request :set_metadata
121
+ request :set_tags
122
+ request :set_forwarding_rule_target
123
+ request :set_global_forwarding_rule_target
124
+ request :set_target_http_proxy_url_map
125
+
126
+ request :add_target_pool_instances
127
+ request :add_target_pool_health_checks
128
+ request :add_backend_service_backends
129
+ request :add_url_map_host_rules
130
+ request :add_url_map_path_matchers
131
+ request :add_zone_view_resources
132
+ request :add_region_view_resources
133
+
134
+ request :remove_target_pool_instances
135
+ request :remove_target_pool_health_checks
136
+ request :set_common_instance_metadata
137
+
138
+ request :attach_disk
139
+ request :detach_disk
140
+ request :get_server_serial_port_output
141
+ request :reset_server
142
+ request :set_server_disk_auto_delete
143
+ request :set_server_scheduling
144
+ request :add_server_access_config
145
+ request :delete_server_access_config
146
+ request :update_url_map
147
+ request :validate_url_map
148
+ request :start_server
149
+ request :stop_server
150
+
151
+ model_path 'fog/google/models/compute'
152
+ model :server
153
+ collection :servers
154
+
155
+ model :image
156
+ collection :images
157
+
158
+ model :flavor
159
+ collection :flavors
160
+
161
+ model :disk
162
+ collection :disks
163
+
164
+ model :disk_type
165
+ collection :disk_types
166
+
167
+ model :address
168
+ collection :addresses
169
+
170
+ model :operation
171
+ collection :operations
172
+
173
+ model :snapshot
174
+ collection :snapshots
175
+
176
+ model :zone
177
+ collection :zones
178
+
179
+ model :region
180
+ collection :regions
181
+
182
+ model :http_health_check
183
+ collection :http_health_checks
184
+
185
+ model :target_pool
186
+ collection :target_pools
187
+
188
+ model :forwarding_rule
189
+ collection :forwarding_rules
190
+
191
+ model :project
192
+ collection :projects
193
+
194
+ model :firewall
195
+ collection :firewalls
196
+
197
+ model :network
198
+ collection :networks
199
+
200
+ model :route
201
+ collection :routes
202
+
203
+ model :backend_service
204
+ collection :backend_services
205
+
206
+ model :target_http_proxy
207
+ collection :target_http_proxies
208
+
209
+ model :url_map
210
+ collection :url_maps
211
+
212
+ model :global_forwarding_rule
213
+ collection :global_forwarding_rules
214
+
215
+ model :resource_view
216
+ collection :resource_views
217
+
218
+ model :target_instance
219
+ collection :target_instances
220
+
221
+ class Mock
222
+ include Fog::Google::Shared
223
+
224
+ def initialize(options)
225
+ shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
226
+ end
227
+
228
+ def self.data(api_version)
229
+ @data ||= Hash.new do |hash, key|
230
+ case key
231
+ when 'debian-cloud'
232
+ hash[key] = {
233
+ :images => {
234
+ "debian-6-squeeze-v20130816" => {
235
+ "kind" => "compute#image",
236
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-6-squeeze-v20130816",
237
+ "id" => "14841592146580482051",
238
+ "creationTimestamp" => "2013-09-04T13:21:53.292-07:00",
239
+ "name" => "debian-6-squeeze-v20130816",
240
+ "description" => "Debian GNU/Linux 6.0.7 (squeeze) built on 2013-08-16",
241
+ "sourceType" => "RAW",
242
+ "rawDisk" => {
243
+ "containerType" => "TAR",
244
+ "source" => ""
245
+ },
246
+ "status" => "READY"
247
+ },
248
+ "debian-7-wheezy-v20130816" => {
249
+ "kind" => "compute#image",
250
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20130816",
251
+ "id" => "4213305957435180899",
252
+ "creationTimestamp" => "2013-09-04T13:24:30.479-07:00",
253
+ "name" => "debian-7-wheezy-v20130816",
254
+ "description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-08-16",
255
+ "sourceType" => "RAW",
256
+ "rawDisk" => {
257
+ "containerType" => "TAR",
258
+ "source" => ""
259
+ },
260
+ "status" => "READY"
261
+ },
262
+ "debian-7-wheezy-v20131014" => {
263
+ "kind" => "compute#image",
264
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20131014",
265
+ "id" => "4213305957435180899",
266
+ "creationTimestamp" => "2013-09-04T13:24:30.479-07:00",
267
+ "name" => "debian-7-wheezy-v20131014",
268
+ "description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-10-14",
269
+ "sourceType" => "RAW",
270
+ "rawDisk" => {
271
+ "containerType" => "TAR",
272
+ "source" => ""
273
+ },
274
+ "status" => "READY"
275
+ },
276
+ "debian-7-wheezy-v20140408" => {
277
+ "kind" => "compute#image",
278
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20140408",
279
+ "id" => "17312518942796567788",
280
+ "creationTimestamp" => "2013-11-25T15:17:00.436-08:00",
281
+ "name" => "debian-7-wheezy-v20131120",
282
+ "description" => "Debian GNU/Linux 7.2 (wheezy) built on 2013-11-20",
283
+ "sourceType" => "RAW",
284
+ "rawDisk" => {
285
+ "containerType" => "TAR",
286
+ "source" => ""
287
+ },
288
+ "status" => "READY",
289
+ "archiveSizeBytes" => "341857472"
290
+ }
291
+ }
292
+ }
293
+ when 'centos-cloud'
294
+ hash[key] = {
295
+ :images => {
296
+ "centos-6-v20130813" => {
297
+ "kind" => "compute#image",
298
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/images/centos-6-v20130813",
299
+ "id" => "4670523370938782739",
300
+ "creationTimestamp" => "2013-08-19T11:56:47.004-07:00",
301
+ "name" => "centos-6-v20130813",
302
+ "description" => "SCSI-enabled CentOS 6; Created Tue, 13 Aug 2013 00:00:00 +0000",
303
+ "sourceType" => "RAW",
304
+ "rawDisk" => {
305
+ "containerType" => "TAR",
306
+ "source" => ""
307
+ },
308
+ "status" => "READY"
309
+ }
310
+ }
311
+ }
312
+ else
313
+ hash[key] = {
314
+ :target_http_proxies => {
315
+ "test-target-http-proxy" => {
316
+ "kind" => "compute#targetHttpProxy",
317
+ "id" => "1361932147851415729",
318
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
319
+ "name" => "test-target-http-proxy",
320
+ "description" => '',
321
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/targetHttpProxies/test-target-http-proxy",
322
+ "urlMap" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/urlMaps/test-url-map"
323
+ }
324
+ },
325
+ :url_maps => {
326
+ "test-url-map" => {
327
+ "kind" => "compute#urlMap",
328
+ "id" => "1361932147851415729",
329
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
330
+ "name" => 'test-url-map',
331
+ "description" => '',
332
+ "hostRules" => [],
333
+ "pathMatchers" => [],
334
+ "tests" => [],
335
+ "defaultService" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/backendServices/fog-backend-service-test",
336
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/urlMaps/test-url-map"
337
+ }
338
+ },
339
+ :target_pools => {
340
+ "test-target-pool" => {
341
+ 'kind' => "compute#targetPool",
342
+ "id" => "1361932147851415729",
343
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/regions/us-central1/targetPools/test-target-pool",
344
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
345
+ 'name' => "test-target-pool",
346
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/regions/us-central1",
347
+ "healthChecks" => ["https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/httpHealthChecks/test-check"],
348
+ "instances" => ["https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/us-central1-a/instances/test-instance"],
349
+ }
350
+ },
351
+
352
+ :http_health_checks => {
353
+ "test-http-health-check" => {
354
+ "checkIntervalSec" => 5,
355
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
356
+ "healthyThreshold" => 2,
357
+ "id" => "1361932147851415729",
358
+ "kind" => "compute#httphealthCheck",
359
+ "name" => "test-http-health-check",
360
+ "port" => 80,
361
+ "requestPath" => '/',
362
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/httpHealthChecks/test-http-health-check",
363
+ "timeoutSec" => 5,
364
+ "unhealthyThreshold" => 2
365
+ }
366
+ },
367
+ :global_forwarding_rules => {
368
+ "test-global-forwarding-rule" => {
369
+ "kind" => "compute#forwardingRule",
370
+ "id" => "1361932147851415729",
371
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
372
+ "name" => 'test-global-forwarding-rule',
373
+ "IPAddress" => '107.178.255.155',
374
+ "IPProtocol" => 'TCP',
375
+ "portRange" => '80-80',
376
+ "target" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/targetHttpProxies/proxy",
377
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/forwardngRules/test-global-forwarding-rule"
378
+ }
379
+ },
380
+ :forwarding_rules => {
381
+ "test-forwarding-rule" => {
382
+ "kind" => "compute#forwardingRule",
383
+ "id" => "1361932147851415729",
384
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
385
+ "name" => 'test-forwarding-rule',
386
+ "IPAddress" => '107.178.255.155',
387
+ "IPProtocol" => 'TCP',
388
+ "portRange" => '80-80',
389
+ "target" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/regions/us-central1/targetPools/target_pool",
390
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/regions/us-central1/forwardngRules/test-forwarding-rule",
391
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/regions/us-central1"
392
+ }
393
+ },
394
+ :target_instances => {
395
+ "test-target-instance" => {
396
+ "kind" => "compute#targetInstance",
397
+ "name" => "test-target-instance",
398
+ "natPolicy" => "NO_NAT",
399
+ "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/us-central1-a",
400
+ "instance" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/us-central1-a/instances/test-instance",
401
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/us-central1-a/targetInstances/test-target-instance",
402
+ "id" => "1361932147851415729",
403
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
404
+
405
+ }
406
+ },
407
+ :backend_services =>{
408
+ "test-backend-service" => {
409
+ "kind" => "compute#backend_service",
410
+ "id" => "1361932147851415729",
411
+ "creationTimestamp" => '2014-08-23T10:06:13.951-07:00',
412
+ "name" => "test-backend-service",
413
+ "description" => '',
414
+ "backends" => [
415
+ {
416
+ "description" => '',
417
+ "group" => "https://www.googleapis.com/resourceviews/v1beta1/projects#{@project}/zones/us-central1-a/zoneViews/name",
418
+ "balancingMode" => "RATE",
419
+ "capacityScaler" => 1.1,
420
+ "maxRate" => 0.5,
421
+ }],
422
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/backendServices/test-backend-service"
423
+ }
424
+ },
425
+ :servers => {
426
+ "fog-1" => {
427
+ "kind" => "compute#instance",
428
+ "id" => "1361932147851415727",
429
+ "creationTimestamp" => "2013-09-26T04:55:43.881-07:00",
430
+ "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
431
+ "status" => "RUNNING",
432
+ "name" => "fog-1380196541",
433
+ "tags" => { "fingerprint" => "42WmSpB8rSM=" },
434
+ "machineType" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/machineTypes/n1-standard-1",
435
+ "canIpForward" => false,
436
+ "networkInterfaces" => [
437
+ {
438
+ "network" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/global/networks/default",
439
+ "networkIP" => "10.240.121.54",
440
+ "name" => "nic0",
441
+ "accessConfigs" => [
442
+ {
443
+ "kind" => "compute#accessConfig",
444
+ "type" => "ONE_TO_ONE_NAT",
445
+ "name" => "External NAT",
446
+ "natIP" => "108.59.81.28"
447
+ }
448
+ ]
449
+ }
450
+ ],
451
+ "disks" => [
452
+ {
453
+ "kind" => "compute#attachedDisk",
454
+ "index" => 0,
455
+ "type" => "PERSISTENT",
456
+ "mode" => "READ_WRITE",
457
+ "source" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1",
458
+ "deviceName" => "persistent-disk-0",
459
+ "boot" => true
460
+ }
461
+ ],
462
+ "metadata" => {
463
+ "kind" => "compute#metadata",
464
+ "fingerprint" => "5_hasd_gC3E=",
465
+ "items" => [
466
+ {
467
+ "key" => "sshKeys",
468
+ "value" => "sysadmin:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA1zc7mx+0H8Roywet/L0aVX6MUdkDfzd/17kZhprAbpUXYOILv9AG4lIzQk6xGxDIltghytjfVGme/4A42Sb0Z9LN0pxB4KnWTNoOSHPJtp6jbXpq6PdN9r3Z5NKQg0A/Tfw7gt2N0GDsj6vpK8VbHHdW78JAVUxql18ootJxjaksdocsiHNK8iA6/v9qiLRhX3fOgtK7KpxxdZxLRzFg9vkp8jcGISgpZt27kOgXWhR5YLhi8pRJookzphO5O4yhflgoHoAE65XkfrsRCe0HU5QTbY2jH88rBVkq0KVlZh/lEsuwfmG4d77kEqaCGGro+j1Wrvo2K3DSQ+rEcvPp2CYRUySjhaeLF18UzQLtxNeoN14QOYqlm9ITdkCnmq5w4Wn007MjSOFp8LEq2RekrnddGXjg1/vgmXtaVSGzJAlXwtVfZor3dTRmF0JCpr7DsiupBaDFtLUlGFFlSKmPDVMPOOB5wajexmcvSp2Vu4U3yP8Lai/9/ZxMdsGPhpdCsWVL83B5tF4oYj1HVIycbYIxIIfFqOxZcCru3CMfe9jmzKgKLv2UtkfOS8jpS/Os2gAiB3wPweH3agvtwYAYBVMDwt5cnrhgHYWoOz7ABD8KgmCrD7Y9HikiCqIUNkgUFd9YmjcYi5FkU5rFXIawN7efs341lsdf923lsdf923fs= johndoe@acme"
469
+ }
470
+ ]
471
+ },
472
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/instances/fog-1380196541"
473
+ }
474
+ },
475
+ :zones => {
476
+ "europe-west1-a" => {
477
+ "kind" => "compute#zone",
478
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/europe-west1-a",
479
+ "id" => "10419676573632995924",
480
+ "creationTimestamp" => "2013-09-26T02:56:13.115-07:00",
481
+ "name" => "europe-west1-a",
482
+ "description" => "europe-west1-a",
483
+ "status" => "UP",
484
+ "maintenanceWindows" => [
485
+ {
486
+ "name" => "2014-01-18-planned-outage",
487
+ "description" => "maintenance zone",
488
+ "beginTime" => "2014-01-18T12:00:00.000-08:00",
489
+ "endTime" => "2014-02-02T12:00:00.000-08:00"
490
+ }
491
+ ],
492
+ "quotas" => [
493
+ {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
494
+ {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
495
+ {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
496
+ {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
497
+ ],
498
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/europe-west1"
499
+ },
500
+ "us-central1-a" => {
501
+ "kind" => "compute#zone",
502
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
503
+ "id" => "6562457277909136262",
504
+ "creationTimestamp" => "2013-09-26T02:56:13.116-07:00",
505
+ "name" => "us-central1-a",
506
+ "description" => "us-central1-a",
507
+ "status" => "UP",
508
+ "maintenanceWindows" => nil,
509
+ "quotas" => [
510
+ {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 1.0},
511
+ {"metric" => "CPUS", "limit" => 24.0, "usage" => 1.0},
512
+ {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
513
+ {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
514
+ ],
515
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central1"
516
+ },
517
+ "us-central1-b" => {
518
+ "kind" => "compute#zone",
519
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-b",
520
+ "id" => "8701502109626061015",
521
+ "creationTimestamp" => "2013-09-26T02:56:13.124-07:00",
522
+ "name" => "us-central1-b",
523
+ "description" => "us-central1-b",
524
+ "status" => "UP",
525
+ "maintenanceWindows" => [{"name" => "2013-10-26-planned-outage",
526
+ "description" => "maintenance zone",
527
+ "beginTime" => "2013-10-26T12:00:00.000-07:00",
528
+ "endTime" => "2013-11-10T12:00:00.000-08:00"}],
529
+ "quotas" => [
530
+ {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
531
+ {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
532
+ {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
533
+ {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
534
+ ],
535
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central1"
536
+ },
537
+ "us-central2-a" => {
538
+ "kind" => "compute#zone",
539
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central2-a",
540
+ "id" => "13611654493253680292",
541
+ "creationTimestamp" => "2013-09-26T02:56:13.125-07:00",
542
+ "name" => "us-central2-a",
543
+ "description" => "us-central2-a",
544
+ "status" => "UP",
545
+ "maintenanceWindows" => [
546
+ {
547
+ "name" => "2013-10-12-planned-outage",
548
+ "description" => "maintenance zone",
549
+ "beginTime" => "2013-10-12T12:00:00.000-07:00",
550
+ "endTime" => "2013-10-27T12:00:00.000-07:00"
551
+ }
552
+ ],
553
+ "quotas" => [
554
+ {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
555
+ {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
556
+ {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
557
+ {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
558
+ ],
559
+ "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central2"
560
+ }
561
+ },
562
+ :regions => {
563
+ "us-central1" => {
564
+ "creationTimestamp" => '2014-01-21T10:30:54.895-08:00',
565
+ "description" => 'us-central1',
566
+ "id" => '18201118976141502843',
567
+ "kind" => "compute#region",
568
+ "name" =>"us-central1",
569
+ "quotas" => [
570
+ {"metric" =>"CPUS", "limit" => 1050.0, "usage" => 28.0},
571
+ {"metric" =>"DISKS_TOTAL_GB", "limit" => 10000.0, "usage" => 292.0},
572
+ {"metric" =>"STATIC_ADDRESSES", "limit" => 10.0, "usage" => 0.0},
573
+ {"metric" =>"IN_USE_ADDRESSES", "limit" => 1050.0, "usage" => 30.0},
574
+ {"metric" =>"SSD_TOTAL_GB", "limit" => 1024.0, "usage" => 0.0}
575
+ ],
576
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central1",
577
+ "status" => "UP",
578
+ "zones" => [
579
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
580
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-b",
581
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-f",
582
+ ]
583
+ },
584
+ "europe-west1" => {
585
+ "creationTimestamp" => '2014-01-21T10:30:54.891-08:00',
586
+ "description" => 'europe-west1',
587
+ "id" => '18201118976141502843',
588
+ "kind" => "compute#region",
589
+ "name" =>"europe-west1",
590
+ "quotas" => [
591
+ {"metric" =>"CPUS", "limit" => 24.0, "usage" => 0.0},
592
+ {"metric" =>"DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0},
593
+ {"metric" =>"STATIC_ADDRESSES", "limit" => 7.0, "usage" => 0.0},
594
+ {"metric" =>"IN_USE_ADDRESSES", "limit" => 23.0, "usage" => 0.0},
595
+ {"metric" =>"SSD_TOTAL_GB", "limit" => 1024.0, "usage" => 0.0}
596
+ ],
597
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/erope-west1",
598
+ "status" => "UP",
599
+ "zones" => [
600
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/europe-west1-a",
601
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/europe-west1-b",
602
+ ]
603
+ },
604
+ "asia-east1" => {
605
+ "creationTimestamp" => '2014-01-21T10:30:54.895-08:00',
606
+ "description" => 'asia-east1',
607
+ "id" => '18201118976141502843',
608
+ "kind" => "compute#region",
609
+ "name" =>"asia-east1",
610
+ "quotas" => [
611
+ {"metric" =>"CPUS", "limit" => 1050.0, "usage" => 28.0},
612
+ {"metric" =>"DISKS_TOTAL_GB", "limit" => 10000.0, "usage" => 292.0},
613
+ {"metric" =>"STATIC_ADDRESSES", "limit" => 10.0, "usage" => 0.0},
614
+ {"metric" =>"IN_USE_ADDRESSES", "limit" => 1050.0, "usage" => 30.0},
615
+ {"metric" =>"SSD_TOTAL_GB", "limit" => 1024.0, "usage" => 0.0}
616
+ ],
617
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/asia-east1",
618
+ "status" => "UP",
619
+ "zones" => [
620
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/asia-east1-a",
621
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/asia-east1-b",
622
+ "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/asia-east1-c",
623
+ ]
624
+ }
625
+ },
626
+
627
+ :machine_types => Hash.new do |machine_types_hash, zone|
628
+ machine_types_hash[zone] = {
629
+ "f1-micro" => {
630
+ "kind" => "compute#machineType",
631
+ "id" => "4618642685664990776",
632
+ "creationTimestamp" => "2013-04-25T13:32:49.088-07:00",
633
+ "name" => "f1-micro",
634
+ "description" => "1 vCPU (shared physical core) and 0.6 GB RAM",
635
+ "guestCpus" => 1,
636
+ "memoryMb" => 614,
637
+ "imageSpaceGb" => 0,
638
+ "maximumPersistentDisks" => 4,
639
+ "maximumPersistentDisksSizeGb" => "3072",
640
+ "zone" => zone,
641
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/f1-micro"
642
+ },
643
+ "g1-small" => {
644
+ "kind" => "compute#machineType",
645
+ "id" => "7224129552184485774",
646
+ "creationTimestamp" => "2013-04-25T13:32:45.550-07:00",
647
+ "name" => "g1-small",
648
+ "description" => "1 vCPU (shared physical core) and 1.7 GB RAM",
649
+ "guestCpus" => 1,
650
+ "memoryMb" => 1740,
651
+ "imageSpaceGb" => 0,
652
+ "maximumPersistentDisks" => 4,
653
+ "maximumPersistentDisksSizeGb" => "3072",
654
+ "zone" => zone,
655
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/g1-small"
656
+ },
657
+ "n1-highcpu-2" => {
658
+ "kind" => "compute#machineType",
659
+ "id" => "13043554592196512955",
660
+ "creationTimestamp" => "2012-11-16T11:46:10.572-08:00",
661
+ "name" => "n1-highcpu-2",
662
+ "description" => "2 vCPUs, 1.8 GB RAM",
663
+ "guestCpus" => 2,
664
+ "memoryMb" => 1843,
665
+ "imageSpaceGb" => 10,
666
+ "maximumPersistentDisks" => 16,
667
+ "maximumPersistentDisksSizeGb" => "10240",
668
+ "zone" => zone,
669
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-2"
670
+ },
671
+ "n1-highcpu-2-d" => {
672
+ "kind" => "compute#machineType",
673
+ "id" => "13043555176034896271",
674
+ "creationTimestamp" => "2012-11-16T11:47:07.825-08:00",
675
+ "name" => "n1-highcpu-2-d",
676
+ "description" => "2 vCPUs, 1.8 GB RAM, 1 scratch disk (870 GB)",
677
+ "guestCpus" => 2,
678
+ "memoryMb" => 1843,
679
+ "imageSpaceGb" => 10,
680
+ "scratchDisks" => [
681
+ {
682
+ "diskGb" => 870
683
+ }
684
+ ],
685
+ "maximumPersistentDisks" => 16,
686
+ "maximumPersistentDisksSizeGb" => "10240",
687
+ "zone" => zone,
688
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-2-d"
689
+ },
690
+ "n1-highcpu-4" => {
691
+ "kind" => "compute#machineType",
692
+ "id" => "13043555705736970382",
693
+ "creationTimestamp" => "2012-11-16T11:48:06.087-08:00",
694
+ "name" => "n1-highcpu-4",
695
+ "description" => "4 vCPUs, 3.6 GB RAM",
696
+ "guestCpus" => 4,
697
+ "memoryMb" => 3686,
698
+ "imageSpaceGb" => 10,
699
+ "maximumPersistentDisks" => 16,
700
+ "maximumPersistentDisksSizeGb" => "10240",
701
+ "zone" => zone,
702
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-4"
703
+ },
704
+ "n1-highcpu-4-d" => {
705
+ "kind" => "compute#machineType",
706
+ "id" => "13043556330284250611",
707
+ "creationTimestamp" => "2012-11-16T11:49:07.563-08:00",
708
+ "name" => "n1-highcpu-4-d",
709
+ "description" => "4 vCPUS, 3.6 GB RAM, 1 scratch disk (1770 GB)",
710
+ "guestCpus" => 4,
711
+ "memoryMb" => 3686,
712
+ "imageSpaceGb" => 10,
713
+ "scratchDisks" => [
714
+ {
715
+ "diskGb" => 1770
716
+ }
717
+ ],
718
+ "maximumPersistentDisks" => 16,
719
+ "maximumPersistentDisksSizeGb" => "10240",
720
+ "zone" => zone,
721
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-4-d"
722
+ },
723
+ "n1-highcpu-8" => {
724
+ "kind" => "compute#machineType",
725
+ "id" => "13043556949665240937",
726
+ "creationTimestamp" => "2012-11-16T11:50:15.128-08:00",
727
+ "name" => "n1-highcpu-8",
728
+ "description" => "8 vCPUs, 7.2 GB RAM",
729
+ "guestCpus" => 8,
730
+ "memoryMb" => 7373,
731
+ "imageSpaceGb" => 10,
732
+ "maximumPersistentDisks" => 16,
733
+ "maximumPersistentDisksSizeGb" => "10240",
734
+ "zone" => zone,
735
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-8"
736
+ },
737
+ "n1-highcpu-8-d" => {
738
+ "kind" => "compute#machineType",
739
+ "id" => "13043557458004959701",
740
+ "creationTimestamp" => "2012-11-16T11:51:04.549-08:00",
741
+ "name" => "n1-highcpu-8-d",
742
+ "description" => "8 vCPUS, 7.2 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
743
+ "guestCpus" => 8,
744
+ "memoryMb" => 7373,
745
+ "imageSpaceGb" => 10,
746
+ "scratchDisks" => [
747
+ {
748
+ "diskGb" => 1770
749
+ },
750
+ {
751
+ "diskGb" => 1770
752
+ }
753
+ ],
754
+ "maximumPersistentDisks" => 16,
755
+ "maximumPersistentDisksSizeGb" => "10240",
756
+ "zone" => zone,
757
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-8-d"
758
+ },
759
+ "n1-highmem-2" => {
760
+ "kind" => "compute#machineType",
761
+ "id" => "13043551079318055993",
762
+ "creationTimestamp" => "2012-11-16T11:40:06.129-08:00",
763
+ "name" => "n1-highmem-2",
764
+ "description" => "2 vCPUs, 13 GB RAM",
765
+ "guestCpus" => 2,
766
+ "memoryMb" => 13312,
767
+ "imageSpaceGb" => 10,
768
+ "maximumPersistentDisks" => 16,
769
+ "maximumPersistentDisksSizeGb" => "10240",
770
+ "zone" => zone,
771
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-2"
772
+ },
773
+ "n1-highmem-2-d" => {
774
+ "kind" => "compute#machineType",
775
+ "id" => "13043551625558644085",
776
+ "creationTimestamp" => "2012-11-16T11:40:59.630-08:00",
777
+ "name" => "n1-highmem-2-d",
778
+ "description" => "2 vCPUs, 13 GB RAM, 1 scratch disk (870 GB)",
779
+ "guestCpus" => 2,
780
+ "memoryMb" => 13312,
781
+ "imageSpaceGb" => 10,
782
+ "scratchDisks" => [
783
+ {
784
+ "diskGb" => 870
785
+ }
786
+ ],
787
+ "maximumPersistentDisks" => 16,
788
+ "maximumPersistentDisksSizeGb" => "10240",
789
+ "zone" => zone,
790
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-2-d"
791
+ },
792
+ "n1-highmem-4" => {
793
+ "kind" => "compute#machineType",
794
+ "id" => "13043552263604939569",
795
+ "creationTimestamp" => "2012-11-16T11:42:08.983-08:00",
796
+ "name" => "n1-highmem-4",
797
+ "description" => "4 vCPUs, 26 GB RAM",
798
+ "guestCpus" => 4,
799
+ "memoryMb" => 26624,
800
+ "imageSpaceGb" => 10,
801
+ "maximumPersistentDisks" => 16,
802
+ "maximumPersistentDisksSizeGb" => "10240",
803
+ "zone" => zone,
804
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-4"
805
+ },
806
+ "n1-highmem-4-d" => {
807
+ "kind" => "compute#machineType",
808
+ "id" => "13043552953632709737",
809
+ "creationTimestamp" => "2012-11-16T11:43:17.400-08:00",
810
+ "name" => "n1-highmem-4-d",
811
+ "description" => "4 vCPUs, 26 GB RAM, 1 scratch disk (1770 GB)",
812
+ "guestCpus" => 4,
813
+ "memoryMb" => 26624,
814
+ "imageSpaceGb" => 10,
815
+ "scratchDisks" => [
816
+ {
817
+ "diskGb" => 1770
818
+ }
819
+ ],
820
+ "maximumPersistentDisks" => 16,
821
+ "maximumPersistentDisksSizeGb" => "10240",
822
+ "zone" => zone,
823
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-4-d"
824
+ },
825
+ "n1-highmem-8" => {
826
+ "kind" => "compute#machineType",
827
+ "id" => "13043553584275586275",
828
+ "creationTimestamp" => "2012-11-16T11:44:25.985-08:00",
829
+ "name" => "n1-highmem-8",
830
+ "description" => "8 vCPUs, 52 GB RAM",
831
+ "guestCpus" => 8,
832
+ "memoryMb" => 53248,
833
+ "imageSpaceGb" => 10,
834
+ "maximumPersistentDisks" => 16,
835
+ "maximumPersistentDisksSizeGb" => "10240",
836
+ "zone" => zone,
837
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-8"
838
+ },
839
+ "n1-highmem-8-d" => {
840
+ "kind" => "compute#machineType",
841
+ "id" => "13043554021673472746",
842
+ "creationTimestamp" => "2012-11-16T11:45:08.195-08:00",
843
+ "name" => "n1-highmem-8-d",
844
+ "description" => "8 vCPUs, 52 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
845
+ "guestCpus" => 8,
846
+ "memoryMb" => 53248,
847
+ "imageSpaceGb" => 10,
848
+ "scratchDisks" => [
849
+ {
850
+ "diskGb" => 1770
851
+ },
852
+ {
853
+ "diskGb" => 1770
854
+ }
855
+ ],
856
+ "maximumPersistentDisks" => 16,
857
+ "maximumPersistentDisksSizeGb" => "10240",
858
+ "zone" => zone,
859
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-8-d"
860
+ },
861
+ "n1-standard-1" => {
862
+ "kind" => "compute#machineType",
863
+ "id" => "12907738072351752276",
864
+ "creationTimestamp" => "2012-06-07T13:48:14.670-07:00",
865
+ "name" => "n1-standard-1",
866
+ "description" => "1 vCPU, 3.75 GB RAM",
867
+ "guestCpus" => 1,
868
+ "memoryMb" => 3840,
869
+ "imageSpaceGb" => 10,
870
+ "maximumPersistentDisks" => 16,
871
+ "maximumPersistentDisksSizeGb" => "10240",
872
+ "zone" => zone,
873
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-1"
874
+ },
875
+ "n1-standard-1-d" => {
876
+ "kind" => "compute#machineType",
877
+ "id" => "12908559201265214706",
878
+ "creationTimestamp" => "2012-06-07T13:48:34.258-07:00",
879
+ "name" => "n1-standard-1-d",
880
+ "description" => "1 vCPU, 3.75 GB RAM, 1 scratch disk (420 GB)",
881
+ "guestCpus" => 1,
882
+ "memoryMb" => 3840,
883
+ "imageSpaceGb" => 10,
884
+ "scratchDisks" => [
885
+ {
886
+ "diskGb" => 420
887
+ }
888
+ ],
889
+ "maximumPersistentDisks" => 16,
890
+ "maximumPersistentDisksSizeGb" => "10240",
891
+ "zone" => zone,
892
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-1-d"
893
+ },
894
+ "n1-standard-2" => {
895
+ "kind" => "compute#machineType",
896
+ "id" => "12908559320241551184",
897
+ "creationTimestamp" => "2012-06-07T13:48:56.867-07:00",
898
+ "name" => "n1-standard-2",
899
+ "description" => "2 vCPUs, 7.5 GB RAM",
900
+ "guestCpus" => 2,
901
+ "memoryMb" => 7680,
902
+ "imageSpaceGb" => 10,
903
+ "maximumPersistentDisks" => 16,
904
+ "maximumPersistentDisksSizeGb" => "10240",
905
+ "zone" => zone,
906
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-2"
907
+ },
908
+ "n1-standard-2-d" => {
909
+ "kind" => "compute#machineType",
910
+ "id" => "12908559582417967837",
911
+ "creationTimestamp" => "2012-06-07T13:49:19.448-07:00",
912
+ "name" => "n1-standard-2-d",
913
+ "description" => "2 vCPUs, 7.5 GB RAM, 1 scratch disk (870 GB)",
914
+ "guestCpus" => 2,
915
+ "memoryMb" => 7680,
916
+ "imageSpaceGb" => 10,
917
+ "scratchDisks" => [
918
+ {
919
+ "diskGb" => 870
920
+ }
921
+ ],
922
+ "maximumPersistentDisks" => 16,
923
+ "maximumPersistentDisksSizeGb" => "10240",
924
+ "zone" => zone,
925
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-2-d"
926
+ },
927
+ "n1-standard-4" => {
928
+ "kind" => "compute#machineType",
929
+ "id" => "12908559692070444049",
930
+ "creationTimestamp" => "2012-06-07T13:49:40.050-07:00",
931
+ "name" => "n1-standard-4",
932
+ "description" => "4 vCPUs, 15 GB RAM",
933
+ "guestCpus" => 4,
934
+ "memoryMb" => 15360,
935
+ "imageSpaceGb" => 10,
936
+ "maximumPersistentDisks" => 16,
937
+ "maximumPersistentDisksSizeGb" => "10240",
938
+ "zone" => zone,
939
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-4"
940
+ },
941
+ "n1-standard-4-d" => {
942
+ "kind" => "compute#machineType",
943
+ "id" => "12908559991903153608",
944
+ "creationTimestamp" => "2012-06-07T13:50:05.677-07:00",
945
+ "name" => "n1-standard-4-d",
946
+ "description" => "4 vCPUs, 15 GB RAM, 1 scratch disk (1770 GB)",
947
+ "guestCpus" => 4,
948
+ "memoryMb" => 15360,
949
+ "imageSpaceGb" => 10,
950
+ "scratchDisks" => [
951
+ {
952
+ "diskGb" => 1770
953
+ }
954
+ ],
955
+ "maximumPersistentDisks" => 16,
956
+ "maximumPersistentDisksSizeGb" => "10240",
957
+ "zone" => zone,
958
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-4-d"
959
+ },
960
+ "n1-standard-8" => {
961
+ "kind" => "compute#machineType",
962
+ "id" => "12908560197989714867",
963
+ "creationTimestamp" => "2012-06-07T13:50:42.334-07:00",
964
+ "name" => "n1-standard-8",
965
+ "description" => "8 vCPUs, 30 GB RAM",
966
+ "guestCpus" => 8,
967
+ "memoryMb" => 30720,
968
+ "imageSpaceGb" => 10,
969
+ "maximumPersistentDisks" => 16,
970
+ "maximumPersistentDisksSizeGb" => "10240",
971
+ "zone" => zone,
972
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-8"
973
+ },
974
+ "n1-standard-8-d" => {
975
+ "kind" => "compute#machineType",
976
+ "id" => "12908560709887590691",
977
+ "creationTimestamp" => "2012-06-07T13:51:19.936-07:00",
978
+ "name" => "n1-standard-8-d",
979
+ "description" => "8 vCPUs, 30 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
980
+ "guestCpus" => 8,
981
+ "memoryMb" => 30720,
982
+ "imageSpaceGb" => 10,
983
+ "scratchDisks" => [
984
+ {
985
+ "diskGb" => 1770
986
+ },
987
+ {
988
+ "diskGb" => 1770
989
+ }
990
+ ],
991
+ "maximumPersistentDisks" => 16,
992
+ "maximumPersistentDisksSizeGb" => "10240",
993
+ "zone" => zone,
994
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-8-d"
995
+ }
996
+ }
997
+ end,
998
+ :images => {},
999
+ :disks => {
1000
+ "fog-1" => {
1001
+ "kind" => "compute#disk",
1002
+ "id" => "3338131294770784461",
1003
+ "creationTimestamp" => "2013-12-18T19:47:10.583-08:00",
1004
+ "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
1005
+ "status" => "READY",
1006
+ "name" => "fog-1",
1007
+ "sizeGb" => "10",
1008
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1",
1009
+ "sourceImage" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
1010
+ "sourceImageId" => "17312518942796567788",
1011
+ "type" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/diskTypes/pd-standard",
1012
+ },
1013
+ "fog-2" => {
1014
+ "kind" => "compute#disk",
1015
+ "id" => "3338131294770784462",
1016
+ "creationTimestamp" => "2013-12-18T19:47:10.583-08:00",
1017
+ "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
1018
+ "status" => "READY",
1019
+ "name" => "fog-2",
1020
+ "sizeGb" => "10",
1021
+ "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1",
1022
+ "type" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/diskTypes/pd-ssd",
1023
+ }
1024
+ },
1025
+ :operations => {}
1026
+ }
1027
+ end
1028
+ end
1029
+ end
1030
+
1031
+ def self.reset
1032
+ @data = nil
1033
+ end
1034
+
1035
+ def data(project=@project)
1036
+ self.class.data(api_version)[project]
1037
+ end
1038
+
1039
+ def reset_data
1040
+ # not particularly useful because it deletes zones
1041
+ self.class.data(api_version).delete(@project)
1042
+ end
1043
+
1044
+ def random_operation
1045
+ "operation-#{Fog::Mock.random_numbers(13)}-#{Fog::Mock.random_hex(13)}-#{Fog::Mock.random_hex(8)}"
1046
+ end
1047
+ end
1048
+
1049
+ class Real
1050
+ include Fog::Google::Shared
1051
+
1052
+ attr_accessor :client
1053
+ attr_reader :compute
1054
+
1055
+ def initialize(options)
1056
+ shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
1057
+ options.merge!(:google_api_scope_url => GOOGLE_COMPUTE_API_SCOPE_URLS.join(' '))
1058
+
1059
+ @client = initialize_google_client(options)
1060
+ @compute = @client.discovered_api('compute', api_version)
1061
+ @resourceviews = @client.discovered_api('resourceviews', 'v1beta1')
1062
+ end
1063
+ end
1064
+
1065
+ RUNNING = 'RUNNING'
1066
+ end
1067
+ end
1068
+ end