Module: Fog::RiakCS::UserUtils

Included in:
Provisioning::Mock, Provisioning::Real
Defined in:
lib/fog/riakcs/core.rb

Instance Method Summary collapse

Instance Method Details

#update_mock_user(key_id, user) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fog/riakcs/core.rb', line 81

def update_mock_user(key_id, user)
  if data[key_id]
    if status = user[:status]
      data[key_id][:status] = status
    end

    if user[:new_key_secret]
      data[key_id][:key_secret] = rand(100).to_s
    end

    Excon::Response.new.tap do |response|
      response.status = 200
      response.body   = data[key_id]
    end
  else
    Excon::Response.new.tap do |response|
      response.status = 403
    end
  end
end

#update_riakcs_user(key_id, user) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/fog/riakcs/core.rb', line 73

def update_riakcs_user(key_id, user)
  response = @s3_connection.put_object('riak-cs', "user/#{key_id}", Fog::JSON.encode(user), { 'Content-Type' => 'application/json' })
  if !response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end