atlantic_net 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/atlantic_net.gemspec +1 -1
- data/lib/atlantic_net.rb +21 -3
- data/spec/atlantic_net_spec.rb +79 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f11c5b0a4d7a3fa1b38dfebec04ff9426433a5a
|
4
|
+
data.tar.gz: d4458c00fd3b5ab52f232090be26444e72c925eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235396cac8f1bb392921918f60848927fe6c8a738cd27a58776bf0cecb2ffdc41b696f0a67ddd7d350e163bd34cdbe2dda1fef5c1f2863ccd1fae9fd676949b7
|
7
|
+
data.tar.gz: 76af83ddec3aac53a6415c3bd92fffc760372d4edd5d92cd7263092baa1593f6adeac88dcc71b85a243fb93fec92c5f5c71e60061948b4fa7a0c6406f4f1bc27
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/jrstarke/atlantic_net.png?branch=master)](https://travis-ci.org/jrstarke/atlantic_net)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/jrstarke/atlantic_net/badge.png)](https://coveralls.io/r/jrstarke/atlantic_net)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/atlantic_net.svg)](https://badge.fury.io/rb/atlantic_net)
|
6
|
+
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/jrstarke/atlantic_net/master/LICENSE)
|
5
7
|
|
6
8
|
A lightweight ruby interface for interacting with the Atlantic.net API.
|
7
9
|
|
data/atlantic_net.gemspec
CHANGED
data/lib/atlantic_net.rb
CHANGED
@@ -79,7 +79,12 @@ class AtlanticNet
|
|
79
79
|
#
|
80
80
|
def list_instances
|
81
81
|
response = api_call('list-instances')
|
82
|
-
response['list-instancesresponse']['instancesSet']
|
82
|
+
instances = response['list-instancesresponse']['instancesSet']
|
83
|
+
if instances
|
84
|
+
instances.values
|
85
|
+
else
|
86
|
+
[]
|
87
|
+
end
|
83
88
|
end
|
84
89
|
|
85
90
|
# Restart a specific cloud server.
|
@@ -170,6 +175,9 @@ class AtlanticNet
|
|
170
175
|
#
|
171
176
|
# @return [Array<Hash>] A array of image descriptions
|
172
177
|
#
|
178
|
+
# @raise [AtlanticNetException] if the image_id specified in the options does not
|
179
|
+
# match an image id on Atlantic.net
|
180
|
+
#
|
173
181
|
def describe_images(options={})
|
174
182
|
args = {}
|
175
183
|
|
@@ -198,7 +206,12 @@ class AtlanticNet
|
|
198
206
|
response = api_call('describe-plan',options)
|
199
207
|
end
|
200
208
|
|
201
|
-
response["describe-planresponse"]["plans"]
|
209
|
+
plans = response["describe-planresponse"]["plans"]
|
210
|
+
if plans.respond_to?(:values)
|
211
|
+
plans.values
|
212
|
+
else
|
213
|
+
[]
|
214
|
+
end
|
202
215
|
end
|
203
216
|
|
204
217
|
# Retrieve the details of all SSH Keys associated with the account
|
@@ -207,7 +220,12 @@ class AtlanticNet
|
|
207
220
|
#
|
208
221
|
def list_ssh_keys
|
209
222
|
response = api_call('list-sshkeys')
|
210
|
-
response["list-sshkeysresponse"]["KeysSet"]
|
223
|
+
keys_set = response["list-sshkeysresponse"]["KeysSet"]
|
224
|
+
if keys_set
|
225
|
+
keys_set.values
|
226
|
+
else
|
227
|
+
[]
|
228
|
+
end
|
211
229
|
end
|
212
230
|
|
213
231
|
|
data/spec/atlantic_net_spec.rb
CHANGED
@@ -112,15 +112,31 @@ describe AtlanticNet do
|
|
112
112
|
]
|
113
113
|
}
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
115
|
+
context "instances have been set up" do
|
116
|
+
it 'calls api_call with list-instances and returns a list of instance hashes' do
|
117
|
+
allow(subject).to receive(:api_call).with("list-instances").and_return(sample_api_response)
|
118
|
+
instances = subject.list_instances
|
119
|
+
expect(instances).to eq expected_instances
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "no instances exist yet" do
|
124
|
+
let(:sample_api_response) {
|
125
|
+
{
|
126
|
+
"list-instancesresponse" => {
|
127
|
+
"requestid" => "310db3f4-4250-4b2e-8e18-57b967a767ab",
|
128
|
+
"instancesSet" => nil
|
129
|
+
},
|
130
|
+
"Timestamp"=>1464539924
|
131
|
+
}
|
132
|
+
}
|
133
|
+
let(:expected_instances) { [] }
|
134
|
+
|
135
|
+
it 'calls api_call with list-instances and returns an empty array' do
|
136
|
+
allow(subject).to receive(:api_call).with("list-instances").and_return(sample_api_response)
|
137
|
+
instances = subject.list_instances
|
138
|
+
expect(instances).to eq expected_instances
|
139
|
+
end
|
124
140
|
end
|
125
141
|
end
|
126
142
|
|
@@ -495,6 +511,31 @@ describe AtlanticNet do
|
|
495
511
|
expect(result).to eq plan_descriptions
|
496
512
|
end
|
497
513
|
end
|
514
|
+
|
515
|
+
context 'No plans exist for options' do
|
516
|
+
let(:plan_name) { "GO" }
|
517
|
+
let(:platform) { "linux" }
|
518
|
+
|
519
|
+
let(:sample_api_response) {
|
520
|
+
{
|
521
|
+
"Timestamp" => 1439932362,
|
522
|
+
"describe-planresponse" => {
|
523
|
+
"plans" => [],
|
524
|
+
"requestid" => "4aae48ae-af7b-4bbd-9309-58aadbfd02d3"
|
525
|
+
}
|
526
|
+
}
|
527
|
+
}
|
528
|
+
let(:plan_descriptions) {
|
529
|
+
[]
|
530
|
+
}
|
531
|
+
it 'calls api_call with describe-plan plan_name and platform and returns an empty array' do
|
532
|
+
expect(subject).to receive(:api_call)
|
533
|
+
.with("describe-plan", {plan_name: plan_name, platform: platform})
|
534
|
+
.and_return(sample_api_response)
|
535
|
+
result = subject.describe_plans({plan_name: plan_name, platform: platform})
|
536
|
+
expect(result).to eq plan_descriptions
|
537
|
+
end
|
538
|
+
end
|
498
539
|
end
|
499
540
|
|
500
541
|
describe "#list_ssh_keys" do
|
@@ -523,12 +564,35 @@ describe AtlanticNet do
|
|
523
564
|
]
|
524
565
|
}
|
525
566
|
|
526
|
-
|
527
|
-
|
528
|
-
.
|
529
|
-
|
530
|
-
|
531
|
-
|
567
|
+
context 'SSH Keys on atlantic.net have been set' do
|
568
|
+
it 'calls api_call with list-sshkeys and returns a list of ssh key hashes' do
|
569
|
+
expect(subject).to receive(:api_call)
|
570
|
+
.with("list-sshkeys")
|
571
|
+
.and_return(sample_api_response)
|
572
|
+
result = subject.list_ssh_keys
|
573
|
+
expect(result).to eq ssh_keys
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
context 'No SSH Keys setup' do
|
578
|
+
let(:sample_api_response) {
|
579
|
+
{
|
580
|
+
"list-sshkeysresponse" => {
|
581
|
+
"requestid" => "ba77409d-e74a-4d86-a6b1-847ac2adb6dd",
|
582
|
+
"KeysSet" => nil
|
583
|
+
},
|
584
|
+
"Timestamp"=>1464539384
|
585
|
+
}
|
586
|
+
}
|
587
|
+
let(:ssh_keys) { [] }
|
588
|
+
|
589
|
+
it 'calls api_call with list-sshkeys and returns a nil KeysSet' do
|
590
|
+
expect(subject).to receive(:api_call)
|
591
|
+
.with("list-sshkeys")
|
592
|
+
.and_return(sample_api_response)
|
593
|
+
result = subject.list_ssh_keys
|
594
|
+
expect(result).to eq ssh_keys
|
595
|
+
end
|
532
596
|
end
|
533
597
|
end
|
534
598
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlantic_net
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Starke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.5.1
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: A Ruby wrapper of the Atlantic.net API
|