digitalocean 0.0.3 → 1.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +2 -2
- data/README.md +75 -47
- data/lib/digitalocean.rb +138 -16
- data/lib/digitalocean/version.rb +1 -1
- data/spec/digitalocean/domain_spec.rb +34 -50
- data/spec/digitalocean/droplet_spec.rb +125 -36
- data/spec/digitalocean/image_spec.rb +49 -23
- data/spec/digitalocean/integration_spec.rb +12 -0
- data/spec/digitalocean/record_spec.rb +63 -74
- data/spec/digitalocean/region_spec.rb +5 -14
- data/spec/digitalocean/size_spec.rb +5 -14
- data/spec/digitalocean/ssh_key_spec.rb +29 -13
- data/spec/digitalocean_spec.rb +4 -3
- data/spec/spec_helper.rb +0 -10
- metadata +40 -31
- checksums.yaml +0 -7
- data/.env-example +0 -2
- data/lib/digitalocean/domain.rb +0 -34
- data/lib/digitalocean/droplet.rb +0 -67
- data/lib/digitalocean/image.rb +0 -23
- data/lib/digitalocean/record.rb +0 -62
- data/lib/digitalocean/region.rb +0 -14
- data/lib/digitalocean/size.rb +0 -14
- data/lib/digitalocean/ssh_key.rb +0 -21
data/lib/digitalocean/image.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Digitalocean
|
2
|
-
class Image
|
3
|
-
#
|
4
|
-
# Api calls
|
5
|
-
#
|
6
|
-
def self.all(attrs={})
|
7
|
-
response = Digitalocean.request.get "images", attrs
|
8
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
|
-
end
|
10
|
-
def self.find(id)
|
11
|
-
response = Digitalocean.request.get "images/#{id}"
|
12
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true).image
|
13
|
-
end
|
14
|
-
def self.destroy(id)
|
15
|
-
response = Digitalocean.request.get "images/#{id}/destroy"
|
16
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true).image
|
17
|
-
end
|
18
|
-
def self.transfer(id, region_id)
|
19
|
-
response = Digitalocean.request.get "images/#{id}/transfer", { region_id: region_id }
|
20
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true).image
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/digitalocean/record.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module Digitalocean
|
2
|
-
class Record
|
3
|
-
#
|
4
|
-
# Api calls
|
5
|
-
#
|
6
|
-
def self.all(domain_id)
|
7
|
-
response = Digitalocean.request.get "domains/#{domain_id}/records"
|
8
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.find(domain_id, record_id)
|
12
|
-
response = Digitalocean.request.get "domains/#{domain_id}/records/#{record_id}"
|
13
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
14
|
-
end
|
15
|
-
|
16
|
-
# attrs = {
|
17
|
-
# :domain_id => domain_id || domain_name,
|
18
|
-
# :record_type => 'A' || 'CNAME' || 'NS' || 'TXT' || 'MX' || 'SRV',
|
19
|
-
# :data => '@' || '123.123.123.123' || ...,
|
20
|
-
# :name => optional, required for A, CNAME, TXT, and SRV records,
|
21
|
-
# :priority => optional, required for SRV and MX,
|
22
|
-
# :port => optional, required for SRV,
|
23
|
-
# :weight => optional, required for SRV
|
24
|
-
# }
|
25
|
-
def self.create(domain_id, record_type, data, name = nil, priority = nil, port = nil, weight = nil)
|
26
|
-
attrs = {
|
27
|
-
domain_id: domain_id,
|
28
|
-
record_type: record_type,
|
29
|
-
data: data,
|
30
|
-
name: name,
|
31
|
-
priority: priority,
|
32
|
-
port: port,
|
33
|
-
weight: weight,
|
34
|
-
}
|
35
|
-
response = Digitalocean.request.get "domains/#{domain_id}/records/new", attrs
|
36
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
37
|
-
end
|
38
|
-
|
39
|
-
# attrs = {
|
40
|
-
# :domain_id => domain_id || domain_name,
|
41
|
-
# :record_type => 'A' || 'CNAME' || 'NS' || 'TXT' || 'MX' || 'SRV',
|
42
|
-
# :data => '@' || '123.123.123.123' || ...,
|
43
|
-
# :name => optional, required for A, CNAME, TXT, and SRV records,
|
44
|
-
# :priority => optional, required for SRV and MX,
|
45
|
-
# :port => optional, required for SRV,
|
46
|
-
# :weight => optional, required for SRV
|
47
|
-
# }
|
48
|
-
def self.edit(domain_id, record_id, attrs)
|
49
|
-
attrs.merge({
|
50
|
-
domain_id: domain_id,
|
51
|
-
record_id: record_id
|
52
|
-
})
|
53
|
-
response = Digitalocean.request.get "domains/#{domain_id}/records/#{record_id}/edit", attrs
|
54
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.destroy(domain_id, record_id)
|
58
|
-
response = Digitalocean.request.get "domains/#{domain_id}/records/#{record_id}/destroy"
|
59
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/digitalocean/region.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Digitalocean
|
2
|
-
class Region
|
3
|
-
#
|
4
|
-
# Api calls
|
5
|
-
#
|
6
|
-
def self.all
|
7
|
-
response = Digitalocean.request.get "regions"
|
8
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
|
-
end
|
10
|
-
def self.find(id)
|
11
|
-
self.all.regions.detect{|region| region.id == id}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/digitalocean/size.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Digitalocean
|
2
|
-
class Size
|
3
|
-
#
|
4
|
-
# Api calls
|
5
|
-
#
|
6
|
-
def self.all
|
7
|
-
response = Digitalocean.request.get "sizes"
|
8
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
|
-
end
|
10
|
-
def self.find(id)
|
11
|
-
self.all.sizes.detect{|size| size.id == id}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/digitalocean/ssh_key.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Digitalocean
|
2
|
-
class SshKey
|
3
|
-
#
|
4
|
-
# Api calls
|
5
|
-
#
|
6
|
-
def self.all
|
7
|
-
response = Digitalocean.request.get "ssh_keys"
|
8
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.retrieve(ssh_key_id=nil)
|
12
|
-
response = Digitalocean.request.get "ssh_keys/#{ssh_key_id}"
|
13
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.create(attrs)
|
17
|
-
response = Digitalocean.request.get "ssh_keys/new", attrs
|
18
|
-
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|