Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/test/tmp/
/test/version_tmp/
/tmp/
/spec/vcr/

# Used by dotenv library to load environment variables.
# .env
Expand Down
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
source 'https://rubygems.org'

gem 'faraday'
gem 'json'
gem 'json'

group :development do
gem 'rspec'
gem 'vcr'
end
34 changes: 34 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
json (1.8.3)
multipart-post (2.0.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
vcr (3.0.3)

PLATFORMS
ruby

DEPENDENCIES
faraday
json
rspec
vcr

BUNDLED WITH
1.11.2
2 changes: 2 additions & 0 deletions jager.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ Gem::Specification.new do |spec|

spec.add_dependency 'faraday'
spec.add_dependency 'json'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'vcr'
end
18 changes: 11 additions & 7 deletions lib/jager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Jager

# API_ENDPOINT = "https://api.cloud.net" its used for live data

API_ENDPOINT = "https://api.staging.cloud.net/" #now testing with staging data.
API_ENDPOINT = "https://api.staging.cloud.net" #now testing with staging data.

class CloudNet

Expand Down Expand Up @@ -54,7 +54,7 @@ def create_server template_id, options = {}
req.params["disk_size"] = options[:disk_size]
req.params["cpus"] = options[:cpus]
end
return JSON.parse(resp.body)
return {body: resp.body,status: resp.status}
end

def edit_server server_id, options = {}
Expand All @@ -67,13 +67,14 @@ def edit_server server_id, options = {}
req.params["cpus"] = options[:cpus]
req.params["id"] = server_id
end
return JSON.parse(resp.body)
return {body: resp.body,status: resp.status}
end

def destroy_server id
resp = @connection.delete("#{API_ENDPOINT}/servers/#{id}") do |req|
req.headers["Authorization"] = "Basic #{@authentication_string}"
end
return {body: resp.body,status: resp.status}
end

#server power options
Expand Down Expand Up @@ -108,22 +109,25 @@ def collection_request type
req.headers["Authorization"] = "Basic #{@authentication_string}"
end

return JSON.parse(full_data.body)

return { body: full_data.body, status: full_data.status,
total: full_data.headers["x-total"], page: full_data.headers["x-page"],
per_page: full_data.headers["x-per-page"],
total_pages: full_data.headers["x-total-pages"]
}
end

def member_request id, type
resp = @connection.get("#{API_ENDPOINT}/#{type}/#{id}") do |req|
req.headers["Authorization"] = "Basic #{@authentication_string}"
end
return JSON.parse(resp.body)
return {body: resp.body,status: resp.status}
end

def power_options server_id, option
resp = @connection.put("#{API_ENDPOINT}/servers/#{server_id}/#{option}") do |req|
req.headers["Authorization"] = "Basic #{@authentication_string}"
end
return JSON.parse(resp.body)
return {body: resp.body,status: resp.status}
end
end
end
Loading