Class: Visor::Web::Meta
- Inherits:
-
Object
- Object
- Visor::Web::Meta
- Includes:
- Common::Exception
- Defined in:
- lib/web/meta.rb
Overview
The Client API for the VISoR Meta. This class supports all image metadata manipulation operations through a programmatically interface.
After Instantiate a Client object its possible to directly interact with the meta server and its database backend.
Constant Summary collapse
- DEFAULT_HOST =
configs[:bind_host] || '0.0.0.0'
- DEFAULT_PORT =
configs[:bind_port] || 4567
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
Instance Method Summary collapse
-
#delete_image(id) ⇒ Hash
Removes an image record based on its _id and returns its metadata.
-
#get_image(id) ⇒ Hash
Retrieves detailed image metadata of the image with the given id.
-
#get_images(query = {}) ⇒ Array
Retrieves brief metadata of all public images.
-
#get_images_detail(query = {}) ⇒ Array
Retrieves detailed metadata of all public images.
-
#initialize(opts = {}) ⇒ Meta
constructor
Initializes a new new VISoR Meta Client.
-
#post_image(meta) ⇒ Hash
Register a new image on the server with the given metadata and returns its metadata.
-
#put_image(id, meta) ⇒ Hash
Updates an image record with the given metadata and returns its metadata.
Constructor Details
#initialize(opts = {}) ⇒ Meta
Initializes a new new VISoR Meta Client.
41 42 43 44 45 |
# File 'lib/web/meta.rb', line 41 def initialize(opts = {}) @host = opts[:host] || DEFAULT_HOST @port = opts[:port] || DEFAULT_PORT @ssl = opts[:ssl] || false end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
24 25 26 |
# File 'lib/web/meta.rb', line 24 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
24 25 26 |
# File 'lib/web/meta.rb', line 24 def port @port end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
24 25 26 |
# File 'lib/web/meta.rb', line 24 def ssl @ssl end |
Instance Method Details
#delete_image(id) ⇒ Hash
Removes an image record based on its _id and returns its metadata.
220 221 222 223 |
# File 'lib/web/meta.rb', line 220 def delete_image(id) request = Net::HTTP::Delete.new("/images/#{id}") do_request(request) end |
#get_image(id) ⇒ Hash
Retrieves detailed image metadata of the image with the given id.
140 141 142 143 |
# File 'lib/web/meta.rb', line 140 def get_image(id) request = Net::HTTP::Get.new("/images/#{id}") do_request(request) end |
#get_images(query = {}) ⇒ Array
Retrieves brief metadata of all public images. Options for filtering the returned results can be passed in.
83 84 85 86 87 |
# File 'lib/web/meta.rb', line 83 def get_images(query = {}) str = build_query(query) request = Net::HTTP::Get.new("/images#{str}") do_request(request) end |
#get_images_detail(query = {}) ⇒ Array
Retrieves detailed metadata of all public images.
Filtering and querying works the same as with #get_images. The only difference is the number of disclosed attributes.
108 109 110 111 112 |
# File 'lib/web/meta.rb', line 108 def get_images_detail(query = {}) str = build_query(query) request = Net::HTTP::Get.new("/images/detail#{str}") do_request(request) end |
#post_image(meta) ⇒ Hash
Register a new image on the server with the given metadata and returns its metadata.
168 169 170 171 172 |
# File 'lib/web/meta.rb', line 168 def post_image() request = Net::HTTP::Post.new('/images') request.body = prepare_body() do_request(request) end |
#put_image(id, meta) ⇒ Hash
Updates an image record with the given metadata and returns its metadata.
200 201 202 203 204 |
# File 'lib/web/meta.rb', line 200 def put_image(id, ) request = Net::HTTP::Put.new("/images/#{id}") request.body = prepare_body() do_request(request) end |