gaptool-api 0.8.0 → 0.8.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/gaptool-api.rb +39 -35
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccba4a49e83243e31f6125178153925ebb079b9a
4
- data.tar.gz: 3bd070cc71098015e6de81eec1e9b54242a6a706
3
+ metadata.gz: f31ec7f78d859b9db5eb0c076d09638de2211590
4
+ data.tar.gz: 53f4e3638849981d428eca6b5a6d321094de670b
5
5
  SHA512:
6
- metadata.gz: 3d7ddd392693323e7c6650fe4e71c3ca8c5fc4be6641e801d6178223b2f6bb8a9a2c55934fdd524f2cda12522d0a3927170db4f95f3bcc838789ff74379e8ba6
7
- data.tar.gz: 634568d21e8685ff02722c7eb64342079547de36b36933e0642523fa398f1b1703751e828099463c80dfcbf489a38519f0baa2fb4bb2c5daad7bad51d227e148
6
+ metadata.gz: dd61d61b2e487edc8c058530eaec07b380c2cdeac2d7e146460fd5eab0c708a259da7070c3d75cba84fab718f20378a9a4653e87d3158773dc3a5adc48d5678e
7
+ data.tar.gz: b265e89e33b4717eac5c5f8a609b590c7e7b4909d48b721fd34ea91af2563880803dfe5f1df5000dd29ba3d8067c2d1f20277409e45a4ab805b42d855386457b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
data/lib/gaptool-api.rb CHANGED
@@ -8,16 +8,17 @@ module GTAPI
8
8
  DEFAULT_AWS_AZ = 'us-west-2c'
9
9
  attr_reader :version
10
10
 
11
- def initialize(user, apikey, uri, default_aws_az=DEFAULT_AWS_AZ)
12
- @auth = { 'X-GAPTOOL-USER' => user, 'X-GAPTOOL-KEY' => apikey}
13
- default_aws_az = default_aws_az || DEFAULT_AWS_AZ
11
+ def initialize(user, apikey, uri, default_aws_az = DEFAULT_AWS_AZ)
12
+ @auth = { 'X-GAPTOOL-USER' => user, 'X-GAPTOOL-KEY' => apikey }
13
+ default_aws_az ||= DEFAULT_AWS_AZ
14
14
  @default_aws_az = default_aws_az
15
15
  @default_aws_region = default_aws_az[0..-2]
16
- @version = File.read(File.realpath(File.join(File.dirname(__FILE__), "..", 'VERSION'))).strip
16
+ @version = File.read(File.realpath(File.join(File.dirname(__FILE__),
17
+ '..', 'VERSION'))).strip
17
18
  GaptoolServer.base_uri uri
18
19
  end
19
20
 
20
- def call(verb, url, opts={})
21
+ def call(verb, url, opts = {})
21
22
  options = opts || {}
22
23
  options[:headers] ||= {}
23
24
  options[:headers].merge!(@auth)
@@ -31,33 +32,39 @@ module GTAPI
31
32
  JSON.parse(self.class.send(verb, url, options).body)
32
33
  end
33
34
 
34
- def get(url, opts={})
35
+ def get(url, opts = {})
35
36
  call(:get, url, opts)
36
37
  end
37
38
 
38
- def post(url, opts={})
39
+ def post(url, opts = {})
39
40
  call(:post, url, opts)
40
41
  end
41
42
 
42
- def patch(url, opts={})
43
+ def patch(url, opts = {})
43
44
  call(:patch, url, opts)
44
45
  end
45
46
 
46
- def rehash()
47
- post("/rehash")
47
+ def rehash
48
+ post('/rehash')
48
49
  end
49
50
 
50
51
  def getonenode(id)
51
52
  get("/instance/#{id}")
52
53
  end
53
54
 
54
- def getenvroles(role, environment, params={})
55
- get("/hosts/#{role}/#{environment}", {query: params})
55
+ def getnodeattrs(id, attrs = {})
56
+ attrs ||= {}
57
+ get("/instance/#{id}/attrs",
58
+ body: attrs.to_json)
56
59
  end
57
60
 
58
- def addnode(zone, itype, role, environment, mirror=nil, security_group=nil,
59
- ami=nil, chef_repo=nil, chef_branch=nil, chef_runlist=nil,
60
- no_terminate=nil)
61
+ def getenvroles(role, environment, params = {})
62
+ get("/hosts/#{role}/#{environment}", query: params)
63
+ end
64
+
65
+ def addnode(zone, itype, role, environment, _mirror = nil,
66
+ security_group = nil, ami = nil, chef_repo = nil,
67
+ chef_branch = nil, chef_runlist = nil, no_terminate = nil)
61
68
  body = {
62
69
  'zone' => zone || @default_aws_az,
63
70
  'itype' => itype,
@@ -67,44 +74,41 @@ module GTAPI
67
74
  'chef_repo' => chef_repo,
68
75
  'chef_branch' => chef_branch
69
76
  }
70
- unless security_group.nil?
71
- body['security_group'] = security_group
72
- end
77
+ body['security_group'] = security_group unless security_group.nil?
73
78
  unless chef_runlist.nil? || chef_runlist.empty?
74
79
  body['chef_runlist'] = [*chef_runlist]
75
80
  end
76
- if no_terminate
77
- body['terminate'] = false
78
- end
79
- post('/init', {body: body.to_json})
81
+ body['terminate'] = false if no_terminate
82
+ post('/init', body: body.to_json)
80
83
  end
81
84
 
82
85
  def terminatenode(id, zone)
83
- post('/terminate', {body: {'id' => id, 'zone' => zone || @default_aws_region}.to_json})
86
+ body = { 'id' => id, 'zone' => zone || @default_aws_region }
87
+ post('/terminate', body: body.to_json)
84
88
  end
85
89
 
86
- def setparameters(instance, params={})
87
- patch("/instance/#{instance}", {body: params.to_json})
90
+ def setparameters(instance, params = {})
91
+ patch("/instance/#{instance}", body: params.to_json)
88
92
  end
89
93
 
90
- def getappnodes(app, environment, params={})
91
- get("/app/#{app}/#{environment}/hosts", {query: params})
94
+ def getappnodes(app, environment, params = {})
95
+ get("/app/#{app}/#{environment}/hosts", query: params)
92
96
  end
93
97
 
94
- def getrolenodes(role, params={})
95
- get("/hosts/#{role}", {query: params})
98
+ def getrolenodes(role, params = {})
99
+ get("/hosts/#{role}", query: params)
96
100
  end
97
101
 
98
- def getenvnodes(environment, params={})
99
- get("/hosts/ALL/#{environment}", {query: params})
102
+ def getenvnodes(environment, params = {})
103
+ get("/hosts/ALL/#{environment}", query: params)
100
104
  end
101
105
 
102
- def getallnodes(params)
103
- get("/hosts", {query: params})
106
+ def getallnodes(params = {})
107
+ get('/hosts', query: params)
104
108
  end
105
109
 
106
- def api_version()
107
- get("/version")
110
+ def api_version
111
+ get('/version')
108
112
  end
109
113
  end
110
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.8.0
4
+ version: 0.8.1
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-29 00:00:00.000000000 Z
12
+ date: 2016-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty