occi-api 4.2.0.beta.7 → 4.2.0.beta.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/occi/api/client/base/stubs.rb +1 -1
- data/lib/occi/api/client/client_http.rb +8 -3
- data/lib/occi/api/client/http/party_wrappers.rb +50 -28
- data/lib/occi/api/version.rb +1 -1
- metadata +13 -5
- checksums.yaml +0 -15
@@ -121,7 +121,7 @@ module Occi::Api::Client
|
|
121
121
|
#
|
122
122
|
# @param [String] resource type or type identifier
|
123
123
|
# @param [Occi::Core::ActionInstance] type of action
|
124
|
-
# @return [
|
124
|
+
# @return [Boolean] status
|
125
125
|
def trigger(resource_type_identifier, action_instance)
|
126
126
|
raise Occi::Api::Client::Errors::NotImplementedError, "#{__method__} is just a stub!"
|
127
127
|
end
|
@@ -180,15 +180,20 @@ module Occi::Api::Client
|
|
180
180
|
|
181
181
|
# @see Occi::Api::Client::ClientBase
|
182
182
|
def trigger(resource_type_identifier, action_instance)
|
183
|
-
# TODO: not tested
|
184
183
|
raise 'Resource not provided!' if resource_type_identifier.blank?
|
184
|
+
raise 'ActionInstance not provided!' if action_instance.blank?
|
185
185
|
|
186
|
-
#
|
186
|
+
# attempt to resolve shortened identifiers
|
187
187
|
resource_type_identifier = get_resource_type_identifier(resource_type_identifier)
|
188
188
|
path = path_for_kind_type_identifier(resource_type_identifier)
|
189
189
|
|
190
|
+
# prepare data
|
191
|
+
path = "#{path}?action=#{action_instance.action.term}"
|
192
|
+
collection = Occi::Collection.new
|
193
|
+
collection << action_instance
|
194
|
+
|
190
195
|
# make the request
|
191
|
-
post path,
|
196
|
+
post path, collection
|
192
197
|
end
|
193
198
|
|
194
199
|
# @see Occi::Api::Client::ClientBase
|
@@ -17,7 +17,9 @@ module Occi::Api::Client
|
|
17
17
|
# apply filters if present
|
18
18
|
response = if filter
|
19
19
|
categories = filter.categories.collect { |category| category.to_text }.join(',')
|
20
|
-
attributes = filter.entities.collect { |entity|
|
20
|
+
attributes = filter.entities.collect { |entity|
|
21
|
+
entity.attributes.combine.collect { |k, v| k + '=' + v }
|
22
|
+
}.join(',')
|
21
23
|
|
22
24
|
headers = self.class.headers.clone
|
23
25
|
headers['Content-Type'] = 'text/occi'
|
@@ -30,7 +32,7 @@ module Occi::Api::Client
|
|
30
32
|
end
|
31
33
|
|
32
34
|
response_msg = response_message response
|
33
|
-
raise "HTTP GET failed! #{response_msg}" unless response.code
|
35
|
+
raise "HTTP GET failed! #{response_msg}" unless response.code == 200
|
34
36
|
|
35
37
|
Occi::Log.debug "Response location: #{path.inspect}"
|
36
38
|
kind = @model.get_by_location(path) if @model
|
@@ -44,8 +46,12 @@ module Occi::Api::Client
|
|
44
46
|
|
45
47
|
entity_type = Occi::Core::Resource unless entity_type
|
46
48
|
|
47
|
-
Occi::Log.debug "Parser call: #{response.content_type} #{path.include?('/-/')}
|
48
|
-
|
49
|
+
Occi::Log.debug "Parser call: #{response.content_type} #{path.include?('/-/')} " \
|
50
|
+
"#{entity_type} #{response.headers.inspect}"
|
51
|
+
collection = Occi::Parser.parse(
|
52
|
+
response.content_type, response.body,
|
53
|
+
path.include?('/-/'), entity_type, response.headers
|
54
|
+
)
|
49
55
|
|
50
56
|
Occi::Log.debug "Parsed collection: empty? #{collection.empty?}"
|
51
57
|
collection
|
@@ -65,7 +71,7 @@ module Occi::Api::Client
|
|
65
71
|
#
|
66
72
|
# @param [String] path for the POST request
|
67
73
|
# @param [Occi::Collection] resource data to be POSTed
|
68
|
-
# @return [String] URI location
|
74
|
+
# @return [Occi::Collection, String, Boolean] Collection, URI location or action result (if ActionInstance is passed)
|
69
75
|
def post(path, collection)
|
70
76
|
raise ArgumentError, "Path is a required argument!" if path.blank?
|
71
77
|
|
@@ -87,27 +93,9 @@ module Occi::Api::Client
|
|
87
93
|
end
|
88
94
|
|
89
95
|
response_msg = response_message(response)
|
96
|
+
raise "HTTP POST failed! #{response_msg}" unless response.code.between? 200, 201
|
90
97
|
|
91
|
-
|
92
|
-
when 200
|
93
|
-
collection = Occi::Parser.parse(response.header["content-type"].split(";").first, response.body)
|
94
|
-
|
95
|
-
if collection.empty?
|
96
|
-
Occi::Parser.locations(response.header["content-type"].split(";").first, response.body, response.headers).first
|
97
|
-
else
|
98
|
-
collection.resources.first.location if collection.resources.first
|
99
|
-
end
|
100
|
-
when 201
|
101
|
-
# TODO: OCCI-OS hack, look for header Location instead of uri-list
|
102
|
-
# This should be probably implemented in Occi::Parser.locations
|
103
|
-
if response.header['location']
|
104
|
-
response.header['location']
|
105
|
-
else
|
106
|
-
Occi::Parser.locations(response.header["content-type"].split(";").first, response.body, response.headers).first
|
107
|
-
end
|
108
|
-
else
|
109
|
-
raise "HTTP POST failed! #{response_msg}"
|
110
|
-
end
|
98
|
+
collection.send(:standalone_action_instance?) ? post_action(response) : post_create(response)
|
111
99
|
end
|
112
100
|
|
113
101
|
# Performs PUT requests and parses responses to collections.
|
@@ -140,8 +128,7 @@ module Occi::Api::Client
|
|
140
128
|
|
141
129
|
response_msg = response_message(response)
|
142
130
|
|
143
|
-
|
144
|
-
when 200, 201
|
131
|
+
if response.code.between? 200, 201
|
145
132
|
Occi::Parser.parse(response.header["content-type"].split(";").first, response.body)
|
146
133
|
else
|
147
134
|
raise "HTTP POST failed! #{response_msg}"
|
@@ -162,11 +149,46 @@ module Occi::Api::Client
|
|
162
149
|
response = self.class.delete(path)
|
163
150
|
|
164
151
|
response_msg = response_message(response)
|
165
|
-
raise "HTTP DELETE failed! #{response_msg}" unless response.code
|
152
|
+
raise "HTTP DELETE failed! #{response_msg}" unless response.code == 200
|
153
|
+
|
154
|
+
true
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
166
158
|
|
159
|
+
def post_action(response)
|
167
160
|
true
|
168
161
|
end
|
169
162
|
|
163
|
+
def post_create(response)
|
164
|
+
if response.code == 200
|
165
|
+
collection = Occi::Parser.parse(
|
166
|
+
response.header["content-type"].split(";").first,
|
167
|
+
response.body
|
168
|
+
)
|
169
|
+
|
170
|
+
if collection.empty?
|
171
|
+
Occi::Parser.locations(
|
172
|
+
response.header["content-type"].split(";").first,
|
173
|
+
response.body,
|
174
|
+
response.headers
|
175
|
+
).first
|
176
|
+
else
|
177
|
+
raise "HTTP POST response does not " \
|
178
|
+
"contain required resource rendering!" unless collection.resources.first
|
179
|
+
collection.resources.first.location
|
180
|
+
end
|
181
|
+
else
|
182
|
+
Occi::Parser.locations(
|
183
|
+
response.header["content-type"].split(";").first,
|
184
|
+
response.body,
|
185
|
+
response.headers
|
186
|
+
).first
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def post_update(response); end
|
191
|
+
|
170
192
|
end
|
171
193
|
|
172
194
|
end
|
data/lib/occi/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.0.beta.
|
4
|
+
version: 4.2.0.beta.8
|
5
|
+
prerelease: 6
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Florian Feldhaus
|
@@ -10,11 +11,12 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2014-01-
|
14
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: occi-core
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
18
20
|
requirements:
|
19
21
|
- - ~>
|
20
22
|
- !ruby/object:Gem::Version
|
@@ -22,6 +24,7 @@ dependencies:
|
|
22
24
|
type: :runtime
|
23
25
|
prerelease: false
|
24
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
25
28
|
requirements:
|
26
29
|
- - ~>
|
27
30
|
- !ruby/object:Gem::Version
|
@@ -29,6 +32,7 @@ dependencies:
|
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
33
|
name: httparty
|
31
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
32
36
|
requirements:
|
33
37
|
- - ! '>='
|
34
38
|
- !ruby/object:Gem::Version
|
@@ -36,6 +40,7 @@ dependencies:
|
|
36
40
|
type: :runtime
|
37
41
|
prerelease: false
|
38
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
39
44
|
requirements:
|
40
45
|
- - ! '>='
|
41
46
|
- !ruby/object:Gem::Version
|
@@ -43,6 +48,7 @@ dependencies:
|
|
43
48
|
- !ruby/object:Gem::Dependency
|
44
49
|
name: json
|
45
50
|
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
46
52
|
requirements:
|
47
53
|
- - ! '>='
|
48
54
|
- !ruby/object:Gem::Version
|
@@ -50,6 +56,7 @@ dependencies:
|
|
50
56
|
type: :runtime
|
51
57
|
prerelease: false
|
52
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
53
60
|
requirements:
|
54
61
|
- - ! '>='
|
55
62
|
- !ruby/object:Gem::Version
|
@@ -138,25 +145,26 @@ files:
|
|
138
145
|
homepage: https://github.com/gwdg/rOCCI-api
|
139
146
|
licenses:
|
140
147
|
- Apache License, Version 2.0
|
141
|
-
metadata: {}
|
142
148
|
post_install_message:
|
143
149
|
rdoc_options: []
|
144
150
|
require_paths:
|
145
151
|
- lib
|
146
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
147
154
|
requirements:
|
148
155
|
- - ! '>='
|
149
156
|
- !ruby/object:Gem::Version
|
150
157
|
version: 1.9.3
|
151
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
152
160
|
requirements:
|
153
161
|
- - ! '>'
|
154
162
|
- !ruby/object:Gem::Version
|
155
163
|
version: 1.3.1
|
156
164
|
requirements: []
|
157
165
|
rubyforge_project:
|
158
|
-
rubygems_version:
|
166
|
+
rubygems_version: 1.8.25
|
159
167
|
signing_key:
|
160
|
-
specification_version:
|
168
|
+
specification_version: 3
|
161
169
|
summary: OCCI development library providing a high-level API
|
162
170
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ODNiNDZlNGY4NjZiY2VlMGM4Yjc3YTNhMjg1M2I2MDc2MWNlMDYyOA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2JjMWI0NDQxZjYyYTU4MmNkNWZlZDhmZmUzMWVkYjU4MGExZTc2MA==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
M2RjZjE1ZDcyNTc1MTgyNTk0NDdkYzNlZTI4OTM5NzI2ODJlMDMwNTE1OWRi
|
10
|
-
M2Y4Y2VmYmJlNjc2OWQ3NWU5Y2E5MTc3MGNiOTJlM2FiYzY0YTUzMWIzM2I2
|
11
|
-
M2M3NjEwYWVhZGVjM2Q2NjMxY2ViZDA3YzI2MmZhNzA3N2NlNGI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDMyM2YyNzMyYTFlYWMxOGFmMzNkNmIzYjZlZDFjY2VmZDAxNGI1MWFkZmYz
|
14
|
-
ZDg4YjIwMDg1OWE0YmI3YmMzMGY2OTU1OGFiZmMzOGE3YWU4ZmMwY2IyZGU1
|
15
|
-
OTg0MWFiYTE5MzM2ODIzNDVjNWY4Y2VhMjI5NDc1ZjZhYzNhYjc=
|