Sha256: d302fd0bbe44272dabcedfcc4f15c918ca5ba3d288eb7da31fe124073629f1b8
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
module Fog module Radosgw class Provisioning class Real include Utils def delete_user(user_id) path = "admin/user" user_id = Fog::AWS.escape(user_id) query = "?uid=#{user_id}&format=json" params = { :method => 'DELETE', :path => path, } begin response = Excon.delete("#{@scheme}://#{@host}/#{path}#{query}", :headers => signed_headers(params)) if !response.body.empty? case response.headers['Content-Type'] when 'application/json' response.body = Fog::JSON.decode(response.body) end end response rescue Excon::Errors::NotFound => e raise Fog::Radosgw::Provisioning::NoSuchUser.new rescue Excon::Errors::BadRequest => e raise Fog::Radosgw::Provisioning::ServiceUnavailable.new end end end class Mock def user_exists?(user_id) data.find do |key, value| value[:user_id] == user_id end end def delete_user(user_id) if !user_exists?(user_id) raise Fog::Radosgw::Provisioning::NoSuchUser, "No user with user_id #{user_id} exists." end data.delete(user_id) Excon::Response.new.tap do |response| response.status = 200 response.headers['Content-Type'] = 'application/json' response.body = "" end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fog-radosgw-0.0.1 | lib/fog/radosgw/requests/provisioning/delete_user.rb |