triglav-client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +17 -0
- data/lib/triglav/client.rb +8 -8
- data/lib/triglav/client/version.rb +1 -1
- data/lib/triglav/model.rb +18 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 746b47cfa73e02ecd2629f764ec004c1007ecec0
|
4
|
+
data.tar.gz: b867c996155aad60c393a9fc332ca71c8ef884ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78881ae200488d80b4f8aa9219b912a78ead4b2398000a38851e2717b56a4538217d695ed842d68b4bec525979f90ce2e68c2b4bf8aab9b33272937dec2920c5
|
7
|
+
data.tar.gz: f34fb2df0bb7969f08624e4be061c7f64df75b16ca9961caabae2521b8a9fa0ea5be45889033d27c387e24054e751d4b2df0b341c53d602dd2fd4f565b75b445
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changes for triglav-client-ruby
|
2
2
|
|
3
|
+
## 0.0.7
|
4
|
+
|
5
|
+
* Bugfix: Fix client and model along with API changes
|
6
|
+
|
7
|
+
## 0.0.6
|
8
|
+
|
9
|
+
* Bugfix: Fix client and model along with API changes
|
10
|
+
|
11
|
+
## 0.0.5
|
12
|
+
|
13
|
+
* (no diff)
|
14
|
+
|
15
|
+
## 0.0.4
|
16
|
+
|
17
|
+
* Feature: Put support
|
18
|
+
* Bugfix: NameError: uninitialized constant Triglav::Client::Model
|
19
|
+
|
3
20
|
## 0.0.3
|
4
21
|
|
5
22
|
* Updadated API endpoints along with Triglav's changes.
|
data/lib/triglav/client.rb
CHANGED
@@ -54,9 +54,9 @@ module Triglav
|
|
54
54
|
|
55
55
|
def create (model, params)
|
56
56
|
case model
|
57
|
-
when :service; Model::Service.create(self, params)
|
58
|
-
when :role; Model::Role.create(self, params)
|
59
|
-
when :host; Model::Host.create(self, params)
|
57
|
+
when :service; Triglav::Model::Service.create(self, params)
|
58
|
+
when :role; Triglav::Model::Role.create(self, params)
|
59
|
+
when :host; Triglav::Model::Host.create(self, params)
|
60
60
|
else raise ArgumentError.new("No such model for #{model}")
|
61
61
|
end
|
62
62
|
end
|
@@ -65,7 +65,7 @@ module Triglav
|
|
65
65
|
endpoint = endpoint_for(:services)
|
66
66
|
response = dispatch_request(endpoint[:method], endpoint[:path])
|
67
67
|
response.map do |info|
|
68
|
-
Model::Service.new(client: self, info: info)
|
68
|
+
Triglav::Model::Service.new(client: self, info: info)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -73,7 +73,7 @@ module Triglav
|
|
73
73
|
endpoint = endpoint_for(:roles)
|
74
74
|
response = dispatch_request(endpoint[:method], endpoint[:path])
|
75
75
|
response.map do |info|
|
76
|
-
Model::Role.new(client: self, info: info)
|
76
|
+
Triglav::Model::Role.new(client: self, info: info)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -81,7 +81,7 @@ module Triglav
|
|
81
81
|
endpoint = endpoint_for(:roles_in, service)
|
82
82
|
response = dispatch_request(endpoint[:method], endpoint[:path])
|
83
83
|
response.map do |info|
|
84
|
-
Model::Role.new(client: self, info: info)
|
84
|
+
Triglav::Model::Role.new(client: self, info: info)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -89,7 +89,7 @@ module Triglav
|
|
89
89
|
endpoint = endpoint_for(:hosts)
|
90
90
|
response = dispatch_request(endpoint[:method], endpoint[:path])
|
91
91
|
response.map do |info|
|
92
|
-
Model::Host.new(client: self, info: info)
|
92
|
+
Triglav::Model::Host.new(client: self, info: info)
|
93
93
|
end.select do |h|
|
94
94
|
if options[:with_inactive]
|
95
95
|
true
|
@@ -115,7 +115,7 @@ module Triglav
|
|
115
115
|
end
|
116
116
|
|
117
117
|
response.map do |info|
|
118
|
-
Model::Host.new(client: self, info: info)
|
118
|
+
Triglav::Model::Host.new(client: self, info: info)
|
119
119
|
end.select do |h|
|
120
120
|
if options[:with_inactive]
|
121
121
|
true
|
data/lib/triglav/model.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ostruct'
|
|
4
4
|
module Triglav
|
5
5
|
module Model
|
6
6
|
class Base
|
7
|
-
|
7
|
+
attr_accessor :client, :info
|
8
8
|
|
9
9
|
def initialize(args)
|
10
10
|
@client = args[:client]
|
@@ -16,7 +16,7 @@ module Triglav
|
|
16
16
|
show: { method: :get, path: '/api/%s/%s' },
|
17
17
|
update: { method: :put, path: '/api/%s/%s' },
|
18
18
|
destroy: { method: :delete, path: '/api/%s/%s' },
|
19
|
-
revert: { method: :
|
19
|
+
revert: { method: :put, path: '/api/%s/%s/revert' },
|
20
20
|
}
|
21
21
|
|
22
22
|
def self.endpoint_for (type, *args)
|
@@ -49,9 +49,11 @@ module Triglav
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def show
|
52
|
-
endpoint
|
53
|
-
result
|
54
|
-
|
52
|
+
endpoint = self.class.endpoint_for(:show, info.name)
|
53
|
+
result = client.dispatch_request(endpoint[:method], endpoint[:path])
|
54
|
+
|
55
|
+
self.info = OpenStruct.new(result)
|
56
|
+
self
|
55
57
|
end
|
56
58
|
|
57
59
|
def update(params = {})
|
@@ -61,19 +63,25 @@ module Triglav
|
|
61
63
|
endpoint[:path],
|
62
64
|
self.class.build_params(params),
|
63
65
|
)
|
64
|
-
|
66
|
+
|
67
|
+
self.info = OpenStruct.new(result)
|
68
|
+
self
|
65
69
|
end
|
66
70
|
|
67
71
|
def destroy
|
68
72
|
endpoint = self.class.endpoint_for(:destroy, info.name)
|
69
73
|
result = client.dispatch_request(endpoint[:method], endpoint[:path])
|
70
|
-
|
74
|
+
|
75
|
+
self.info = OpenStruct.new(result)
|
76
|
+
self
|
71
77
|
end
|
72
78
|
|
73
79
|
def revert
|
74
|
-
endpoint
|
75
|
-
result
|
76
|
-
|
80
|
+
endpoint = self.class.endpoint_for(:revert, info.name)
|
81
|
+
result = client.dispatch_request(endpoint[:method], endpoint[:path])
|
82
|
+
|
83
|
+
self.info = OpenStruct.new(result)
|
84
|
+
self
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triglav-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Kuribayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|