Class: Visor::Image::Meta
- Inherits:
-
Object
- Object
- Visor::Image::Meta
- Includes:
- Common::Exception
- Defined in:
- lib/image/meta.rb
Overview
The API for the VISOR Meta System (VMS) server. This class supports all image metadata manipulation operations.
This is the API used by the VISOR Image System (VIS) to communicate with the VMS in order to accomplish metadata retrieving and registering operations.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
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 metadata of the image with the given id.
-
#get_images(query = {}, owner = nil) ⇒ Array
Retrieves all public and user’s private images brief metadata.
-
#get_images_detail(query = {}, owner = nil) ⇒ Array
Retrieves all public and user’s private images detailed metadata.
-
#initialize(opts = {}) ⇒ Meta
constructor
Initializes a new new VMS interface.
-
#post_image(meta, address) ⇒ Hash
Register a new image metadata on VMS and return it.
-
#put_image(id, meta) ⇒ Hash
Updates an image metadata with the given metadata and returns it.
Constructor Details
#initialize(opts = {}) ⇒ Meta
Initializes a new new VMS interface.
23 24 25 26 |
# File 'lib/image/meta.rb', line 23 def initialize(opts = {}) @host = opts[:host] @port = opts[:port] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/image/meta.rb', line 16 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/image/meta.rb', line 16 def port @port end |
Instance Method Details
#delete_image(id) ⇒ Hash
Removes an image record based on its _id and returns its metadata.
119 120 121 122 |
# File 'lib/image/meta.rb', line 119 def delete_image(id) http = request.delete path: "/images/#{id}", head: delete_headers return_response(http) end |
#get_image(id) ⇒ Hash
Retrieves detailed metadata of the image with the given id.
76 77 78 79 |
# File 'lib/image/meta.rb', line 76 def get_image(id) http = request.get path: "/images/#{id}", head: get_headers return_response(http) end |
#get_images(query = {}, owner = nil) ⇒ Array
Retrieves all public and user’s private images brief metadata. Options for filtering the returned results can be passed in.
41 42 43 44 45 |
# File 'lib/image/meta.rb', line 41 def get_images(query = {}, owner=nil) query.merge!(owner: owner) if owner http = request.get path: '/images', query: query, head: get_headers return_response(http) end |
#get_images_detail(query = {}, owner = nil) ⇒ Array
Retrieves all public and user’s private images detailed metadata.
Filtering and querying works the same as with #get_images. The only difference is the number of disclosed attributes.
62 63 64 65 66 |
# File 'lib/image/meta.rb', line 62 def get_images_detail(query = {}, owner=nil) query.merge!(owner: owner) if owner http = request.get path: '/images/detail', query: query, head: get_headers return_response(http) end |
#post_image(meta, address) ⇒ Hash
Register a new image metadata on VMS and return it.
89 90 91 92 93 |
# File 'lib/image/meta.rb', line 89 def post_image(, address) body = prepare_body() http = request.post path: '/images', body: body, head: post_headers(address) return_response(http) end |
#put_image(id, meta) ⇒ Hash
Updates an image metadata with the given metadata and returns it.
105 106 107 108 109 |
# File 'lib/image/meta.rb', line 105 def put_image(id, ) body = prepare_body() http = request.put path: "/images/#{id}", body: body, head: put_headers return_response(http) end |