fog 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +1 -0
  3. data/Rakefile +2 -1
  4. data/changelog.txt +184 -0
  5. data/docs/cdn/index.markdown +69 -3
  6. data/fog.gemspec +2 -2
  7. data/lib/fog.rb +2 -1
  8. data/lib/fog/atmos/models/storage/file.rb +16 -14
  9. data/lib/fog/aws/auto_scaling.rb +55 -13
  10. data/lib/fog/aws/cdn.rb +69 -9
  11. data/lib/fog/aws/cloud_watch.rb +15 -1
  12. data/lib/fog/aws/compute.rb +2 -0
  13. data/lib/fog/aws/models/auto_scaling/group.rb +10 -4
  14. data/lib/fog/aws/models/cdn/distribution.rb +93 -0
  15. data/lib/fog/aws/models/cdn/distribution_helper.rb +64 -0
  16. data/lib/fog/aws/models/cdn/distributions.rb +32 -0
  17. data/lib/fog/aws/models/cdn/distributions_helper.rb +47 -0
  18. data/lib/fog/aws/models/cdn/invalidation.rb +64 -0
  19. data/lib/fog/aws/models/cdn/invalidations.rb +54 -0
  20. data/lib/fog/aws/models/cdn/streaming_distribution.rb +77 -0
  21. data/lib/fog/aws/models/cdn/streaming_distributions.rb +32 -0
  22. data/lib/fog/aws/models/compute/server.rb +0 -23
  23. data/lib/fog/aws/models/compute/spot_request.rb +2 -24
  24. data/lib/fog/aws/models/rds/server.rb +18 -0
  25. data/lib/fog/aws/models/rds/subnet_group.rb +20 -0
  26. data/lib/fog/aws/models/rds/subnet_groups.rb +27 -0
  27. data/lib/fog/aws/models/storage/file.rb +1 -1
  28. data/lib/fog/aws/parsers/auto_scaling/describe_adjustment_types.rb +15 -2
  29. data/lib/fog/aws/parsers/auto_scaling/describe_auto_scaling_groups.rb +39 -13
  30. data/lib/fog/aws/parsers/auto_scaling/describe_auto_scaling_notification_types.rb +43 -0
  31. data/lib/fog/aws/parsers/auto_scaling/describe_metric_collection_types.rb +3 -3
  32. data/lib/fog/aws/parsers/auto_scaling/describe_notification_configurations.rb +42 -0
  33. data/lib/fog/aws/parsers/auto_scaling/describe_scaling_process_types.rb +15 -2
  34. data/lib/fog/aws/parsers/auto_scaling/describe_tags.rb +46 -0
  35. data/lib/fog/aws/parsers/auto_scaling/describe_termination_policy_types.rb +44 -0
  36. data/lib/fog/aws/parsers/cdn/get_invalidation.rb +32 -0
  37. data/lib/fog/aws/parsers/cloud_formation/describe_stacks.rb +1 -1
  38. data/lib/fog/aws/parsers/cloud_watch/list_metrics.rb +1 -1
  39. data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +13 -2
  40. data/lib/fog/aws/parsers/compute/describe_reserved_instances.rb +1 -1
  41. data/lib/fog/aws/parsers/elasticache/base.rb +0 -2
  42. data/lib/fog/aws/parsers/elasticache/engine_defaults_parser.rb +1 -1
  43. data/lib/fog/aws/parsers/elasticache/event_list.rb +2 -0
  44. data/lib/fog/aws/parsers/rds/base.rb +32 -0
  45. data/lib/fog/aws/parsers/rds/create_db_subnet_group.rb +38 -0
  46. data/lib/fog/aws/parsers/rds/describe_db_subnet_groups.rb +38 -0
  47. data/lib/fog/aws/parsers/rds/event_list.rb +40 -0
  48. data/lib/fog/aws/parsers/rds/subnet_group_parser.rb +38 -0
  49. data/lib/fog/aws/parsers/rds/tag_list_parser.rb +35 -0
  50. data/lib/fog/aws/rds.rb +24 -7
  51. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +36 -16
  52. data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +19 -12
  53. data/lib/fog/aws/requests/auto_scaling/create_or_update_tags.rb +63 -0
  54. data/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +10 -3
  55. data/lib/fog/aws/requests/auto_scaling/delete_notification_configuration.rb +21 -5
  56. data/lib/fog/aws/requests/auto_scaling/delete_policy.rb +2 -2
  57. data/lib/fog/aws/requests/auto_scaling/delete_tags.rb +63 -0
  58. data/lib/fog/aws/requests/auto_scaling/describe_adjustment_types.rb +4 -3
  59. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb +17 -13
  60. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +1 -1
  61. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_notification_types.rb +55 -0
  62. data/lib/fog/aws/requests/auto_scaling/describe_metric_collection_types.rb +6 -5
  63. data/lib/fog/aws/requests/auto_scaling/describe_notification_configurations.rb +79 -0
  64. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +1 -1
  65. data/lib/fog/aws/requests/auto_scaling/describe_scaling_process_types.rb +4 -3
  66. data/lib/fog/aws/requests/auto_scaling/describe_tags.rb +74 -0
  67. data/lib/fog/aws/requests/auto_scaling/describe_termination_policy_types.rb +53 -0
  68. data/lib/fog/aws/requests/auto_scaling/disable_metrics_collection.rb +1 -1
  69. data/lib/fog/aws/requests/auto_scaling/enable_metrics_collection.rb +2 -2
  70. data/lib/fog/aws/requests/auto_scaling/put_notification_configuration.rb +30 -11
  71. data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +4 -4
  72. data/lib/fog/aws/requests/auto_scaling/put_scheduled_update_group_action.rb +8 -5
  73. data/lib/fog/aws/requests/auto_scaling/set_desired_capacity.rb +2 -2
  74. data/lib/fog/aws/requests/auto_scaling/set_instance_health.rb +2 -2
  75. data/lib/fog/aws/requests/auto_scaling/suspend_processes.rb +1 -1
  76. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +30 -18
  77. data/lib/fog/aws/requests/cdn/delete_distribution.rb +31 -0
  78. data/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb +30 -0
  79. data/lib/fog/aws/requests/cdn/get_distribution.rb +28 -0
  80. data/lib/fog/aws/requests/cdn/get_distribution_list.rb +29 -0
  81. data/lib/fog/aws/requests/cdn/get_invalidation.rb +60 -0
  82. data/lib/fog/aws/requests/cdn/get_invalidation_list.rb +41 -0
  83. data/lib/fog/aws/requests/cdn/get_streaming_distribution.rb +26 -0
  84. data/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb +30 -0
  85. data/lib/fog/aws/requests/cdn/post_distribution.rb +44 -0
  86. data/lib/fog/aws/requests/cdn/post_invalidation.rb +33 -0
  87. data/lib/fog/aws/requests/cdn/post_streaming_distribution.rb +44 -0
  88. data/lib/fog/aws/requests/cdn/put_distribution_config.rb +28 -0
  89. data/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb +28 -0
  90. data/lib/fog/aws/requests/compute/create_image.rb +32 -5
  91. data/lib/fog/aws/requests/compute/create_subnet.rb +3 -3
  92. data/lib/fog/aws/requests/compute/create_volume.rb +2 -2
  93. data/lib/fog/aws/requests/compute/register_image.rb +1 -1
  94. data/lib/fog/aws/requests/elasticache/describe_events.rb +7 -4
  95. data/lib/fog/aws/requests/glacier/create_archive.rb +1 -1
  96. data/lib/fog/aws/requests/glacier/initiate_multipart_upload.rb +1 -1
  97. data/lib/fog/aws/requests/rds/add_tags_to_resource.rb +46 -0
  98. data/lib/fog/aws/requests/rds/create_db_instance.rb +2 -0
  99. data/lib/fog/aws/requests/rds/create_db_subnet_group.rb +58 -0
  100. data/lib/fog/aws/requests/rds/describe_db_subnet_groups.rb +63 -0
  101. data/lib/fog/aws/requests/rds/describe_events.rb +52 -0
  102. data/lib/fog/aws/requests/rds/list_tags_for_resource.rb +44 -0
  103. data/lib/fog/aws/requests/rds/remove_tags_from_resource.rb +44 -0
  104. data/lib/fog/aws/sqs.rb +1 -1
  105. data/lib/fog/aws/storage.rb +1 -1
  106. data/lib/fog/bin/openstack.rb +5 -0
  107. data/lib/fog/bluebox/models/compute/server.rb +0 -19
  108. data/lib/fog/bluebox/requests/compute/create_block.rb +8 -8
  109. data/lib/fog/brightbox/compute.rb +56 -7
  110. data/lib/fog/brightbox/models/compute/accounts.rb +29 -0
  111. data/lib/fog/brightbox/models/compute/api_client.rb +37 -0
  112. data/lib/fog/brightbox/models/compute/api_clients.rb +24 -0
  113. data/lib/fog/brightbox/models/compute/application.rb +27 -0
  114. data/lib/fog/brightbox/models/compute/applications.rb +28 -0
  115. data/lib/fog/brightbox/models/compute/server.rb +3 -1
  116. data/lib/fog/brightbox/models/compute/users.rb +1 -3
  117. data/lib/fog/brightbox/requests/compute/create_application.rb +13 -0
  118. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +2 -2
  119. data/lib/fog/brightbox/requests/compute/destroy_application.rb +14 -0
  120. data/lib/fog/brightbox/requests/compute/get_account.rb +28 -4
  121. data/lib/fog/brightbox/requests/compute/get_application.rb +14 -0
  122. data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +19 -0
  123. data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +19 -0
  124. data/lib/fog/brightbox/requests/compute/get_user.rb +28 -5
  125. data/lib/fog/brightbox/requests/compute/list_accounts.rb +13 -0
  126. data/lib/fog/brightbox/requests/compute/list_applications.rb +13 -0
  127. data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +14 -0
  128. data/lib/fog/brightbox/requests/compute/update_account.rb +51 -3
  129. data/lib/fog/brightbox/requests/compute/update_application.rb +15 -0
  130. data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +4 -2
  131. data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +37 -0
  132. data/lib/fog/clodo/models/compute/server.rb +7 -44
  133. data/lib/fog/compute/models/server.rb +23 -2
  134. data/lib/fog/core/time.rb +2 -0
  135. data/lib/fog/core/wait_for.rb +0 -2
  136. data/lib/fog/ecloud/models/compute/servers.rb +3 -1
  137. data/lib/fog/ecloud/requests/compute/get_servers.rb +1 -1
  138. data/lib/fog/ecloud/requests/compute/get_tasks.rb +1 -1
  139. data/lib/fog/go_grid/models/compute/server.rb +0 -4
  140. data/lib/fog/google/storage.rb +1 -1
  141. data/lib/fog/hp/models/compute/server.rb +1 -23
  142. data/lib/fog/hp/storage.rb +0 -1
  143. data/lib/fog/joyent/models/compute/server.rb +4 -0
  144. data/lib/fog/joyent/models/compute/servers.rb +4 -3
  145. data/lib/fog/libvirt/models/compute/server.rb +1 -27
  146. data/lib/fog/linode/models/compute/server.rb +0 -1
  147. data/lib/fog/local/models/storage/directory.rb +1 -1
  148. data/lib/fog/network.rb +26 -0
  149. data/lib/fog/ninefold/compute.rb +8 -0
  150. data/lib/fog/ninefold/requests/compute/assign_to_load_balancer_rule.rb +13 -0
  151. data/lib/fog/ninefold/requests/compute/create_load_balancer_rule.rb +11 -0
  152. data/lib/fog/ninefold/requests/compute/delete_load_balancer_rule.rb +11 -0
  153. data/lib/fog/ninefold/requests/compute/list_load_balancer_rule_instances.rb +15 -0
  154. data/lib/fog/ninefold/requests/compute/list_load_balancer_rules.rb +14 -0
  155. data/lib/fog/ninefold/requests/compute/remove_from_load_balancer_rule.rb +12 -0
  156. data/lib/fog/ninefold/requests/compute/update_load_balancer_rule.rb +15 -0
  157. data/lib/fog/ninefold/storage.rb +14 -112
  158. data/lib/fog/openstack.rb +4 -1
  159. data/lib/fog/openstack/compute.rb +20 -1
  160. data/lib/fog/openstack/identity.rb +67 -18
  161. data/lib/fog/openstack/image.rb +12 -4
  162. data/lib/fog/openstack/models/compute/security_group.rb +1 -1
  163. data/lib/fog/openstack/models/compute/server.rb +5 -23
  164. data/lib/fog/openstack/models/identity/tenants.rb +5 -3
  165. data/lib/fog/openstack/models/identity/users.rb +4 -1
  166. data/lib/fog/openstack/models/image/image.rb +6 -1
  167. data/lib/fog/openstack/models/network/network.rb +46 -0
  168. data/lib/fog/openstack/models/network/networks.rb +34 -0
  169. data/lib/fog/openstack/models/network/port.rb +52 -0
  170. data/lib/fog/openstack/models/network/ports.rb +34 -0
  171. data/lib/fog/openstack/models/network/subnet.rb +55 -0
  172. data/lib/fog/openstack/models/network/subnets.rb +34 -0
  173. data/lib/fog/openstack/network.rb +234 -0
  174. data/lib/fog/openstack/requests/compute/attach_volume.rb +10 -0
  175. data/lib/fog/openstack/requests/compute/create_security_group.rb +15 -11
  176. data/lib/fog/openstack/requests/compute/create_security_group_rule.rb +17 -15
  177. data/lib/fog/openstack/requests/compute/create_server.rb +7 -1
  178. data/lib/fog/openstack/requests/compute/create_volume.rb +10 -10
  179. data/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +16 -1
  180. data/lib/fog/openstack/requests/compute/detach_volume.rb +5 -0
  181. data/lib/fog/openstack/requests/compute/get_snapshot_details.rb +4 -4
  182. data/lib/fog/openstack/requests/compute/get_volume_details.rb +9 -9
  183. data/lib/fog/openstack/requests/compute/list_security_groups.rb +3 -3
  184. data/lib/fog/openstack/requests/compute/list_volumes.rb +14 -14
  185. data/lib/fog/openstack/requests/identity/create_tenant.rb +3 -3
  186. data/lib/fog/openstack/requests/identity/create_user.rb +1 -1
  187. data/lib/fog/openstack/requests/identity/delete_role.rb +1 -1
  188. data/lib/fog/openstack/requests/identity/get_tenant.rb +1 -1
  189. data/lib/fog/openstack/requests/identity/list_roles.rb +7 -0
  190. data/lib/fog/openstack/requests/image/create_image.rb +36 -38
  191. data/lib/fog/openstack/requests/image/delete_image.rb +0 -2
  192. data/lib/fog/openstack/requests/image/list_public_images.rb +7 -25
  193. data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +2 -41
  194. data/lib/fog/openstack/requests/image/update_image.rb +26 -21
  195. data/lib/fog/openstack/requests/image/update_image_members.rb +37 -0
  196. data/lib/fog/openstack/requests/network/create_network.rb +44 -0
  197. data/lib/fog/openstack/requests/network/create_port.rb +52 -0
  198. data/lib/fog/openstack/requests/network/create_subnet.rb +56 -0
  199. data/lib/fog/openstack/requests/network/delete_network.rb +30 -0
  200. data/lib/fog/openstack/requests/network/delete_port.rb +30 -0
  201. data/lib/fog/openstack/requests/network/delete_subnet.rb +30 -0
  202. data/lib/fog/openstack/requests/network/get_network.rb +42 -0
  203. data/lib/fog/openstack/requests/network/get_port.rb +48 -0
  204. data/lib/fog/openstack/requests/network/get_subnet.rb +49 -0
  205. data/lib/fog/openstack/requests/network/list_networks.rb +27 -0
  206. data/lib/fog/openstack/requests/network/list_ports.rb +27 -0
  207. data/lib/fog/openstack/requests/network/list_subnets.rb +27 -0
  208. data/lib/fog/openstack/requests/network/set_tenant.rb +21 -0
  209. data/lib/fog/openstack/requests/network/update_network.rb +41 -0
  210. data/lib/fog/openstack/requests/network/update_port.rb +44 -0
  211. data/lib/fog/openstack/requests/network/update_subnet.rb +44 -0
  212. data/lib/fog/openstack/requests/volume/create_volume.rb +10 -10
  213. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +16 -1
  214. data/lib/fog/openstack/requests/volume/get_snapshot_details.rb +6 -6
  215. data/lib/fog/openstack/requests/volume/get_volume_details.rb +10 -10
  216. data/lib/fog/openstack/requests/volume/list_volumes.rb +14 -14
  217. data/lib/fog/openstack/volume.rb +10 -0
  218. data/lib/fog/rackspace/models/compute/server.rb +1 -24
  219. data/lib/fog/rackspace/models/compute_v2/server.rb +4 -2
  220. data/lib/fog/rackspace/requests/compute_v2/create_server.rb +1 -1
  221. data/lib/fog/rackspace/requests/compute_v2/list_servers.rb +1 -1
  222. data/lib/fog/storm_on_demand/models/compute/server.rb +1 -5
  223. data/lib/fog/virtual_box/models/compute/server.rb +2 -44
  224. data/lib/fog/vmfusion/models/compute/server.rb +3 -36
  225. data/lib/fog/vsphere/models/compute/server.rb +1 -1
  226. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +2 -31
  227. data/lib/fog/vsphere/requests/compute/vm_clone.rb +35 -7
  228. data/tests/aws/models/cdn/distribution_tests.rb +15 -0
  229. data/tests/aws/models/cdn/distributions_tests.rb +15 -0
  230. data/tests/aws/models/cdn/invalidation_tests.rb +32 -0
  231. data/tests/aws/models/cdn/invalidations_tests.rb +15 -0
  232. data/tests/aws/models/cdn/streaming_distribution_tests.rb +15 -0
  233. data/tests/aws/models/cdn/streaming_distributions_tests.rb +15 -0
  234. data/tests/aws/models/rds/tagging_tests.rb +20 -0
  235. data/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +1 -11
  236. data/tests/aws/requests/auto_scaling/describe_types_tests.rb +102 -0
  237. data/tests/aws/requests/auto_scaling/helper.rb +47 -3
  238. data/tests/aws/requests/auto_scaling/notification_configuration_tests.rb +123 -0
  239. data/tests/aws/requests/auto_scaling/tag_tests.rb +62 -0
  240. data/tests/aws/requests/cdn/cdn_tests.rb +252 -0
  241. data/tests/aws/requests/compute/image_tests.rb +32 -1
  242. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  243. data/tests/aws/requests/rds/describe_events.rb +16 -0
  244. data/tests/aws/requests/rds/helper.rb +26 -0
  245. data/tests/aws/requests/rds/subnet_groups_test.rb +48 -0
  246. data/tests/aws/requests/rds/tagging_tests.rb +78 -0
  247. data/tests/brightbox/requests/compute/account_tests.rb +24 -4
  248. data/tests/brightbox/requests/compute/application_test.rb +63 -0
  249. data/tests/brightbox/requests/compute/helper.rb +49 -1
  250. data/tests/helper.rb +4 -1
  251. data/tests/local/models/directory_tests.rb +16 -0
  252. data/tests/ninefold/requests/compute/helper.rb +53 -0
  253. data/tests/ninefold/requests/compute/load_balancer_tests.rb +66 -0
  254. data/tests/openstack/models/image/image_tests.rb +1 -0
  255. data/tests/openstack/models/network/network_tests.rb +24 -0
  256. data/tests/openstack/models/network/networks_tests.rb +21 -0
  257. data/tests/openstack/models/network/port_tests.rb +28 -0
  258. data/tests/openstack/models/network/ports_tests.rb +25 -0
  259. data/tests/openstack/models/network/subnet_tests.rb +30 -0
  260. data/tests/openstack/models/network/subnets_tests.rb +27 -0
  261. data/tests/openstack/requests/compute/image_tests.rb +3 -4
  262. data/tests/openstack/requests/compute/quota_tests.rb +2 -0
  263. data/tests/openstack/requests/compute/security_group_tests.rb +10 -10
  264. data/tests/openstack/requests/compute/server_tests.rb +3 -1
  265. data/tests/openstack/requests/compute/volume_tests.rb +11 -12
  266. data/tests/openstack/requests/identity/tenant_tests.rb +2 -1
  267. data/tests/openstack/requests/image/image_tests.rb +66 -45
  268. data/tests/openstack/requests/network/network_tests.rb +56 -0
  269. data/tests/openstack/requests/network/port_tests.rb +63 -0
  270. data/tests/openstack/requests/network/subnet_tests.rb +66 -0
  271. data/tests/rackspace/models/identity/user_tests.rb +1 -1
  272. data/tests/rackspace/models/identity/users_tests.rb +1 -1
  273. metadata +137 -13
  274. data/lib/fog/ninefold/models/storage/directories.rb +0 -48
  275. data/lib/fog/ninefold/models/storage/directory.rb +0 -53
  276. data/lib/fog/ninefold/models/storage/file.rb +0 -108
  277. data/lib/fog/ninefold/models/storage/files.rb +0 -73
  278. data/lib/fog/ninefold/requests/storage/delete_namespace.rb +0 -19
  279. data/lib/fog/ninefold/requests/storage/get_namespace.rb +0 -20
  280. data/lib/fog/ninefold/requests/storage/head_namespace.rb +0 -20
  281. data/lib/fog/ninefold/requests/storage/post_namespace.rb +0 -20
  282. data/lib/fog/ninefold/requests/storage/put_namespace.rb +0 -20
@@ -9,7 +9,11 @@ module Fog
9
9
  requires :aws_access_key_id, :aws_secret_access_key
10
10
  recognizes :host, :path, :port, :scheme, :version, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at
11
11
 
12
- model_path 'fog/aws/cdn/models'
12
+ model_path 'fog/aws/models/cdn'
13
+ model :distribution
14
+ collection :distributions
15
+ model :streaming_distribution
16
+ collection :streaming_distributions
13
17
 
14
18
  request_path 'fog/aws/requests/cdn'
15
19
  request 'delete_distribution'
@@ -17,6 +21,7 @@ module Fog
17
21
  request 'get_distribution'
18
22
  request 'get_distribution_list'
19
23
  request 'get_invalidation_list'
24
+ request 'get_invalidation'
20
25
  request 'get_streaming_distribution'
21
26
  request 'get_streaming_distribution_list'
22
27
  request 'post_distribution'
@@ -28,12 +33,12 @@ module Fog
28
33
  class Mock
29
34
 
30
35
  def self.data
31
- @data ||= Hash.new do |hash, region|
32
- hash[region] = Hash.new do |region_hash, key|
33
- region_hash[key] = {
34
- :buckets => {}
36
+ @data ||= Hash.new do |hash, key|
37
+ hash[key] = {
38
+ :distributions => {},
39
+ :streaming_distributions => {},
40
+ :invalidations => {}
35
41
  }
36
- end
37
42
  end
38
43
  end
39
44
 
@@ -45,15 +50,14 @@ module Fog
45
50
  require 'mime/types'
46
51
  @use_iam_profile = options[:use_iam_profile]
47
52
  setup_credentials(options)
48
- @region = options[:region]
49
53
  end
50
54
 
51
55
  def data
52
- self.class.data[@region][@aws_access_key_id]
56
+ self.class.data[@aws_access_key_id]
53
57
  end
54
58
 
55
59
  def reset_data
56
- self.class.data[@region].delete(@aws_access_key_id)
60
+ self.class.data.delete(@aws_access_key_id)
57
61
  end
58
62
 
59
63
  def signature(params)
@@ -63,6 +67,62 @@ module Fog
63
67
  def setup_credentials(options={})
64
68
  @aws_access_key_id = options[:aws_access_key_id]
65
69
  end
70
+
71
+ def self.distribution_id
72
+ random_id(14)
73
+ end
74
+
75
+ def self.generic_id
76
+ random_id(14)
77
+ end
78
+
79
+ def self.domain_name
80
+ "#{random_id(12).downcase}.cloudfront.net"
81
+ end
82
+
83
+ def self.random_id(length)
84
+ Fog::Mock.random_selection("abcdefghijklmnopqrstuvwxyz0123456789", length).upcase
85
+ end
86
+
87
+ CDN_ERRORS = {
88
+ :access_denies => {:code => 'AccessDenied',:msg => 'Access denied.',:status => 403},
89
+ :inappropriate_xml => {:code => 'InappropriateXML',:msg => 'The XML document you provided was well-formed and valid, but not appropriate for this operation.',:status => 400},
90
+ :internal_error => {:code => 'InternalError',:msg => 'We encountered an internal error. Please try again.',:status => 500},
91
+ :invalid_action => {:code => 'InvalidAction',:msg => 'The action specified is not valid.',:status => 400},
92
+ :invalid_argument => {:code => 'InvalidArgument',:msg => '%s', :status => 400},
93
+ :not_implemented => {:code => 'NotImplemented', :msg => 'Not implemented.',:status => 501},
94
+ :no_such_distribution => { :code => 'NoSuchDistribution', :msg => 'The specified distribution does not exist', :status => 404 },
95
+ :no_such_streaming_distribution => { :code => 'NoSuchStreamingDistribution', :msg => 'The specified streaming distribution does not exist', :status => 404 },
96
+ :no_such_invalidation => { :code => 'NoSuchInvalidation', :msg => 'The specified invalidation does not exist', :status => 404 },
97
+ :cname_exists => { :code => 'CNAMEAlreadyExists', :msg => 'One or more of the CNAMEs you provided are already associated with a different distribution', :status => 409 },
98
+ :illegal_update => { :code => 'IllegalUpdate', :msg => 'Origin and CallerReference cannot be updated.', :status => 400 },
99
+ :invalid_if_match_version => { :code => 'InvalidIfMatchVersion', :msg => 'The If-Match version is missing or not valid for the distribution.', :status => 400},
100
+ :distribution_not_disabled => { :code => 'DistributionNotDisabled', :msg => 'The distribution you are trying to delete has not been disabled.', :status => 409 },
101
+
102
+ }
103
+
104
+ def self.error(code, argument = '')
105
+ if error = CDN_ERRORS[code]
106
+ raise_error(error[:status], error[:code], error[:msg] % argument)
107
+ end
108
+ end
109
+
110
+ def self.raise_error(status, code, message='')
111
+ response = Excon::Response.new
112
+ response.status = status
113
+ response.body = <<EOF
114
+ <ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
115
+ <Error>
116
+ <Type>Sender</Type>
117
+ <Code>#{code}</Code>
118
+ <Message>#{message}.</Message>
119
+ </Error>
120
+ <RequestId>#{Fog::AWS::Mock.request_id}</RequestId>
121
+ </ErrorResponse>
122
+ EOF
123
+
124
+ raise(Excon::Errors.status_error({:expects => 201}, response))
125
+ end
66
126
  end
67
127
 
68
128
  class Real
@@ -6,7 +6,7 @@ module Fog
6
6
  extend Fog::AWS::CredentialFetcher::ServiceMethods
7
7
 
8
8
  requires :aws_access_key_id, :aws_secret_access_key
9
- recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at
9
+ recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
10
10
 
11
11
  request_path 'fog/aws/requests/cloud_watch'
12
12
 
@@ -94,6 +94,10 @@ module Fog
94
94
  setup_credentials(options)
95
95
 
96
96
  @connection_options = options[:connection_options] || {}
97
+
98
+ @instrumentor = options[:instrumentor]
99
+ @instrumentor_name = options[:instrumentor_name] || 'fog.aws.cloud_watch'
100
+
97
101
  options[:region] ||= 'us-east-1'
98
102
  @host = options[:host] || "monitoring.#{options[:region]}.amazonaws.com"
99
103
  @path = options[:path] || '/'
@@ -136,6 +140,16 @@ module Fog
136
140
  }
137
141
  )
138
142
 
143
+ if @instrumentor
144
+ @instrumentor.instrument("#{@instrumentor_name}.request", params) do
145
+ _request(body, idempotent, parser)
146
+ end
147
+ else
148
+ _request(body, idempotent, parser)
149
+ end
150
+ end
151
+
152
+ def _request(body, idempotent, parser)
139
153
  @connection.request({
140
154
  :body => body,
141
155
  :expects => 200,
@@ -212,6 +212,8 @@ module Fog
212
212
  @data = nil
213
213
  end
214
214
 
215
+ attr_accessor :region
216
+
215
217
  def initialize(options={})
216
218
  @use_iam_profile = options[:use_iam_profile]
217
219
  @aws_credentials_expire_at = Time::now + 20
@@ -20,11 +20,12 @@ module Fog
20
20
  attribute :min_size, :aliases => 'MinSize'
21
21
  attribute :placement_group, :aliases => 'PlacementGroup'
22
22
  attribute :suspended_processes, :aliases => 'SuspendedProcesses'
23
- attribute :vpc_zone_identifier, :aliases => 'VPCZoneIdentifier'
24
23
  attribute :tags, :aliases => 'Tags'
24
+ attribute :termination_policies, :aliases => 'TerminationPolicies'
25
+ attribute :vpc_zone_identifier, :aliases => 'VPCZoneIdentifier'
25
26
 
26
27
  def initialize(attributes={})
27
- attributes['DefaultCooldown'] ||= 0
28
+ attributes['DefaultCooldown'] ||= 300
28
29
  attributes['DesiredCapacity'] ||= 0
29
30
  attributes['EnabledMetrics'] ||= []
30
31
  attributes['HealthCheckGracePeriod'] ||= 0
@@ -35,6 +36,7 @@ module Fog
35
36
  attributes['MinSize'] ||= 0
36
37
  attributes['SuspendedProcesses'] ||= []
37
38
  attributes['Tags'] ||= []
39
+ attributes['TerminationPolicies'] ||= ['Default']
38
40
  super
39
41
  end
40
42
 
@@ -119,9 +121,13 @@ module Fog
119
121
  # self
120
122
  #end
121
123
 
122
- def destroy
124
+ def destroy(options = { :force => false })
123
125
  requires :id
124
- connection.delete_auto_scaling_group(id)
126
+
127
+ opts = {}
128
+ opts.merge({'ForceDelete' => true}) if options[:force]
129
+
130
+ connection.delete_auto_scaling_group(id, opts)
125
131
  end
126
132
 
127
133
  def update
@@ -0,0 +1,93 @@
1
+ require 'fog/core/model'
2
+ require 'fog/aws/models/cdn/invalidations'
3
+ require 'fog/aws/models/cdn/distribution_helper'
4
+
5
+ module Fog
6
+ module CDN
7
+ class AWS
8
+
9
+ class Distribution < Fog::Model
10
+ include Fog::CDN::AWS::DistributionHelper
11
+
12
+ identity :id, :aliases => 'Id'
13
+
14
+ attribute :caller_reference, :aliases => 'CallerReference'
15
+ attribute :last_modified_time, :aliases => 'LastModifiedTime'
16
+ attribute :status, :aliases => 'Status'
17
+ attribute :s3_origin, :aliases => 'S3Origin'
18
+ attribute :custom_origin, :aliases => 'CustomOrigin'
19
+ attribute :cname, :aliases => 'CNAME'
20
+ attribute :comment, :aliases => 'Comment'
21
+ attribute :enabled, :aliases => 'Enabled'
22
+ attribute :in_progress_invalidation_batches, :aliases => 'InProgressInvalidationBatches'
23
+ attribute :logging, :aliases => 'Logging'
24
+ attribute :trusted_signers, :aliases => 'TrustedSigners'
25
+ attribute :default_root_object,:aliases => 'DefaultRootObject'
26
+ attribute :domain, :aliases => 'DomainName'
27
+ attribute :etag, :aliases => ['Etag', 'ETag']
28
+
29
+ # items part of DistributionConfig
30
+ CONFIG = [ :caller_reference, :origin, :cname, :comment, :enabled, :logging, :trusted_signers, :default_root_object ]
31
+
32
+ def initialize(new_attributes = {})
33
+ super(distribution_config_to_attributes(new_attributes))
34
+ end
35
+
36
+ def invalidations
37
+ @invalidations ||= begin
38
+ Fog::CDN::AWS::Invalidations.new(
39
+ :distribution => self,
40
+ :connection => connection
41
+ )
42
+ end
43
+ end
44
+
45
+ def save
46
+ requires_one :s3_origin, :custom_origin
47
+ options = attributes_to_options
48
+ response = identity ? put_distribution_config(identity, etag, options) : post_distribution(options)
49
+ etag = response.headers['ETag']
50
+ merge_attributes(response.body)
51
+ true
52
+ end
53
+
54
+ private
55
+
56
+ def delete_distribution(identity, etag)
57
+ connection.delete_distribution(identity, etag)
58
+ end
59
+
60
+ def put_distribution_config(identity, etag, options)
61
+ connection.put_distribution_config(identity, etag, options)
62
+ end
63
+
64
+ def post_distribution(options = {})
65
+ connection.post_distribution(options)
66
+ end
67
+
68
+ def attributes_to_options
69
+ options = {
70
+ 'CallerReference' => caller_reference,
71
+ 'S3Origin' => s3_origin,
72
+ 'CustomOrigin' => custom_origin,
73
+ 'CNAME' => cname,
74
+ 'Comment' => comment,
75
+ 'Enabled' => enabled,
76
+ 'Logging' => logging,
77
+ 'TrustedSigners' => trusted_signers,
78
+ 'DefaultRootObject' => default_root_object
79
+ }
80
+ options.reject! { |k,v| v.nil? }
81
+ options.reject! { |k,v| v.respond_to?(:empty?) && v.empty? }
82
+ options
83
+ end
84
+
85
+ def distribution_config_to_attributes(new_attributes = {})
86
+ new_attributes.merge(new_attributes.delete('DistributionConfig') || {})
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,64 @@
1
+ require 'fog/core/collection'
2
+
3
+ module Fog
4
+ module CDN
5
+ class AWS
6
+
7
+ module DistributionHelper
8
+
9
+ def destroy
10
+ requires :identity, :etag, :caller_reference
11
+ raise "Distribution must be disabled to be deleted" unless disabled?
12
+ delete_distribution(identity, etag)
13
+ true
14
+ end
15
+
16
+ def enabled?
17
+ requires :identity
18
+ !!enabled and ready?
19
+ end
20
+
21
+ def disabled?
22
+ requires :identity
23
+ not enabled? and ready?
24
+ end
25
+
26
+ def custom_origin?
27
+ requires :identity
28
+ not custom_origin.nil?
29
+ end
30
+
31
+ def ready?
32
+ requires :identity
33
+ status == 'Deployed'
34
+ end
35
+
36
+ def enable
37
+ requires :identity
38
+ reload if etag.nil? or caller_reference.nil?
39
+ unless enabled?
40
+ self.enabled = true
41
+ response = put_distribution_config(identity, etag, attributes_to_options)
42
+ etag = response.headers['ETag']
43
+ merge_attributes(response.body)
44
+ end
45
+ true
46
+ end
47
+
48
+ def disable
49
+ requires :identity
50
+ reload if etag.nil? or caller_reference.nil?
51
+ if enabled?
52
+ self.enabled = false
53
+ response = put_distribution_config(identity, etag, attributes_to_options)
54
+ etag = response.headers['ETag']
55
+ merge_attributes(response.body)
56
+ end
57
+ true
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,32 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/aws/models/cdn/distribution'
3
+ require 'fog/aws/models/cdn/distributions_helper'
4
+
5
+ module Fog
6
+ module CDN
7
+ class AWS
8
+
9
+ class Distributions < Fog::Collection
10
+ include Fog::CDN::AWS::DistributionsHelper
11
+
12
+ model Fog::CDN::AWS::Distribution
13
+
14
+ attribute :marker, :aliases => 'Marker'
15
+ attribute :max_items, :aliases => 'MaxItems'
16
+ attribute :is_truncated, :aliases => 'IsTruncated'
17
+
18
+ def get_distribution(dist_id)
19
+ connection.get_distribution(dist_id)
20
+ end
21
+
22
+ def list_distributions(options = {})
23
+ connection.get_distribution_list(options)
24
+ end
25
+
26
+ alias :each_distribution_this_page :each
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ require 'fog/core/collection'
2
+
3
+ module Fog
4
+ module CDN
5
+ class AWS
6
+
7
+ module DistributionsHelper
8
+ def all(options = {})
9
+ merge_attributes(options)
10
+ data = list_distributions(options).body
11
+ merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'], 'MaxItems' => data['MaxItems'])
12
+ if summary = data['DistributionSummary']
13
+ load(summary.map { |a| { 'DistributionConfig' => a } })
14
+ else
15
+ load((data['StreamingDistributionSummary'] || {}).map { |a| { 'StreamingDistributionConfig' => a }})
16
+ end
17
+ end
18
+
19
+ def get(dist_id)
20
+ response = get_distribution(dist_id)
21
+ data = response.body.merge({'ETag' => response.headers['ETag']})
22
+ new(data)
23
+ rescue Excon::Errors::NotFound
24
+ nil
25
+ end
26
+
27
+ def each
28
+ if !block_given?
29
+ self
30
+ else
31
+ subset = dup.all
32
+
33
+ subset.each_distribution_this_page {|f| yield f}
34
+ while subset.is_truncated
35
+ subset = subset.all('Marker' => subset.marker, 'MaxItems' => 1000)
36
+ subset.each_distribution_this_page {|f| yield f}
37
+ end
38
+
39
+ self
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,64 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module CDN
5
+ class AWS
6
+
7
+ class Invalidation < Fog::Model
8
+
9
+ identity :id, :aliases => 'Id'
10
+
11
+ attribute :status, :aliases => 'Status'
12
+ attribute :create_time, :aliases => 'CreateTime'
13
+ attribute :caller_reference, :aliases => 'CallerReference'
14
+ attribute :paths, :aliases => 'Paths'
15
+
16
+ def initialize(new_attributes={})
17
+ new_attributes[:caller_reference] ||= Time.now.utc.to_i.to_s
18
+ super(invalidation_to_attributes(new_attributes))
19
+ end
20
+
21
+ def distribution
22
+ @distribution
23
+ end
24
+
25
+ def ready?
26
+ requires :id, :status
27
+ status == 'Completed'
28
+ end
29
+
30
+ def save
31
+ requires :paths, :caller_reference
32
+ raise "Submitted invalidation cannot be submitted again" if identity
33
+ response = connection.post_invalidation(distribution.identity, paths, caller_reference)
34
+ merge_attributes(invalidation_to_attributes(response.body))
35
+ true
36
+ end
37
+
38
+ def destroy
39
+ # invalidations can't be removed, but tests are requiring they do :)
40
+ true
41
+ end
42
+
43
+ private
44
+
45
+ def distribution=(dist)
46
+ @distribution = dist
47
+ end
48
+
49
+ def invalidation_to_attributes(new_attributes={})
50
+ invalidation_batch = new_attributes.delete('InvalidationBatch') || {}
51
+ if invalidation_batch['Path']
52
+ new_attributes[:paths] = invalidation_batch['Path']
53
+ end
54
+ if invalidation_batch['CallerReference']
55
+ new_attributes[:caller_reference] = invalidation_batch['CallerReference']
56
+ end
57
+ new_attributes
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+ end