droplet_kit 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/droplet_kit.gemspec +2 -2
  4. data/lib/droplet_kit.rb +20 -3
  5. data/lib/droplet_kit/client.rb +2 -0
  6. data/lib/droplet_kit/error_handling_resourcable.rb +19 -0
  7. data/lib/droplet_kit/mappings/domain_record_mapping.rb +6 -6
  8. data/lib/droplet_kit/mappings/floating_ip_mapping.rb +19 -0
  9. data/lib/droplet_kit/models/floating_ip.rb +10 -0
  10. data/lib/droplet_kit/paginated_resource.rb +1 -1
  11. data/lib/droplet_kit/resources/account_resource.rb +2 -0
  12. data/lib/droplet_kit/resources/action_resource.rb +2 -0
  13. data/lib/droplet_kit/resources/domain_record_resource.rb +2 -0
  14. data/lib/droplet_kit/resources/domain_resource.rb +2 -0
  15. data/lib/droplet_kit/resources/droplet_action_resource.rb +4 -0
  16. data/lib/droplet_kit/resources/droplet_resource.rb +3 -1
  17. data/lib/droplet_kit/resources/droplet_upgrade_resource.rb +2 -0
  18. data/lib/droplet_kit/resources/floating_ip_action_resource.rb +30 -0
  19. data/lib/droplet_kit/resources/floating_ip_resource.rb +29 -0
  20. data/lib/droplet_kit/resources/image_action_resource.rb +4 -0
  21. data/lib/droplet_kit/resources/image_resource.rb +2 -0
  22. data/lib/droplet_kit/resources/region_resource.rb +2 -0
  23. data/lib/droplet_kit/resources/size_resource.rb +2 -0
  24. data/lib/droplet_kit/resources/ssh_key_resource.rb +2 -0
  25. data/lib/droplet_kit/version.rb +1 -1
  26. data/spec/fixtures/droplet_actions/change_kernel.json +27 -0
  27. data/spec/fixtures/droplet_actions/disable_backups.json +27 -0
  28. data/spec/fixtures/droplet_actions/enable_ipv6.json +27 -0
  29. data/spec/fixtures/droplet_actions/enable_private_networking.json +27 -0
  30. data/spec/fixtures/droplet_actions/find.json +19 -0
  31. data/spec/fixtures/droplet_actions/password_reset.json +27 -0
  32. data/spec/fixtures/droplet_actions/power_cycle.json +27 -0
  33. data/spec/fixtures/droplet_actions/power_off.json +27 -0
  34. data/spec/fixtures/droplet_actions/power_on.json +27 -0
  35. data/spec/fixtures/droplet_actions/reboot.json +27 -0
  36. data/spec/fixtures/droplet_actions/rebuild.json +27 -0
  37. data/spec/fixtures/droplet_actions/rename.json +27 -0
  38. data/spec/fixtures/droplet_actions/resize.json +27 -0
  39. data/spec/fixtures/droplet_actions/restore.json +27 -0
  40. data/spec/fixtures/droplet_actions/shutdown.json +27 -0
  41. data/spec/fixtures/droplet_actions/snapshot.json +27 -0
  42. data/spec/fixtures/droplet_actions/upgrade.json +27 -0
  43. data/spec/fixtures/floating_ip_actions/all.json +41 -0
  44. data/spec/fixtures/floating_ip_actions/assign.json +27 -0
  45. data/spec/fixtures/floating_ip_actions/find.json +19 -0
  46. data/spec/fixtures/floating_ip_actions/unassign.json +27 -0
  47. data/spec/fixtures/floating_ips/all.json +186 -0
  48. data/spec/fixtures/floating_ips/all_empty.json +7 -0
  49. data/spec/fixtures/floating_ips/create.json +29 -0
  50. data/spec/fixtures/floating_ips/create_with_droplet.json +44 -0
  51. data/spec/fixtures/floating_ips/find.json +28 -0
  52. data/spec/fixtures/image_actions/convert.json +27 -0
  53. data/spec/fixtures/image_actions/transfer.json +27 -0
  54. data/spec/fixtures/images/private.json +31 -0
  55. data/spec/fixtures/images/type.json +31 -0
  56. data/spec/lib/droplet_kit/resources/account_resource_spec.rb +5 -0
  57. data/spec/lib/droplet_kit/resources/action_resource_spec.rb +7 -0
  58. data/spec/lib/droplet_kit/resources/domain_record_resource_spec.rb +13 -6
  59. data/spec/lib/droplet_kit/resources/domain_resource_spec.rb +10 -3
  60. data/spec/lib/droplet_kit/resources/droplet_action_resource_spec.rb +28 -34
  61. data/spec/lib/droplet_kit/resources/droplet_resource_spec.rb +36 -17
  62. data/spec/lib/droplet_kit/resources/droplet_upgrade_resource_spec.rb +6 -0
  63. data/spec/lib/droplet_kit/resources/floating_ip_action_resource_spec.rb +137 -0
  64. data/spec/lib/droplet_kit/resources/floating_ip_resource_spec.rb +91 -0
  65. data/spec/lib/droplet_kit/resources/image_action_resource_spec.rb +31 -28
  66. data/spec/lib/droplet_kit/resources/image_resource_spec.rb +11 -4
  67. data/spec/lib/droplet_kit/resources/region_resource_spec.rb +6 -0
  68. data/spec/lib/droplet_kit/resources/size_resource_spec.rb +6 -0
  69. data/spec/lib/droplet_kit/resources/ssh_key_resource_spec.rb +7 -0
  70. data/spec/support/request_stub_helpers.rb +1 -1
  71. data/spec/support/shared_examples/common_errors.rb +27 -0
  72. data/spec/support/shared_examples/paginated_endpoint.rb +2 -1
  73. data/spec/support/shared_examples/unsuccessful_create.rb +8 -0
  74. metadata +109 -38
  75. data/spec/support/null_hash_load.rb +0 -5
@@ -0,0 +1,19 @@
1
+ {
2
+ "action": {
3
+ "id": 19,
4
+ "status": "completed",
5
+ "type": "assign_ip",
6
+ "started_at": "2014-10-28T17:11:05Z",
7
+ "completed_at": "2014-10-28T17:11:06Z",
8
+ "resource_id": 45646587,
9
+ "resource_type": "floating_ip",
10
+ "region_slug": "nyc1",
11
+ "region": {
12
+ "name": "New York",
13
+ "slug": "nyc1",
14
+ "available": true,
15
+ "sizes": ["512mb"],
16
+ "features": ["virtio", "private_networking", "backups", "ipv6", "metadata"]
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "action": {
3
+ "id": 2,
4
+ "status": "in-progress",
5
+ "type": "unassign",
6
+ "started_at": "2014-08-05T15:15:28Z",
7
+ "completed_at": null,
8
+ "resource_id": 12,
9
+ "resource_type": "floating_ip",
10
+ "region_slug": "nyc1",
11
+ "region": {
12
+ "name": "New York",
13
+ "slug": "nyc1",
14
+ "available": true,
15
+ "sizes": [
16
+ "512mb"
17
+ ],
18
+ "features": [
19
+ "virtio",
20
+ "private_networking",
21
+ "backups",
22
+ "ipv6",
23
+ "metadata"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,186 @@
1
+ {
2
+ "floating_ips": [
3
+ {
4
+ "ip": "45.55.96.32",
5
+ "region": {
6
+ "available": true,
7
+ "features": [
8
+ "private_networking",
9
+ "backups",
10
+ "ipv6",
11
+ "metadata"
12
+ ],
13
+ "sizes": [
14
+ "512mb",
15
+ "1gb",
16
+ "2gb",
17
+ "4gb",
18
+ "8gb",
19
+ "16gb",
20
+ "32gb",
21
+ "48gb",
22
+ "64gb"
23
+ ],
24
+ "slug": "nyc3",
25
+ "name": "New York 3"
26
+ },
27
+ "droplet": {
28
+ "region": {
29
+ "available": true,
30
+ "features": [
31
+ "private_networking",
32
+ "backups",
33
+ "ipv6",
34
+ "metadata"
35
+ ],
36
+ "sizes": [
37
+ "512mb",
38
+ "1gb",
39
+ "2gb",
40
+ "4gb",
41
+ "8gb",
42
+ "16gb",
43
+ "32gb",
44
+ "48gb",
45
+ "64gb"
46
+ ],
47
+ "slug": "nyc3",
48
+ "name": "New York 3"
49
+ },
50
+ "networks": {
51
+ "v6": [],
52
+ "v4": [
53
+ {
54
+ "type": "public",
55
+ "gateway": "104.131.0.1",
56
+ "netmask": "255.255.192.0",
57
+ "ip_address": "104.131.39.129"
58
+ }
59
+ ]
60
+ },
61
+ "kernel": {
62
+ "version": "3.13.0-57-generic",
63
+ "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-57-generic",
64
+ "id": 5175
65
+ },
66
+ "status": "active",
67
+ "locked": false,
68
+ "disk": 20,
69
+ "vcpus": 1,
70
+ "memory": 512,
71
+ "name": "nyc3",
72
+ "id": 7173070,
73
+ "created_at": "2015-09-08T20:29:48Z",
74
+ "features": [
75
+ "virtio"
76
+ ],
77
+ "backup_ids": [],
78
+ "next_backup_window": null,
79
+ "snapshot_ids": [],
80
+ "image": {
81
+ "type": "snapshot",
82
+ "id": 13089493,
83
+ "name": "14.04 x64",
84
+ "distribution": "Ubuntu",
85
+ "slug": "ubuntu-14-04-x64",
86
+ "public": true,
87
+ "regions": [
88
+ "nyc1",
89
+ "ams1",
90
+ "sfo1",
91
+ "nyc2",
92
+ "ams2",
93
+ "sgp1",
94
+ "lon1",
95
+ "nyc3",
96
+ "ams3",
97
+ "fra1",
98
+ "tor1"
99
+ ],
100
+ "created_at": "2015-08-10T21:30:19Z",
101
+ "min_disk_size": 20
102
+ },
103
+ "size": {
104
+ "available": true,
105
+ "slug": "512mb",
106
+ "memory": 512,
107
+ "vcpus": 1,
108
+ "disk": 20,
109
+ "transfer": 1,
110
+ "price_monthly": 5,
111
+ "price_hourly": 0.00744,
112
+ "regions": [
113
+ "nyc1",
114
+ "sgp1",
115
+ "ams1",
116
+ "sfo1",
117
+ "nyc2",
118
+ "lon1",
119
+ "nyc3",
120
+ "ams3",
121
+ "ams2",
122
+ "fra1",
123
+ "tor1"
124
+ ]
125
+ },
126
+ "size_slug": "512mb"
127
+ }
128
+ },
129
+ {
130
+ "ip": "188.166.132.3",
131
+ "region": {
132
+ "available": true,
133
+ "features": [
134
+ "private_networking",
135
+ "backups",
136
+ "ipv6",
137
+ "metadata"
138
+ ],
139
+ "sizes": [
140
+ "512mb",
141
+ "1gb",
142
+ "2gb",
143
+ "4gb",
144
+ "8gb",
145
+ "16gb",
146
+ "32gb",
147
+ "48gb",
148
+ "64gb"
149
+ ],
150
+ "slug": "ams3",
151
+ "name": "Amsterdam 3"
152
+ },
153
+ "droplet": null
154
+ },
155
+ {
156
+ "ip": "45.55.96.3",
157
+ "region": {
158
+ "available": true,
159
+ "features": [
160
+ "private_networking",
161
+ "backups",
162
+ "ipv6",
163
+ "metadata"
164
+ ],
165
+ "sizes": [
166
+ "512mb",
167
+ "1gb",
168
+ "2gb",
169
+ "4gb",
170
+ "8gb",
171
+ "16gb",
172
+ "32gb",
173
+ "48gb",
174
+ "64gb"
175
+ ],
176
+ "slug": "nyc3",
177
+ "name": "New York 3"
178
+ },
179
+ "droplet": null
180
+ }
181
+ ],
182
+ "meta": {
183
+ "total": 3
184
+ },
185
+ "links": {}
186
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "floating_ips": [
3
+ ],
4
+ "meta": {
5
+ "total": 0
6
+ }
7
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "floating_ip": {
3
+ "ip": "45.55.96.32",
4
+ "region": {
5
+ "available": true,
6
+ "features": [
7
+ "private_networking",
8
+ "backups",
9
+ "ipv6",
10
+ "metadata"
11
+ ],
12
+ "sizes": [
13
+ "512mb",
14
+ "1gb",
15
+ "2gb",
16
+ "4gb",
17
+ "8gb",
18
+ "16gb",
19
+ "32gb",
20
+ "48gb",
21
+ "64gb"
22
+ ],
23
+ "slug": "nyc3",
24
+ "name": "New York 3"
25
+ },
26
+ "droplet": null,
27
+ "links": {}
28
+ }
29
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "floating_ip": {
3
+ "ip": "45.55.96.32",
4
+ "region": {
5
+ "available": true,
6
+ "features": [
7
+ "private_networking",
8
+ "backups",
9
+ "ipv6",
10
+ "metadata"
11
+ ],
12
+ "sizes": [
13
+ "512mb",
14
+ "1gb",
15
+ "2gb",
16
+ "4gb",
17
+ "8gb",
18
+ "16gb",
19
+ "32gb",
20
+ "48gb",
21
+ "64gb"
22
+ ],
23
+ "slug": "nyc3",
24
+ "name": "New York 3"
25
+ },
26
+ "droplet": null,
27
+ "links": {
28
+ "actions": [
29
+ {
30
+ "href": "https://api.digitalocean.com/v2/actions/66582085",
31
+ "rel": "assign_ip",
32
+ "id": 66582085
33
+ }
34
+ ],
35
+ "droplets": [
36
+ {
37
+ "href": "https://api.digitalocean.com/v2/droplets/7173070",
38
+ "rel": "droplet",
39
+ "id": 7173070
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "floating_ip": {
3
+ "ip": "45.55.96.32",
4
+ "region": {
5
+ "available": true,
6
+ "features": [
7
+ "private_networking",
8
+ "backups",
9
+ "ipv6",
10
+ "metadata"
11
+ ],
12
+ "sizes": [
13
+ "512mb",
14
+ "1gb",
15
+ "2gb",
16
+ "4gb",
17
+ "8gb",
18
+ "16gb",
19
+ "32gb",
20
+ "48gb",
21
+ "64gb"
22
+ ],
23
+ "slug": "nyc3",
24
+ "name": "New York 3"
25
+ },
26
+ "droplet": null
27
+ }
28
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "action": {
3
+ "id": 23,
4
+ "status": "in-progress",
5
+ "type": "convert",
6
+ "started_at": "2014-08-05T15:15:28Z",
7
+ "completed_at": null,
8
+ "resource_id": 449676391,
9
+ "resource_type": "image",
10
+ "region_slug": "nyc1",
11
+ "region": {
12
+ "name": "New York",
13
+ "slug": "nyc1",
14
+ "available": true,
15
+ "sizes": [
16
+ "512mb"
17
+ ],
18
+ "features": [
19
+ "virtio",
20
+ "private_networking",
21
+ "backups",
22
+ "ipv6",
23
+ "metadata"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "action": {
3
+ "id": 23,
4
+ "status": "in-progress",
5
+ "type": "transfer",
6
+ "started_at": "2014-08-05T15:15:28Z",
7
+ "completed_at": null,
8
+ "resource_id": 449676391,
9
+ "resource_type": "image",
10
+ "region_slug": "nyc1",
11
+ "region": {
12
+ "name": "New York",
13
+ "slug": "nyc1",
14
+ "available": true,
15
+ "sizes": [
16
+ "512mb"
17
+ ],
18
+ "features": [
19
+ "virtio",
20
+ "private_networking",
21
+ "backups",
22
+ "ipv6",
23
+ "metadata"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "id": 119192817,
5
+ "name": "Ubuntu 13.04",
6
+ "distribution": "ubuntu",
7
+ "slug": "ubuntu1304",
8
+ "public": true,
9
+ "regions": [
10
+ "nyc1"
11
+ ],
12
+ "created_at": "2014-07-29T14:35:40Z",
13
+ "type": "snapshot"
14
+ },
15
+ {
16
+ "id": 449676376,
17
+ "name": "Ubuntu 13.04",
18
+ "distribution": "ubuntu",
19
+ "slug": "ubuntu1404",
20
+ "public": true,
21
+ "regions": [
22
+ "nyc1"
23
+ ],
24
+ "created_at": "2014-07-29T14:35:40Z",
25
+ "type": "snapshot"
26
+ }
27
+ ],
28
+ "meta": {
29
+ "total": 2
30
+ }
31
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "id": 119192817,
5
+ "name": "Ubuntu 13.04",
6
+ "distribution": "ubuntu",
7
+ "slug": "ubuntu1304",
8
+ "public": true,
9
+ "regions": [
10
+ "nyc1"
11
+ ],
12
+ "created_at": "2014-07-29T14:35:40Z",
13
+ "type": "snapshot"
14
+ },
15
+ {
16
+ "id": 449676376,
17
+ "name": "Ubuntu 13.04",
18
+ "distribution": "ubuntu",
19
+ "slug": "ubuntu1404",
20
+ "public": true,
21
+ "regions": [
22
+ "nyc1"
23
+ ],
24
+ "created_at": "2014-07-29T14:35:40Z",
25
+ "type": "snapshot"
26
+ }
27
+ ],
28
+ "meta": {
29
+ "total": 2
30
+ }
31
+ }