fog 0.3.31 → 0.3.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.document +3 -0
  2. data/.gitignore +10 -0
  3. data/Gemfile.lock +1 -4
  4. data/README.rdoc +29 -37
  5. data/Rakefile +5 -25
  6. data/bin/fog +1 -3
  7. data/examples/dns_methods.rb +389 -0
  8. data/examples/storage.rb +103 -0
  9. data/fog.gemspec +4 -778
  10. data/lib/fog.rb +5 -66
  11. data/lib/fog/aws.rb +3 -0
  12. data/lib/fog/aws/bin.rb +7 -2
  13. data/lib/fog/aws/cdn.rb +2 -2
  14. data/lib/fog/aws/compute.rb +2 -2
  15. data/lib/fog/aws/dns.rb +101 -0
  16. data/lib/fog/aws/elb.rb +2 -2
  17. data/lib/fog/aws/iam.rb +2 -2
  18. data/lib/fog/aws/models/compute/image.rb +1 -0
  19. data/lib/fog/aws/models/compute/server.rb +1 -1
  20. data/lib/fog/aws/models/compute/servers.rb +1 -13
  21. data/lib/fog/aws/parsers/compute/describe_images.rb +36 -34
  22. data/lib/fog/aws/parsers/dns/change_resource_record_sets.rb +26 -0
  23. data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +55 -0
  24. data/lib/fog/aws/parsers/dns/delete_hosted_zone.rb +25 -0
  25. data/lib/fog/aws/parsers/dns/get_change.rb +26 -0
  26. data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +43 -0
  27. data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +35 -0
  28. data/lib/fog/aws/parsers/dns/list_resource_record_sets.rb +46 -0
  29. data/lib/fog/aws/requests/compute/describe_images.rb +1 -0
  30. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +90 -0
  31. data/lib/fog/aws/requests/dns/create_hosted_zone.rb +68 -0
  32. data/lib/fog/aws/requests/dns/delete_hosted_zone.rb +48 -0
  33. data/lib/fog/aws/requests/dns/get_change.rb +47 -0
  34. data/lib/fog/aws/requests/dns/get_hosted_zone.rb +51 -0
  35. data/lib/fog/aws/requests/dns/list_hosted_zones.rb +63 -0
  36. data/lib/fog/aws/requests/dns/list_resource_record_sets.rb +68 -0
  37. data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  38. data/lib/fog/aws/requests/storage/put_object_url.rb +2 -2
  39. data/lib/fog/aws/requests/storage/sync_clock.rb +28 -0
  40. data/lib/fog/aws/simpledb.rb +2 -2
  41. data/lib/fog/aws/storage.rb +5 -3
  42. data/lib/fog/bluebox.rb +2 -0
  43. data/lib/fog/bluebox/compute.rb +2 -2
  44. data/lib/fog/brightbox.rb +2 -0
  45. data/lib/fog/brightbox/compute.rb +2 -2
  46. data/lib/fog/core.rb +21 -1
  47. data/lib/fog/core/bin.rb +3 -1
  48. data/lib/fog/core/compute.rb +1 -0
  49. data/lib/fog/core/credentials.rb +72 -50
  50. data/lib/fog/core/deprecation.rb +11 -5
  51. data/lib/fog/core/mock.rb +34 -0
  52. data/lib/fog/core/model.rb +9 -1
  53. data/lib/fog/core/service.rb +40 -26
  54. data/lib/fog/core/storage.rb +1 -0
  55. data/lib/fog/core/time.rb +21 -0
  56. data/lib/fog/core/wait_for.rb +17 -0
  57. data/lib/fog/go_grid.rb +2 -0
  58. data/lib/fog/go_grid/compute.rb +2 -2
  59. data/lib/fog/google.rb +2 -0
  60. data/lib/fog/google/requests/storage/get_bucket.rb +6 -5
  61. data/lib/fog/google/requests/storage/get_object_url.rb +4 -4
  62. data/lib/fog/google/requests/storage/put_object_url.rb +4 -4
  63. data/lib/fog/google/storage.rb +4 -3
  64. data/lib/fog/linode.rb +3 -0
  65. data/lib/fog/linode/bin.rb +5 -3
  66. data/lib/fog/linode/compute.rb +6 -2
  67. data/lib/fog/linode/dns.rb +80 -0
  68. data/lib/fog/linode/requests/dns/domain_create.rb +52 -0
  69. data/lib/fog/linode/requests/dns/domain_delete.rb +35 -0
  70. data/lib/fog/linode/requests/dns/domain_list.rb +50 -0
  71. data/lib/fog/linode/requests/dns/domain_resource_create.rb +53 -0
  72. data/lib/fog/linode/requests/dns/domain_resource_delete.rb +36 -0
  73. data/lib/fog/linode/requests/dns/domain_resource_list.rb +48 -0
  74. data/lib/fog/linode/requests/dns/domain_resource_update.rb +54 -0
  75. data/lib/fog/linode/requests/dns/domain_update.rb +48 -0
  76. data/lib/fog/local.rb +2 -0
  77. data/lib/fog/local/storage.rb +3 -3
  78. data/lib/fog/new_servers.rb +2 -0
  79. data/lib/fog/new_servers/compute.rb +2 -2
  80. data/lib/fog/rackspace.rb +2 -0
  81. data/lib/fog/rackspace/cdn.rb +2 -2
  82. data/lib/fog/rackspace/compute.rb +2 -2
  83. data/lib/fog/rackspace/storage.rb +2 -2
  84. data/lib/fog/slicehost.rb +3 -0
  85. data/lib/fog/slicehost/bin.rb +2 -0
  86. data/lib/fog/slicehost/compute.rb +2 -2
  87. data/lib/fog/slicehost/dns.rb +84 -0
  88. data/lib/fog/slicehost/parsers/dns/create_record.rb +26 -0
  89. data/lib/fog/slicehost/parsers/dns/create_zone.rb +26 -0
  90. data/lib/fog/slicehost/parsers/dns/get_record.rb +26 -0
  91. data/lib/fog/slicehost/parsers/dns/get_records.rb +30 -0
  92. data/lib/fog/slicehost/parsers/dns/get_zone.rb +26 -0
  93. data/lib/fog/slicehost/parsers/dns/get_zones.rb +30 -0
  94. data/lib/fog/slicehost/requests/compute/create_slice.rb +2 -2
  95. data/lib/fog/slicehost/requests/compute/delete_slice.rb +3 -17
  96. data/lib/fog/slicehost/requests/dns/create_record.rb +61 -0
  97. data/lib/fog/slicehost/requests/dns/create_zone.rb +54 -0
  98. data/lib/fog/slicehost/requests/dns/delete_record.rb +31 -0
  99. data/lib/fog/slicehost/requests/dns/delete_zone.rb +31 -0
  100. data/lib/fog/slicehost/requests/dns/get_record.rb +40 -0
  101. data/lib/fog/slicehost/requests/dns/get_records.rb +41 -0
  102. data/lib/fog/slicehost/requests/dns/get_zone.rb +40 -0
  103. data/lib/fog/slicehost/requests/dns/get_zones.rb +38 -0
  104. data/lib/fog/terremark.rb +2 -0
  105. data/lib/fog/terremark/ecloud.rb +2 -4
  106. data/lib/fog/vcloud.rb +4 -2
  107. data/lib/fog/vcloud/bin.rb +3 -1
  108. data/lib/fog/vcloud/mock_data_classes.rb +77 -11
  109. data/lib/fog/vcloud/terremark/ecloud.rb +22 -7
  110. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +60 -0
  111. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +36 -0
  112. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +28 -13
  113. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +2 -2
  114. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
  115. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +4 -1
  116. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +5 -5
  117. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +6 -2
  118. data/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +111 -0
  119. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +2 -4
  120. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +1 -3
  121. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +39 -27
  122. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +1 -2
  123. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +21 -6
  124. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +2 -1
  125. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -17
  126. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +12 -10
  127. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -10
  128. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +1 -12
  129. data/lib/fog/zerigo.rb +15 -0
  130. data/lib/fog/zerigo/bin.rb +25 -0
  131. data/lib/fog/zerigo/dns.rb +96 -0
  132. data/lib/fog/zerigo/parsers/dns/count_hosts.rb +24 -0
  133. data/lib/fog/zerigo/parsers/dns/count_zones.rb +24 -0
  134. data/lib/fog/zerigo/parsers/dns/create_host.rb +26 -0
  135. data/lib/fog/zerigo/parsers/dns/create_zone.rb +26 -0
  136. data/lib/fog/zerigo/parsers/dns/find_hosts.rb +30 -0
  137. data/lib/fog/zerigo/parsers/dns/get_host.rb +26 -0
  138. data/lib/fog/zerigo/parsers/dns/get_zone.rb +56 -0
  139. data/lib/fog/zerigo/parsers/dns/get_zone_stats.rb +26 -0
  140. data/lib/fog/zerigo/parsers/dns/list_hosts.rb +30 -0
  141. data/lib/fog/zerigo/parsers/dns/list_zones.rb +30 -0
  142. data/lib/fog/zerigo/requests/dns/count_hosts.rb +36 -0
  143. data/lib/fog/zerigo/requests/dns/count_zones.rb +36 -0
  144. data/lib/fog/zerigo/requests/dns/create_host.rb +70 -0
  145. data/lib/fog/zerigo/requests/dns/create_zone.rb +97 -0
  146. data/lib/fog/zerigo/requests/dns/delete_host.rb +32 -0
  147. data/lib/fog/zerigo/requests/dns/delete_zone.rb +33 -0
  148. data/lib/fog/zerigo/requests/dns/find_hosts.rb +63 -0
  149. data/lib/fog/zerigo/requests/dns/get_host.rb +47 -0
  150. data/lib/fog/zerigo/requests/dns/get_zone.rb +57 -0
  151. data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +44 -0
  152. data/lib/fog/zerigo/requests/dns/list_hosts.rb +48 -0
  153. data/lib/fog/zerigo/requests/dns/list_zones.rb +53 -0
  154. data/lib/fog/zerigo/requests/dns/update_host.rb +60 -0
  155. data/lib/fog/zerigo/requests/dns/update_zone.rb +78 -0
  156. data/spec/spec_helper.rb +0 -5
  157. data/spec/vcloud/spec_helper.rb +3 -2
  158. data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +49 -0
  159. data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +29 -0
  160. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +32 -13
  161. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +7 -4
  162. data/spec/vcloud/terremark/ecloud/models/server_spec.rb +20 -0
  163. data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +60 -0
  164. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +3 -0
  165. data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +55 -0
  166. data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +9 -0
  167. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +60 -14
  168. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -0
  169. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -3
  170. data/tests/aws/requests/compute/image_tests.rb +15 -14
  171. data/tests/aws/requests/dns/dns_tests.rb +276 -0
  172. data/tests/brightbox/requests/compute/account_tests.rb +20 -9
  173. data/tests/brightbox/requests/compute/api_client_tests.rb +12 -4
  174. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +20 -6
  175. data/tests/brightbox/requests/compute/image_tests.rb +9 -4
  176. data/tests/brightbox/requests/compute/interface_tests.rb +8 -2
  177. data/tests/brightbox/requests/compute/server_tests.rb +17 -5
  178. data/tests/brightbox/requests/compute/server_type_tests.rb +8 -4
  179. data/tests/brightbox/requests/compute/user_tests.rb +13 -5
  180. data/tests/brightbox/requests/compute/zone_tests.rb +8 -4
  181. data/tests/core/attribute_tests.rb +45 -0
  182. data/tests/helper.rb +0 -2
  183. data/tests/linode/requests/dns/dns_tests.rb +262 -0
  184. data/tests/rackspace/requests/compute/address_tests.rb +1 -1
  185. data/tests/rackspace/requests/compute/image_tests.rb +1 -1
  186. data/tests/slicehost/requests/dns_tests/dns_tests.rb +279 -0
  187. data/tests/zerigo/helper.rb +0 -0
  188. data/tests/zerigo/requests/dns/dns_tests.rb +374 -0
  189. metadata +280 -36
  190. data/spec/compact_progress_bar_formatter.rb +0 -195
  191. data/spec/core/attributes_spec.rb +0 -52
  192. data/spec/lorem.txt +0 -1
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class CreateZone < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = {}
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
15
+ @response[name] = @value.to_i
16
+ when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
17
+ @response[name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class FindHosts < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @host = {}
10
+ @response = { 'hosts' => [] }
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'id', 'priority', 'ttl', 'zone-id'
16
+ @host[name] = @value.to_i
17
+ when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
18
+ @host[name] = @value
19
+ when 'host'
20
+ @response['hosts'] << @host
21
+ @host = {}
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class GetHost < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = {}
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'id', 'priority', 'ttl', 'zone-id'
15
+ @response[name] = @value.to_i
16
+ when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
17
+ @response[name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,56 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class GetZone < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @host = {}
10
+ @hosts = []
11
+ @response = {}
12
+ @in_hosts = false
13
+ end
14
+
15
+ def start_element(name, attrs = [])
16
+ super(name, attrs)
17
+ #look out for start of <hosts> section
18
+ #needed as some of the tags have the same name as the parent <zone> section
19
+ if name == 'hosts'
20
+ @in_hosts= true
21
+ end
22
+ end
23
+
24
+ def end_element(name)
25
+ if (@in_hosts)
26
+ #in hosts part of response
27
+ case name
28
+ when 'id', 'priority', 'ttl', 'zone-id'
29
+ @host[name] = @value.to_i
30
+ when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
31
+ @host[name] = @value
32
+ when 'host'
33
+ @hosts << @host
34
+ @host = {}
35
+ when 'hosts'
36
+ @response[name] = @hosts
37
+ @in_hosts = false
38
+ end
39
+ else
40
+ #in zone part of data
41
+ case name
42
+ when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
43
+ @response[name] = @value.to_i
44
+ when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
45
+ @response[name] = @value
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class GetZoneStats < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = {}
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'id', 'queries'
15
+ @response[name] = @value.to_i
16
+ when 'domain', 'period-begin', 'period-end'
17
+ @response[name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class ListHosts < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @host = {}
10
+ @response = { 'hosts' => [] }
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'id', 'priority', 'ttl', 'zone-id'
16
+ @host[name] = @value.to_i
17
+ when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
18
+ @host[name] = @value
19
+ when 'host'
20
+ @response['hosts'] << @host
21
+ @host = {}
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module Zerigo
4
+ module DNS
5
+
6
+ class ListZones < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @zone = {}
10
+ @response = { 'zones' => [] }
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
16
+ @zone[name] = @value.to_i
17
+ when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
18
+ @zone[name] = @value
19
+ when 'zone'
20
+ @response['zones'] << @zone
21
+ @zone = {}
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Zerigo
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/zerigo/parsers/dns/count_hosts'
7
+
8
+ # total number of hosts available for the specified zone. It is the same value as provided
9
+ # in the X-Query-Count header in the list_hosts API method
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>
14
+ # * 'count'<~Integer>
15
+ # * 'status'<~Integer> - 200 indicates success
16
+ def count_hosts( zone_id)
17
+ request(
18
+ :expects => 200,
19
+ :method => 'GET',
20
+ :parser => Fog::Parsers::Zerigo::DNS::CountHosts.new,
21
+ :path => "/api/1.1/zones/#{zone_id}/hosts/count.xml"
22
+ )
23
+ end
24
+
25
+ end
26
+
27
+ class Mock
28
+
29
+ def count_hosts( zone_id)
30
+ Fog::Mock.not_implemented
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Zerigo
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/zerigo/parsers/dns/count_zones'
7
+
8
+ # Total number of zones hosted Zerigo for this account. It is the same value as provided
9
+ # in the X-Query-Count header in the list_zones API method
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>
14
+ # * 'count'<~Integer>
15
+ # * 'status'<~Integer> - 200 indicates success
16
+ def count_zones()
17
+ request(
18
+ :expects => 200,
19
+ :method => 'GET',
20
+ :parser => Fog::Parsers::Zerigo::DNS::CountZones.new,
21
+ :path => "/api/1.1/zones/count.xml"
22
+ )
23
+ end
24
+
25
+ end
26
+
27
+ class Mock
28
+
29
+ def count_zones()
30
+ Fog::Mock.not_implemented
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module Zerigo
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/zerigo/parsers/dns/create_host'
7
+
8
+ # Create a new host in the specified zone
9
+ #
10
+ # ==== Parameters
11
+ # * zone_id<~Integer>
12
+ # * host_type<~String>
13
+ # * data<~String>
14
+ # * options<~Hash> - optional paramaters
15
+ # * hostname<~String> - Note: normally this is set/required!!
16
+ # * notes<~String>
17
+ # * priority<~Integer> - Note: required for MX or SRV records
18
+ # * ttl<~Integer>
19
+ # ==== Returns
20
+ # * response<~Excon::Response>:
21
+ # * body<~Hash>
22
+ # * 'created-at'<~String>
23
+ # * 'data'<~String>
24
+ # * 'fqdn'<~String>
25
+ # * 'host-type'<~String>
26
+ # * 'hostname'<~String>
27
+ # * 'id'<~Integer>
28
+ # * 'notes'<~String>
29
+ # * 'priority'<~Integer>
30
+ # * 'ttl'<~Integer>
31
+ # * 'updated-at'<~String>
32
+ # * 'zone-id'<~String>
33
+ # * 'status'<~Integer> - 201 if successful
34
+ def create_host( zone_id, host_type, data, options = {} )
35
+
36
+ optional_tags= ''
37
+ options.each { |option, value|
38
+ case option
39
+ when :hostname
40
+ optional_tags+= "<hostname>#{value}</hostname>"
41
+ when :notes
42
+ optional_tags+= "<notes>#{value}</notes>"
43
+ when :priority
44
+ optional_tags+= "<priority>#{value}</priority>"
45
+ when :ttl
46
+ optional_tags+= "<ttl>#{value}</ttl>"
47
+ end
48
+ }
49
+
50
+ request(
51
+ :body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},
52
+ :expects => 201,
53
+ :method => 'POST',
54
+ :parser => Fog::Parsers::Zerigo::DNS::CreateHost.new,
55
+ :path => "/api/1.1/zones/#{zone_id}/hosts.xml"
56
+ )
57
+ end
58
+
59
+ end
60
+
61
+ class Mock
62
+
63
+ def create_host( zone_id, host_type, data, options = {})
64
+ Fog::Mock.not_implemented
65
+ end
66
+
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,97 @@
1
+ module Fog
2
+ module Zerigo
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/zerigo/parsers/dns/create_zone'
7
+
8
+ # Create a new zone for Zerigo's DNS servers to serve/host
9
+ # ==== Parameters
10
+ #
11
+ # * domain<~String>
12
+ # * default_ttl<~Integer>
13
+ # * ns_type<~String>
14
+ # * options<~Hash> - optional paramaters
15
+ # * ns1<~String> - required if ns_type == sec
16
+ # * nx_ttl<~Integer> -
17
+ # * slave_nameservers<~String> - required if ns_type == pri
18
+ # * axfr_ips<~String> - comma-separated list of IPs or IP blocks allowed to perform AXFRs
19
+ # * custom_nameservers<~String> - comma-separated list of custom nameservers
20
+ # * custom_ns<~String> - indicates if vanity (custom) nameservers are enabled for this domain
21
+ # * hostmaster<~String> - email of the DNS administrator or hostmaster
22
+ # * notes<~String> - notes about the domain
23
+ # * restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
24
+ # * tag_list<~String> - List of all tags associated with this domain
25
+ #
26
+ # ==== Returns
27
+ # * response<~Excon::Response>:
28
+ # * body<~Hash>:
29
+ # * 'id'<~Integer> - zone ID to use for future calls
30
+ # * 'default-ttl'<~Integer>
31
+ # * 'nx-ttl'<~Integer>
32
+ # * 'hosts-count'<~Integer>
33
+ # * 'created-at'<~String>
34
+ # * 'custom-nameservers'<~String>
35
+ # * 'custom-ns'<~String>
36
+ # * 'domain'<~String>
37
+ # * 'hostmaster'<~String>
38
+ # * 'notes'<~String>
39
+ # * 'ns1'<~String>
40
+ # * 'ns-type'<~String>
41
+ # * 'slave-nameservers'<~String>
42
+ # * 'tag-list'<~String>
43
+ # * 'updated-at'<~String>
44
+ # * 'hosts'<~String>
45
+ # * 'axfr-ips'<~String>
46
+ # * 'restrict-axfr'<~String>
47
+ # * 'status'<~Integer> - 201 if successful
48
+
49
+ def create_zone( domain, default_ttl, ns_type, options = {})
50
+
51
+ optional_tags= ''
52
+ options.each { |option, value|
53
+ case option
54
+ when :ns1
55
+ optional_tags+= "<ns1>#{value}</ns1>"
56
+ when :nx_ttl
57
+ optional_tags+= "<nx-ttl type='interger'>#{value}</nx-ttl>"
58
+ when :slave_nameservers
59
+ optional_tags+= "<slave-nameservers>#{value}</slave-nameservers>"
60
+ when :axfr_ips
61
+ optional_tags+= "<axfr-ips>#{value}</axfr-ips>"
62
+ when :custom_nameservers
63
+ optional_tags+= "<custom-nameservers>#{value}</custom-nameservers>"
64
+ when :custom_ns
65
+ optional_tags+= "<custom-ns>#{value}</custom-ns>"
66
+ when :hostmaster
67
+ optional_tags+= "<hostmaster>#{value}</hostmaster>"
68
+ when :notes
69
+ optional_tags+= "<notes>#{value}</notes>"
70
+ when :restrict_axfr
71
+ optional_tags+= "<restrict-axfr>#{value}</restrict-axfr>"
72
+ when :tag_list
73
+ optional_tags+= "<tag-list>#{value}</tag-list>"
74
+ end
75
+ }
76
+
77
+ request(
78
+ :body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><domain>#{domain}</domain><default-ttl type="integer">#{default_ttl}</default-ttl><ns-type>#{ns_type}</ns-type>#{optional_tags}</zone>},
79
+ :expects => 201,
80
+ :method => 'POST',
81
+ :parser => Fog::Parsers::Zerigo::DNS::CreateZone.new,
82
+ :path => '/api/1.1/zones.xml'
83
+ )
84
+ end
85
+
86
+ end
87
+
88
+ class Mock
89
+
90
+ def create_zone(domain, default_ttl, ns_type, options = {})
91
+ Fog::Mock.not_implemented
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+ end