visor-image 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/visor +59 -87
- data/config/server.rb +1 -0
- data/lib/image/auth.rb +108 -77
- data/lib/image/cli.rb +30 -30
- data/lib/image/client.rb +224 -125
- data/lib/image/meta.rb +57 -69
- data/lib/image/routes/delete_all_images.rb +2 -0
- data/lib/image/routes/delete_image.rb +2 -0
- data/lib/image/routes/get_image.rb +2 -0
- data/lib/image/routes/get_images.rb +3 -0
- data/lib/image/routes/get_images_detail.rb +3 -0
- data/lib/image/routes/head_image.rb +2 -0
- data/lib/image/routes/post_image.rb +4 -2
- data/lib/image/routes/put_image.rb +3 -1
- data/lib/image/server.rb +87 -65
- data/lib/image/store/cumulus.rb +2 -2
- data/lib/image/store/hdfs.rb +1 -1
- data/lib/image/store/http.rb +1 -1
- data/lib/image/store/lunacloud.rb +5 -7
- data/lib/image/store/s3.rb +2 -2
- data/lib/image/store/store.rb +1 -1
- data/lib/image/store/walrus.rb +2 -2
- data/lib/image/version.rb +1 -1
- data/spec/lib/meta_spec.rb +10 -9
- data/spec/lib/routes/delete_image_spec.rb +2 -2
- data/spec/lib/routes/get_image_spec.rb +2 -2
- data/spec/lib/routes/get_images_detail_spec.rb +6 -6
- data/spec/lib/routes/get_images_spec.rb +5 -5
- data/spec/lib/routes/head_image_spec.rb +2 -1
- data/spec/lib/routes/post_image_spec.rb +2 -2
- data/spec/lib/routes/put_image_spec.rb +2 -1
- metadata +2 -2
data/lib/image/meta.rb
CHANGED
@@ -5,32 +5,27 @@ require 'json'
|
|
5
5
|
module Visor
|
6
6
|
module Image
|
7
7
|
|
8
|
-
# The API for the
|
8
|
+
# The API for the VISOR Meta System (VMS) server. This class supports all image metadata manipulation operations.
|
9
9
|
#
|
10
|
-
# This is the
|
11
|
-
#
|
10
|
+
# This is the API used by the VISOR Image System (VIS) to communicate with the VMS in order to accomplish
|
11
|
+
# metadata retrieving and registering operations.
|
12
12
|
#
|
13
13
|
class Meta
|
14
14
|
include Visor::Common::Exception
|
15
15
|
|
16
|
-
|
17
|
-
DEFAULT_PORT = 4567
|
16
|
+
attr_reader :host, :port
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
# Initializes a new new VISoR Meta Image.
|
18
|
+
# Initializes a new new VMS interface.
|
22
19
|
#
|
23
|
-
# @option opts [String] :host
|
24
|
-
# @option opts [String] :port
|
25
|
-
# @option opts [String] :ssl (false) If the connection should be made through HTTPS (SSL).
|
20
|
+
# @option opts [String] :host The host address where VMS server resides.
|
21
|
+
# @option opts [String] :port The host port where VMS server listens.
|
26
22
|
#
|
27
23
|
def initialize(opts = {})
|
28
|
-
@host = opts[:host]
|
29
|
-
@port = opts[:port]
|
30
|
-
@ssl = opts[:ssl] || false
|
24
|
+
@host = opts[:host]
|
25
|
+
@port = opts[:port]
|
31
26
|
end
|
32
27
|
|
33
|
-
# Retrieves
|
28
|
+
# Retrieves all public and user’s private images brief metadata.
|
34
29
|
# Options for filtering the returned results can be passed in.
|
35
30
|
#
|
36
31
|
# @option query [String] :<attribute_name> The image attribute value to filter returned results.
|
@@ -38,27 +33,18 @@ module Visor
|
|
38
33
|
# @option query [String] :sort ("_id") The image attribute to sort returned results.
|
39
34
|
# @option query [String] :dir ("asc") The direction to sort results ("asc"/"desc").
|
40
35
|
#
|
41
|
-
# @return [Array] All
|
42
|
-
# Just {Visor::Meta::Backends::Base::BRIEF BRIEF}
|
36
|
+
# @return [Array] All images brief metadata.
|
37
|
+
# Just {Visor::Meta::Backends::Base::BRIEF BRIEF} attributes are returned.
|
43
38
|
#
|
44
|
-
# @raise [NotFound] If there are no
|
39
|
+
# @raise [NotFound] If there are no images registered on VMS.
|
45
40
|
#
|
46
41
|
def get_images(query = {}, owner=nil)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
if owner
|
51
|
-
http = request.get path: '/images', query: query.merge({access: 'private', owner: owner}), head: get_headers
|
52
|
-
begin
|
53
|
-
priv = return_response(http)
|
54
|
-
rescue => e
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
pub + priv
|
42
|
+
query.merge!(owner: owner) if owner
|
43
|
+
http = request.get path: '/images', query: query, head: get_headers
|
44
|
+
return_response(http)
|
59
45
|
end
|
60
46
|
|
61
|
-
# Retrieves
|
47
|
+
# Retrieves all public and user’s private images detailed metadata.
|
62
48
|
#
|
63
49
|
# Filtering and querying works the same as with {#get_images}. The only difference is the number
|
64
50
|
# of disclosed attributes.
|
@@ -71,59 +57,50 @@ module Visor
|
|
71
57
|
# @return [Array] All public images detailed metadata.
|
72
58
|
# The {Visor::Meta::Backends::Base::DETAIL_EXC DETAIL_EXC} fields are excluded from results.
|
73
59
|
#
|
74
|
-
# @raise [NotFound] If there are no
|
60
|
+
# @raise [NotFound] If there are no images registered on the server.
|
75
61
|
#
|
76
62
|
def get_images_detail(query = {}, owner=nil)
|
63
|
+
query.merge!(owner: owner) if owner
|
77
64
|
http = request.get path: '/images/detail', query: query, head: get_headers
|
78
|
-
|
79
|
-
priv = []
|
80
|
-
if owner
|
81
|
-
http = request.get path: '/images/detail', query: query.merge({access: 'private', owner: owner}), head: get_headers
|
82
|
-
begin
|
83
|
-
priv = return_response(http)
|
84
|
-
rescue => e
|
85
|
-
nil
|
86
|
-
end
|
87
|
-
end
|
88
|
-
pub + priv
|
65
|
+
return_response(http)
|
89
66
|
end
|
90
67
|
|
91
|
-
# Retrieves detailed
|
68
|
+
# Retrieves detailed metadata of the image with the given id.
|
92
69
|
#
|
93
70
|
# @param id [String] The wanted image's _id.
|
94
71
|
#
|
95
|
-
# @return [Hash] The requested image metadata.
|
72
|
+
# @return [Hash] The requested image detailed metadata.
|
96
73
|
#
|
97
|
-
# @raise [NotFound] If image not found.
|
74
|
+
# @raise [NotFound] If image metadata was not found.
|
98
75
|
#
|
99
76
|
def get_image(id)
|
100
77
|
http = request.get path: "/images/#{id}", head: get_headers
|
101
78
|
return_response(http)
|
102
79
|
end
|
103
80
|
|
104
|
-
# Register a new image on
|
81
|
+
# Register a new image metadata on VMS and return it.
|
105
82
|
#
|
106
83
|
# @param meta [Hash] The image metadata.
|
107
84
|
#
|
108
|
-
# @return [Hash] The already inserted image metadata.
|
85
|
+
# @return [Hash] The already inserted detailed image metadata.
|
109
86
|
#
|
110
|
-
# @raise [Invalid] If image
|
87
|
+
# @raise [Invalid] If image metadata validation fails.
|
111
88
|
#
|
112
|
-
def post_image(meta)
|
89
|
+
def post_image(meta, address)
|
113
90
|
body = prepare_body(meta)
|
114
|
-
http = request.post path: '/images', body: body, head: post_headers
|
91
|
+
http = request.post path: '/images', body: body, head: post_headers(address)
|
115
92
|
return_response(http)
|
116
93
|
end
|
117
94
|
|
118
|
-
# Updates an image
|
95
|
+
# Updates an image metadata with the given metadata and returns it.
|
119
96
|
#
|
120
97
|
# @param id [String] The image's _id which will be updated.
|
121
98
|
# @param meta [Hash] The image metadata.
|
122
99
|
#
|
123
|
-
# @return [Hash] The already updated image metadata.
|
100
|
+
# @return [Hash] The already updated detailed image metadata.
|
124
101
|
#
|
125
102
|
# @raise [Invalid] If image meta validation fails.
|
126
|
-
# @raise [NotFound] If
|
103
|
+
# @raise [NotFound] If the target image metadata was not found.
|
127
104
|
#
|
128
105
|
def put_image(id, meta)
|
129
106
|
body = prepare_body(meta)
|
@@ -135,9 +112,9 @@ module Visor
|
|
135
112
|
#
|
136
113
|
# @param id [String] The image's _id which will be deleted.
|
137
114
|
#
|
138
|
-
# @return [Hash] The already deleted image metadata. This is useful for
|
115
|
+
# @return [Hash] The already deleted detailed image metadata. This is useful for recovery on accidental delete.
|
139
116
|
#
|
140
|
-
# @raise [NotFound] If
|
117
|
+
# @raise [NotFound] If the target image metadata was not found.
|
141
118
|
#
|
142
119
|
def delete_image(id)
|
143
120
|
http = request.delete path: "/images/#{id}", head: delete_headers
|
@@ -160,7 +137,7 @@ module Visor
|
|
160
137
|
|
161
138
|
# Process requests by preparing its headers, launch them and assert or raise their response.
|
162
139
|
#
|
163
|
-
# @param
|
140
|
+
# @param http [EventMachine::HttpRequest] The request which will be launched.
|
164
141
|
#
|
165
142
|
# @return [String, Hash] If an error is raised, then it parses and returns its message,
|
166
143
|
# otherwise it properly parse and return the response body.
|
@@ -171,30 +148,36 @@ module Visor
|
|
171
148
|
def return_response(http)
|
172
149
|
body = http.response
|
173
150
|
status = http.response_header.status.to_i
|
174
|
-
parsed = JSON.parse(body, symbolize_names: true)
|
175
151
|
|
176
152
|
case status
|
153
|
+
when 0 then
|
154
|
+
raise InternalError, "VISOR Meta System server not found. Is it running?"
|
177
155
|
when 404 then
|
178
|
-
raise NotFound,
|
156
|
+
raise NotFound, parse(body)
|
179
157
|
when 400 then
|
180
|
-
raise Invalid,
|
158
|
+
raise Invalid, parse(body)
|
181
159
|
when 500 then
|
182
|
-
raise InternalError,
|
160
|
+
raise InternalError, parse(body)
|
183
161
|
else
|
184
|
-
|
162
|
+
parse(body)
|
185
163
|
end
|
186
164
|
end
|
187
165
|
|
166
|
+
def parse(body)
|
167
|
+
parsed = JSON.parse(body, symbolize_names: true)
|
168
|
+
parsed[:image] || parsed[:images] || parsed[:message]
|
169
|
+
end
|
170
|
+
|
188
171
|
# Generate a new HTTP or HTTPS connection based on initialization parameters.
|
189
172
|
#
|
190
173
|
# @return [EventMachine::HttpRequest] A HTTP or HTTPS (not done yet) connection ready to use.
|
191
174
|
#
|
192
175
|
def request
|
193
|
-
if @ssl
|
176
|
+
#if @ssl
|
194
177
|
#TODO: ssl connection
|
195
|
-
else
|
178
|
+
#else
|
196
179
|
EventMachine::HttpRequest.new("http://#{@host}:#{@port}")
|
197
|
-
end
|
180
|
+
#end
|
198
181
|
end
|
199
182
|
|
200
183
|
# Fill common header keys before each request. This sets the 'User-Agent' and 'Accept'
|
@@ -202,18 +185,23 @@ module Visor
|
|
202
185
|
# for POST and PUT requests.
|
203
186
|
#
|
204
187
|
def get_headers
|
205
|
-
{'User-Agent' => '
|
188
|
+
{'User-Agent' => 'VISOR Image System',
|
206
189
|
'Accept' => 'application/json'}
|
207
190
|
end
|
208
191
|
|
209
|
-
def
|
210
|
-
{'User-Agent' =>
|
192
|
+
def put_headers
|
193
|
+
{'User-Agent' => "VISOR Image System",
|
194
|
+
'Accept' => 'application/json',
|
195
|
+
'content-type' => 'application/json'}
|
196
|
+
end
|
197
|
+
|
198
|
+
def post_headers(address)
|
199
|
+
{'User-Agent' => "VISOR Image System - #{address}",
|
211
200
|
'Accept' => 'application/json',
|
212
201
|
'content-type' => 'application/json'}
|
213
202
|
end
|
214
203
|
|
215
204
|
alias :delete_headers :get_headers
|
216
|
-
alias :put_headers :post_headers
|
217
205
|
end
|
218
206
|
end
|
219
207
|
end
|
@@ -38,6 +38,8 @@ module Visor
|
|
38
38
|
return exit_error(403, e.message)
|
39
39
|
rescue NotFound => e
|
40
40
|
return exit_error(404, e.message)
|
41
|
+
rescue InternalError => e
|
42
|
+
exit_error(503, e.message)
|
41
43
|
end
|
42
44
|
|
43
45
|
custom = {'Content-Type' => 'application/octet-stream', 'X-Stream' => 'Goliath'}
|
@@ -30,11 +30,14 @@ module Visor
|
|
30
30
|
def response(env)
|
31
31
|
access_key = authorize(env, vas)
|
32
32
|
meta = vms.get_images(params, access_key)
|
33
|
+
env.params.delete('format')
|
33
34
|
[200, {}, {images: meta}]
|
34
35
|
rescue Forbidden => e
|
35
36
|
exit_error(403, e.message)
|
36
37
|
rescue NotFound => e
|
37
38
|
exit_error(404, e.message)
|
39
|
+
rescue InternalError => e
|
40
|
+
exit_error(503, e.message)
|
38
41
|
end
|
39
42
|
|
40
43
|
# Produce an HTTP response with an error code and message.
|
@@ -30,11 +30,14 @@ module Visor
|
|
30
30
|
def response(env)
|
31
31
|
access_key = authorize(env, vas)
|
32
32
|
meta = vms.get_images_detail(params, access_key)
|
33
|
+
env.params.delete('format')
|
33
34
|
[200, {}, {images: meta}]
|
34
35
|
rescue Forbidden => e
|
35
36
|
exit_error(403, e.message)
|
36
37
|
rescue NotFound => e
|
37
38
|
exit_error(404, e.message)
|
39
|
+
rescue InternalError => e
|
40
|
+
exit_error(503, e.message)
|
38
41
|
end
|
39
42
|
|
40
43
|
# Produce an HTTP response with an error code and message.
|
@@ -74,7 +74,7 @@ module Visor
|
|
74
74
|
rescue InternalError => e
|
75
75
|
body.close if body
|
76
76
|
body.unlink if body
|
77
|
-
return exit_error(
|
77
|
+
return exit_error(503, e.message)
|
78
78
|
end
|
79
79
|
|
80
80
|
# if has body(image file), upload file and update meta or raise on error
|
@@ -86,6 +86,8 @@ module Visor
|
|
86
86
|
return exit_error(404, e.message, true)
|
87
87
|
rescue Duplicated => e
|
88
88
|
return exit_error(409, e.message, true)
|
89
|
+
rescue InternalError => e
|
90
|
+
return exit_error(503, e.message, true)
|
89
91
|
ensure
|
90
92
|
body.close
|
91
93
|
body.unlink
|
@@ -127,7 +129,7 @@ module Visor
|
|
127
129
|
# @return [Hash] The already inserted image metadata.
|
128
130
|
#
|
129
131
|
def insert_meta(meta)
|
130
|
-
image = vms.post_image(meta)
|
132
|
+
image = vms.post_image(meta, address)
|
131
133
|
env['id'] = image[:_id]
|
132
134
|
|
133
135
|
if image[:location]
|
@@ -82,7 +82,7 @@ module Visor
|
|
82
82
|
rescue InternalError => e
|
83
83
|
body.close if body
|
84
84
|
body.unlink if body
|
85
|
-
return exit_error(
|
85
|
+
return exit_error(503, e.message)
|
86
86
|
end unless meta.empty?
|
87
87
|
|
88
88
|
# if has body(image file), upload file and update meta or raise on error
|
@@ -96,6 +96,8 @@ module Visor
|
|
96
96
|
return exit_error(409, e.message)
|
97
97
|
rescue Duplicated => e
|
98
98
|
return exit_error(409, e.message, true)
|
99
|
+
rescue InternalError => e
|
100
|
+
return exit_error(503, e.message, true)
|
99
101
|
ensure
|
100
102
|
body.close
|
101
103
|
body.unlink
|
data/lib/image/server.rb
CHANGED
@@ -5,33 +5,35 @@ require 'json'
|
|
5
5
|
module Visor
|
6
6
|
module Image
|
7
7
|
|
8
|
-
# The
|
9
|
-
# operations
|
8
|
+
# The VISOR Image System (VIS) server. This server is the VISOR front-end and supports all image metadata manipulation
|
9
|
+
# operations (dispatched to the VISOR Meta System) and the image files management too.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# **The Server is a RESTful Web service with the following API:**
|
12
12
|
#
|
13
|
-
# HEAD /images/<id> -
|
14
|
-
# GET /images -
|
15
|
-
# GET /images/detail -
|
16
|
-
# GET /images/<id> -
|
17
|
-
# POST /images -
|
18
|
-
# PUT /images/<id> - Update
|
19
|
-
# DELETE /images/<id> -
|
13
|
+
# HEAD /images/<id> - Return detailed metadata of a given image.
|
14
|
+
# GET /images - Return brief metadata of all public and user’s private images.
|
15
|
+
# GET /images/detail - Return detailed metadata of all public and user’s private images.
|
16
|
+
# GET /images/<id> - Return the metadata and file of a given image.
|
17
|
+
# POST /images - Add new metadata and optionally upload a file.
|
18
|
+
# PUT /images/<id> - Update the metadata and/or file of a given image.
|
19
|
+
# DELETE /images/<id> - Remove the metadata and file of a given image.
|
20
20
|
#
|
21
|
-
# The
|
21
|
+
# The VIS API is multi-format, most properly it supports response encoding in JSON and XML formats.
|
22
22
|
# It will auto negotiate and encode the response metadata and error messages in the proper format,
|
23
23
|
# based on the request *Accept* header, being it 'application/json' or 'application/xml'.
|
24
24
|
# If no Accept header is provided, Image will encode and render it as JSON by default.
|
25
25
|
#
|
26
|
-
# This server routes all metadata operations to the {Visor::Meta::Server Visor Meta
|
26
|
+
# This server routes all metadata operations to the {Visor::Meta::Server Visor Meta System server}.
|
27
27
|
#
|
28
28
|
# The server will interact with the multiple supported backend store to manage the image files.
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# **Currently we support the following store backend and operations:**
|
31
31
|
#
|
32
32
|
# Amazon Simple Storage (s3) - GET, POST, PUT, DELETE
|
33
|
+
# Lunacloud Storage (lcs) - GET, POST, PUT, DELETE
|
33
34
|
# Nimbus Cumulus (cumulus) - GET, POST, PUT, DELETE
|
34
35
|
# Eucalyptus Walrus (walrus) - GET, POST, PUT, DELETE
|
36
|
+
# Hadoop HDFS (hdfs) - GET, POST, PUT, DELETE
|
35
37
|
# Local Filesystem (file) - GET, POST, PUT, DELETE
|
36
38
|
# Remote HTTP (http) - GET
|
37
39
|
#
|
@@ -57,26 +59,34 @@ module Visor
|
|
57
59
|
#
|
58
60
|
# The image metadata is promptly passed as a set of HTTP headers, as the following example:
|
59
61
|
#
|
60
|
-
# x-image-meta-_id:
|
61
|
-
# x-image-meta-uri:
|
62
|
-
# x-image-meta-name:
|
63
|
-
# x-image-meta-architecture:
|
64
|
-
# x-image-meta-access:
|
65
|
-
# x-image-meta-status:
|
66
|
-
# x-image-meta-
|
62
|
+
# x-image-meta-_id: <id>
|
63
|
+
# x-image-meta-uri: <uri>
|
64
|
+
# x-image-meta-name: <name>
|
65
|
+
# x-image-meta-architecture: <architecture>
|
66
|
+
# x-image-meta-access: <access>
|
67
|
+
# x-image-meta-status: <status>
|
68
|
+
# x-image-meta-size: <size>
|
69
|
+
# x-image-meta-format: <format>
|
70
|
+
# x-image-meta-store: <store>
|
71
|
+
# x-image-meta-location: <location>
|
72
|
+
# x-image-meta-created_at: <timestamp>
|
73
|
+
# x-image-meta-updated_at: <timestamp>
|
74
|
+
# x-image-meta-checksum: <checksum>
|
75
|
+
# x-image-meta-owner: <owner>
|
67
76
|
#
|
68
|
-
# @note Undefined attributes are ignored and not included into response's header.
|
69
|
-
#
|
77
|
+
# @note Undefined attributes are ignored and not included into response's header.
|
78
|
+
# Any raised error will be passed through HTTP headers too.
|
70
79
|
#
|
71
80
|
# @param [String] id The wanted image _id.
|
72
81
|
#
|
73
82
|
# @example Retrieve the image metadata with id '19b39ed6-6c43-41cc-8d59-d1a1ed24ac9d':
|
74
83
|
# 'HEAD /images/19b39ed6-6c43-41cc-8d59-d1a1ed24ac9d'
|
75
84
|
#
|
76
|
-
# @return [HTTP Headers] The image
|
85
|
+
# @return [HTTP Headers] The image metadata.
|
77
86
|
#
|
78
|
-
# @raise [HTTP Error
|
79
|
-
# @raise [HTTP Error
|
87
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
88
|
+
# @raise [HTTP Error 404] If image metadata was not found.
|
89
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
80
90
|
#
|
81
91
|
head '/images/:id', HeadImage
|
82
92
|
|
@@ -84,20 +94,18 @@ module Visor
|
|
84
94
|
# @method get_all_brief
|
85
95
|
# @overload get '/images'
|
86
96
|
#
|
87
|
-
# Get brief
|
97
|
+
# Get brief metadata of all public and user’s private images, see {Visor::Image::GetImages}.
|
88
98
|
#
|
89
99
|
# { "images":
|
90
100
|
# [
|
91
101
|
# {
|
92
102
|
# "_id":<_id>,
|
93
|
-
# "uri":<uri>,
|
94
103
|
# "name":<name>,
|
95
104
|
# "architecture":<architecture>,
|
96
|
-
# "
|
105
|
+
# "access":<access>
|
97
106
|
# "format":<format>,
|
98
|
-
# "store":<type>,
|
99
107
|
# "size":<size>,
|
100
|
-
# "
|
108
|
+
# "store":<store>
|
101
109
|
# },
|
102
110
|
# ...
|
103
111
|
# ]
|
@@ -110,19 +118,20 @@ module Visor
|
|
110
118
|
# @param [String] sort ("_id") The image attribute to sort results.
|
111
119
|
# @param [String] dir ("asc") The sorting order ("asc"/"desc").
|
112
120
|
#
|
113
|
-
# @example Retrieve all
|
121
|
+
# @example Retrieve all images brief metadata:
|
114
122
|
# 'GET /images'
|
115
123
|
#
|
116
|
-
# @example Retrieve all
|
124
|
+
# @example Retrieve all `x86_64` images brief metadata:
|
117
125
|
# 'GET /images?architecture=x86_64'
|
118
126
|
#
|
119
|
-
# @example Retrieve all
|
127
|
+
# @example Retrieve all `.iso` images brief metadata, descending sorted by `size`:
|
120
128
|
# 'GET /images?format=iso&sort=size&dir=desc'
|
121
129
|
#
|
122
|
-
# @return [JSON, XML]
|
130
|
+
# @return [JSON, XML] Images brief metadata.
|
123
131
|
#
|
124
|
-
# @raise [HTTP Error
|
125
|
-
# @raise [HTTP Error
|
132
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
133
|
+
# @raise [HTTP Error 404] If no images were found.
|
134
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
126
135
|
#
|
127
136
|
get '/images', GetImages
|
128
137
|
|
@@ -130,7 +139,7 @@ module Visor
|
|
130
139
|
# @method get_all_detail
|
131
140
|
# @overload get '/images/detail'
|
132
141
|
#
|
133
|
-
# Get detailed
|
142
|
+
# Get detailed metadata of all public and user’s private images, see {Visor::Image::GetImagesDetail}.
|
134
143
|
#
|
135
144
|
# { "images":
|
136
145
|
# [
|
@@ -147,8 +156,8 @@ module Visor
|
|
147
156
|
# "store":<store>,
|
148
157
|
# "created_at":<timestamp>
|
149
158
|
# "updated_at":<timestamp>,
|
150
|
-
# "
|
151
|
-
# "
|
159
|
+
# "checksum":<checksum>,
|
160
|
+
# "owner":<owner>,
|
152
161
|
# },
|
153
162
|
# ...
|
154
163
|
# ]
|
@@ -161,15 +170,16 @@ module Visor
|
|
161
170
|
# @param [String] sort ("_id") The image attribute to sort results.
|
162
171
|
# @param [String] dir ("asc") The sorting order ("asc"/"desc").
|
163
172
|
#
|
164
|
-
# @example Retrieve all
|
173
|
+
# @example Retrieve all images detailed metadata:
|
165
174
|
# 'GET /images/detail'
|
166
175
|
#
|
167
|
-
# @note Querying and
|
176
|
+
# @note Querying and results sorting is made as with #get_all_brief
|
168
177
|
#
|
169
|
-
# @return [JSON, XML]
|
178
|
+
# @return [JSON, XML] Images detailed metadata.
|
170
179
|
#
|
171
|
-
# @raise [HTTP Error
|
172
|
-
# @raise [HTTP Error
|
180
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
181
|
+
# @raise [HTTP Error 404] If no images were found.
|
182
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
173
183
|
#
|
174
184
|
get '/images/detail', GetImagesDetail
|
175
185
|
|
@@ -177,21 +187,28 @@ module Visor
|
|
177
187
|
# @method get_image
|
178
188
|
# @overload get '/images/:id'
|
179
189
|
#
|
180
|
-
# Get
|
190
|
+
# Get detailed metadata and file for the image with given id, see {Visor::Image::GetImage}.
|
181
191
|
#
|
182
|
-
# The image data file is streamed
|
192
|
+
# The image data file is streamed through the response body. The server will return a 200 status code,
|
183
193
|
# with a special HTTP header, indicating that the response body will be streamed in chunks
|
184
194
|
# and connection shouldn't be closed until the transfer is complete.
|
185
195
|
#
|
186
196
|
# Also, the image metadata is promptly passed as a set of HTTP headers, as the following example:
|
187
197
|
#
|
188
|
-
# x-image-meta-_id:
|
189
|
-
# x-image-meta-uri:
|
190
|
-
# x-image-meta-name:
|
191
|
-
# x-image-meta-architecture:
|
192
|
-
# x-image-meta-access:
|
193
|
-
# x-image-meta-status:
|
194
|
-
# x-image-meta-
|
198
|
+
# x-image-meta-_id: <id>
|
199
|
+
# x-image-meta-uri: <uri>
|
200
|
+
# x-image-meta-name: <name>
|
201
|
+
# x-image-meta-architecture: <architecture>
|
202
|
+
# x-image-meta-access: <access>
|
203
|
+
# x-image-meta-status: <status>
|
204
|
+
# x-image-meta-size: <size>
|
205
|
+
# x-image-meta-format: <format>
|
206
|
+
# x-image-meta-store: <store>
|
207
|
+
# x-image-meta-location: <location>
|
208
|
+
# x-image-meta-created_at: <timestamp>
|
209
|
+
# x-image-meta-updated_at: <timestamp>
|
210
|
+
# x-image-meta-checksum: <checksum>
|
211
|
+
# x-image-meta-owner: <owner>
|
195
212
|
#
|
196
213
|
# @note Undefined attributes are ignored and not included into response's header.
|
197
214
|
#
|
@@ -200,11 +217,13 @@ module Visor
|
|
200
217
|
# @example Retrieve the image with id '19b39ed6-6c43-41cc-8d59-d1a1ed24ac9d':
|
201
218
|
# 'GET /images/19b39ed6-6c43-41cc-8d59-d1a1ed24ac9d'
|
202
219
|
#
|
203
|
-
# @return [HTTP Headers] The image
|
204
|
-
# @return [HTTP Body] The image
|
220
|
+
# @return [HTTP Headers] The image metadata.
|
221
|
+
# @return [HTTP Body] The image file.
|
205
222
|
#
|
206
|
-
# @raise [HTTP Error
|
207
|
-
# @raise [HTTP Error
|
223
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
224
|
+
# @raise [HTTP Error 404] If the image metadata was not found.
|
225
|
+
# @raise [HTTP Error 404] If the image file was not found.
|
226
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
208
227
|
#
|
209
228
|
get '/images/:id', GetImage
|
210
229
|
|
@@ -222,8 +241,8 @@ module Visor
|
|
222
241
|
#
|
223
242
|
# If wanted, the image data file should be streamed through the request body.
|
224
243
|
# The server will receive that data in chunks, buffering them to a properly secured temporary
|
225
|
-
# file, avoiding buffering all the data into memory.
|
226
|
-
#
|
244
|
+
# file, avoiding buffering all the data into memory. The server will then handle the upload of that
|
245
|
+
# file to the definitive store location, cleaning then the generated temporary file.
|
227
246
|
#
|
228
247
|
# Alternatively, a *x-image-meta-location* header can be passed, if the file is already stored in some
|
229
248
|
# provided location. If this header is present, no body content can be passed in the request.
|
@@ -234,9 +253,10 @@ module Visor
|
|
234
253
|
# @raise [HTTP Error 400] If the location header is present no file content can be provided.
|
235
254
|
# @raise [HTTP Error 400] If trying to post an image file to a HTTP backend.
|
236
255
|
# @raise [HTTP Error 400] If provided store is an unsupported store backend.
|
237
|
-
# @raise [HTTP Error
|
256
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
257
|
+
# @raise [HTTP Error 404] If no image file is found at the provided location.
|
238
258
|
# @raise [HTTP Error 409] If the provided image file already exists in the backend store.
|
239
|
-
# @raise [HTTP Error
|
259
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
240
260
|
#
|
241
261
|
post '/images', PostImage
|
242
262
|
|
@@ -269,10 +289,11 @@ module Visor
|
|
269
289
|
# @raise [HTTP Error 400] If the location header is present no file content can be provided.
|
270
290
|
# @raise [HTTP Error 400] If trying to post an image file to a HTTP backend.
|
271
291
|
# @raise [HTTP Error 400] If provided store is an unsupported store backend.
|
292
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
272
293
|
# @raise [HTTP Error 404] If no image data is found at the provided location.
|
273
294
|
# @raise [HTTP Error 409] If trying to assign image file to a locked or uploading image.
|
274
295
|
# @raise [HTTP Error 409] If the provided image file already exists in the backend store.
|
275
|
-
# @raise [HTTP Error
|
296
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
276
297
|
#
|
277
298
|
put '/images/:id', PutImage
|
278
299
|
|
@@ -280,7 +301,7 @@ module Visor
|
|
280
301
|
# @method delete
|
281
302
|
# @overload delete '/images/:id'
|
282
303
|
#
|
283
|
-
# Delete the metadata and
|
304
|
+
# Delete the metadata and file of the image with the given id, see {Visor::Image::DeleteImage}.
|
284
305
|
#
|
285
306
|
# @param [String] id The image _id to delete.
|
286
307
|
#
|
@@ -289,9 +310,10 @@ module Visor
|
|
289
310
|
#
|
290
311
|
# @return [JSON, XML] The already deleted image detailed metadata.
|
291
312
|
#
|
292
|
-
# @raise [HTTP Error
|
313
|
+
# @raise [HTTP Error 403] If user authentication has failed.
|
293
314
|
# @raise [HTTP Error 403] If user does not have permission to manipulate the image file.
|
294
|
-
# @raise [HTTP Error
|
315
|
+
# @raise [HTTP Error 404] If image metadata was not found.
|
316
|
+
# @raise [HTTP Error 503] If VIS or VAS servers were not found.
|
295
317
|
#
|
296
318
|
delete '/images/:id', DeleteImage
|
297
319
|
|