-
Notifications
You must be signed in to change notification settings - Fork 78
Object Storage
os = OpenStack::Connection.create(:username => USERNAME, :api_key => API_KEY, :authtenant => TENANT, :auth_url => API_URL, :service_type => "object-store")
os.get_info => {:count=>2, :bytes=>495041}
os.containers => ["another_containerfoo", "marios_test_container"]
os.containers_detail =>=> {"another_containerfoo"=>{:count=>"3", :bytes=>"1994"}, "marios_test_container"=>{:count=>"2", :bytes=>"493047"}}
os.container_exists?("no_such_thing") => false
os.create_container("foo") => => #<OpenStack::Swift::Container:0xb7275c38 ...... (rest of OpenStack::Swift::Container object)
os.delete_container("foo") => true
cont = os.container("foo") => #<OpenStack::Swift::Container:0xb7262124 ...... (rest of OpenStack::Swift::Container object)
cont.container_metadata =>{:count=>"2", :bytes=>"493047", :metadata=>{"foo"=>"bar", "author"=>"foobar", "jj"=>"foobar", "date"=>"today", "owner"=>"foo"}}
cont.metadata => {"foo"=>"bar", "author"=>"foobar", "jj"=>"foobar", "date"=>"today", "owner"=>"foo"}
cont.set_metadata({"X-Container-Meta-Author"=> "msa", "version"=>"1.2", :date=>"today"}) => true
cont.objects => ["fosdem2012.pdf", "moved_object"]
cont.objects_detail => {"fosdem2012.pdf"=>{:bytes=>"493009", :content_type=>"application/json", :hash=>"494e444f92a8082dabac80a74cdf2c3b", :last_modified=>"2012-04-26T09:22:51.611230"}, "moved_object"=>{:bytes=>"38", :content_type=>"application/json", :hash=>"a7942f97fe6bd34920a4f61fe5e604a5", :last_modified=>"2012-04-26T09:35:33.839920"}}
cont.empty? => false
cont.object_exists?("foo") => false
new_obj = cont.create_object("foo", {:metadata=>{"herpy"=>"derp"}, :content_type=>"text/plain"}, "this is the data") [can also supply File.open(/path/to/file) and the data] => #<OpenStack::Swift::StorageObject:0xb72fdac0 ... etc
cont.delete_object("foo") => true
obj = cont.object("foo") => #<OpenStack::Swift::StorageObject:0xb72fdac0 ... etc
obj.object_metadata =>
obj.metadata =>
obj.data => "This is the text stored in the file"
data = ""; object.data_stream do |chunk| data += chunk end => #<Net::HTTPOK 200 OK readbody=true> data => "This is the text stored in the file"
obj.set_metadata({:foo=>"bar", "X-Object-Meta-herpa"=>"derp", "author"=>"me"}) => true
object.write("This is new data") => true object.data => "This is new data"
copied = obj.copy('copied_object', "destination_container", {:content_type=>"text/plain", :metadata=>{:herp=>"derp", "X-Object-Meta-foo"=>"bar} } ) => #<OpenStack::Swift::StorageObject:0xb728974c ..... etc
moved = obj.move('moved_object', "destination_container", {:content_type=>"text/plain", :metadata=>{:herp=>"derp", "X-Object-Meta-foo"=>"bar"} } ) => #<OpenStack::Swift::StorageObject:0xb7266bd4 ... moved.metadata => {"foo"=>"bar", "herp"=>"derp", "herpy"=>"derp"} obj.metadata => OpenStack::Exception::ItemNotFound: The resource could not be found
Core Services
The project