Class: Aeolus::Image::Warehouse::Client
- Inherits:
-
Object
- Object
- Aeolus::Image::Warehouse::Client
- Defined in:
- lib/aeolus_image/model/warehouse/warehouse_client.rb
Instance Method Summary collapse
- #bucket(bucket) ⇒ Object
- #buckets ⇒ Object
- #create_bucket(bucket) ⇒ Object
- #get_iwhd_version ⇒ Object
-
#initialize(uri) ⇒ Client
constructor
A new instance of Client.
- #query(bucket_name, query_string) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Client
Returns a new instance of Client.
170 171 172 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 170 def initialize(uri) @connection = Connection.new(uri) end |
Instance Method Details
#bucket(bucket) ⇒ Object
179 180 181 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 179 def bucket(bucket) Bucket.new bucket, @connection end |
#buckets ⇒ Object
183 184 185 186 187 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 183 def buckets @connection.do_request.xpath('/api/link[@rel="bucket"]').map do |obj| obj.at_xpath('./@href').to_s.gsub(/.*\//, '') end end |
#create_bucket(bucket) ⇒ Object
174 175 176 177 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 174 def create_bucket(bucket) @connection.do_request("/#{bucket}", :method => :put) rescue RestClient::InternalServerError Bucket.new(bucket, @connection) end |
#get_iwhd_version ⇒ Object
189 190 191 192 193 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 189 def get_iwhd_version result = @connection.do_request.at_xpath('/api[@service="image_warehouse"]/@version') raise "Response does not contain <api> tag or version information" if result == nil return result.value end |
#query(bucket_name, query_string) ⇒ Object
195 196 197 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 195 def query(bucket_name, query_string) @connection.do_request "/#{bucket_name}/_query", {:method => :post, :content => query_string} end |