maas-client 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/lib/maas/client.rb +14 -3
- data/lib/maas/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0af0884af520930a87251571b10143d7a7cfcccda21ef13427027bab7a3cb3
|
4
|
+
data.tar.gz: c1eca77a6dc752adbe75474cf70647140b0562f5471ca01067295f6dc44d43ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d56e06f44c57e59e40b20c63b559911be99e881af6d23eee500bed37bc0b7aaca32ac26defe6e3f6048fb78104dab96b689bf2a9fe4c8f7f6f93d58ec4e1d0
|
7
|
+
data.tar.gz: 98848a20e98a5934473e8a46003a8f55686cf2e39d9ba76b05bba56f669d0bb8dc603f82fe819e2c9b1336c921bf453906fb474bdcfe36925847317faa20febf
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@ This is a simple client library for MAAS, Metal as a Service, written in Ruby.
|
|
6
6
|
|
7
7
|
```ruby
|
8
8
|
|
9
|
+
# https://github.com/typhoeus/typhoeus/issues/390
|
10
|
+
# since 0.3.0
|
11
|
+
$ sudo apt install libcurl4-openssl-dev
|
12
|
+
|
9
13
|
$ bundle
|
10
14
|
|
11
15
|
# Or install it yourself as:
|
@@ -27,6 +31,8 @@ con = Maas::Client::MaasClient.new()
|
|
27
31
|
con = Maas::Client::MaasClient.new("#{CONSUMER_KEY}:#{KEY}:#{SECRET}",
|
28
32
|
"http://#{IP_OR_DOMAIN_NAME}/MAAS/api/2.0")
|
29
33
|
|
34
|
+
# use cases
|
35
|
+
con.request(:get, ['maas'], {'op' => 'get_config', 'name' => 'main_archive'})
|
30
36
|
|
31
37
|
con.request(:get, ['users'])
|
32
38
|
|
@@ -50,7 +56,7 @@ con.request(:get, ['ipaddresses'])
|
|
50
56
|
myarr = []
|
51
57
|
dns_records = con.request(:get, ['dnsresources'])
|
52
58
|
dns_records.each_with_index { |item, index| myarr << item['fqdn'] }
|
53
|
-
myarr
|
59
|
+
pp myarr
|
54
60
|
|
55
61
|
```
|
56
62
|
```bash
|
@@ -180,12 +186,16 @@ Pushed maas-client x.x.xx to rubygems.org.
|
|
180
186
|
** Execute release
|
181
187
|
|
182
188
|
```
|
189
|
+
|
183
190
|
## Reference
|
184
191
|
https://docs.maas.io/2.4/en/api-authentication
|
185
192
|
https://github.com/oauth-xx/oauth-ruby
|
186
193
|
https://github.com/typhoeus/typhoeus
|
187
194
|
https://docs.maas.io/2.4/en/api
|
188
195
|
|
196
|
+
## rubygems
|
197
|
+
https://rubygems.org/gems/maas-client
|
198
|
+
|
189
199
|
## License
|
190
200
|
|
191
201
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/maas/client.rb
CHANGED
@@ -100,15 +100,26 @@ module Maas
|
|
100
100
|
hydra.queue(req); hydra.run
|
101
101
|
response = req.response
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
if response.code == 200
|
104
|
+
if valid_json?(response.body)
|
105
|
+
return JSON.parse(response.body)
|
106
|
+
else
|
107
|
+
return response.body
|
108
|
+
end
|
109
|
+
elsif response.code == 204
|
106
110
|
puts 'No Content'
|
107
111
|
else
|
108
112
|
raise "#{response.class} #{response.code} \
|
109
113
|
#{response.status_message} #{response.body}"
|
110
114
|
end
|
111
115
|
end
|
116
|
+
|
117
|
+
def valid_json?(json)
|
118
|
+
JSON.parse(json)
|
119
|
+
return true
|
120
|
+
rescue JSON::ParserError => e
|
121
|
+
return false
|
122
|
+
end
|
112
123
|
end
|
113
124
|
end
|
114
125
|
end
|
data/lib/maas/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maas-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Draper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|