gaptool-api 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/gaptool-api.rb +43 -33
- 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: 622a85457a9746a3ab0e32f0e69510d1607e9f2e
|
4
|
+
data.tar.gz: ffecfba6406a5d46da77cf9109fa7a684ccd5414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4427618b2bf0c74166a3e814ee61df962d05053d9fc4f195ab0f835336db7c0687f73f4751a418c79d77468d3f71404aa3c553ce60f29483b5675235b6a4d4c
|
7
|
+
data.tar.gz: 6bb664360df70e2ec44b3ee6a0de1ceae731d3cb161f08b32fad74f6bca2ff7286c2233a01e2e7afa5ee518d1653651f334ea2f1df089130b619b4afb5b5b8dc
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.6
|
data/lib/gaptool-api.rb
CHANGED
@@ -17,25 +17,47 @@ module GTAPI
|
|
17
17
|
GaptoolServer.base_uri uri
|
18
18
|
end
|
19
19
|
|
20
|
+
def call(verb, url, opts={})
|
21
|
+
options = opts || {}
|
22
|
+
options[:headers] ||= {}
|
23
|
+
options[:headers].merge!(@auth)
|
24
|
+
options[:headers]['Accept'] = 'application/json'
|
25
|
+
options[:headers]['Content-Type'] = 'application/json'
|
26
|
+
case verb
|
27
|
+
when :post
|
28
|
+
options[:body] ||= ''
|
29
|
+
end
|
30
|
+
JSON.parse(self.class.send(verb, url, options).body)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(url, opts={})
|
34
|
+
call(:get, url, opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
def post(url, opts={})
|
38
|
+
call(:post, url, opts)
|
39
|
+
end
|
40
|
+
|
41
|
+
def patch(url, opts={})
|
42
|
+
call(:patch, url, opts)
|
43
|
+
end
|
44
|
+
|
20
45
|
def rehash()
|
21
|
-
|
22
|
-
JSON::parse self.class.post("/rehash", options)
|
46
|
+
post("/rehash")
|
23
47
|
end
|
24
48
|
|
25
49
|
def getonenode(id)
|
26
|
-
|
27
|
-
JSON::parse self.class.get("/instance/#{id}", options)
|
50
|
+
get("/instance/#{id}")
|
28
51
|
end
|
29
52
|
|
30
53
|
def getenvroles(role, environment, params={})
|
31
|
-
|
32
|
-
JSON::parse self.class.get("/hosts/#{role}/#{environment}", options)
|
54
|
+
get("/hosts/#{role}/#{environment}", {query: params})
|
33
55
|
end
|
34
56
|
|
35
57
|
def addnode(zone, itype, role, environment, mirror=nil, security_group=nil,
|
36
58
|
ami=nil, chef_repo=nil, chef_branch=nil, chef_runlist=nil,
|
37
59
|
no_terminate=nil)
|
38
|
-
|
60
|
+
body = {
|
39
61
|
'zone' => zone || @default_aws_az,
|
40
62
|
'itype' => itype,
|
41
63
|
'role' => role,
|
@@ -45,60 +67,48 @@ module GTAPI
|
|
45
67
|
'chef_branch' => chef_branch
|
46
68
|
}
|
47
69
|
unless security_group.nil?
|
48
|
-
|
70
|
+
body['security_group'] = security_group
|
49
71
|
end
|
50
72
|
unless chef_runlist.nil? || chef_runlist.empty?
|
51
|
-
|
73
|
+
body['chef_runlist'] = [*chef_runlist]
|
52
74
|
end
|
53
75
|
if no_terminate
|
54
|
-
|
76
|
+
body['terminate'] = false
|
55
77
|
end
|
56
|
-
|
57
|
-
options = { :body => @body, :headers => @auth}
|
58
|
-
JSON::parse self.class.post("/init", options)
|
78
|
+
post('/init', {body: body.to_json})
|
59
79
|
end
|
60
80
|
|
61
81
|
def terminatenode(id, zone)
|
62
|
-
|
63
|
-
options = {:body => @body, :headers => @auth}
|
64
|
-
JSON::parse self.class.post("/terminate", options)
|
82
|
+
post('/terminate', {body: {'id' => id, 'zone' => zone || @default_aws_region}.to_json})
|
65
83
|
end
|
66
84
|
|
67
|
-
def setparameters(instance, params)
|
68
|
-
|
69
|
-
options = {:body => @body, :headers => @auth}
|
70
|
-
JSON::parse self.class.patch("/instance/#{instance}", options)
|
85
|
+
def setparameters(instance, params={})
|
86
|
+
patch("/instance/#{instance}", {body: params.to_json})
|
71
87
|
end
|
72
88
|
|
73
89
|
def getappnodes(app, environment, params={})
|
74
|
-
|
75
|
-
|
76
|
-
JSON::parse self.class.get("/hosts/#{role}/#{environment}", options)
|
90
|
+
role = get("/apps", {query: params})["app:#{app}"]['role']
|
91
|
+
get("/hosts/#{role}/#{environment}", {query: params})
|
77
92
|
end
|
78
93
|
|
79
94
|
def ssh(role, environment, id)
|
80
|
-
|
81
|
-
JSON::parse self.class.get("/ssh/#{role}/#{environment}/#{id}", options)
|
95
|
+
get("/ssh/#{role}/#{environment}/#{id}")
|
82
96
|
end
|
83
97
|
|
84
98
|
def getrolenodes(role, params={})
|
85
|
-
|
86
|
-
JSON::parse self.class.get("/hosts/#{role}", options)
|
99
|
+
get("/hosts/#{role}", {query: params})
|
87
100
|
end
|
88
101
|
|
89
102
|
def getenvnodes(environment, params={})
|
90
|
-
|
91
|
-
JSON::parse self.class.get("/hosts/ALL/#{environment}", options)
|
103
|
+
get("/hosts/ALL/#{environment}", {query: params})
|
92
104
|
end
|
93
105
|
|
94
106
|
def getallnodes(params)
|
95
|
-
|
96
|
-
JSON::parse self.class.get("/hosts", options)
|
107
|
+
get("/hosts", {query: params})
|
97
108
|
end
|
98
109
|
|
99
110
|
def api_version()
|
100
|
-
|
101
|
-
JSON::parse self.class.get("/version", options)
|
111
|
+
get("/version")
|
102
112
|
end
|
103
113
|
end
|
104
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaptool-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Bailey
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.2.2
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: gaptool-server ruby API
|