1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
module Fog
module OpenStack
class Network
class Real
def update_rbac_policy(rbac_policy_id, options = {})
data = {'rbac_policy' => {}}
vanilla_options = [:target_tenant]
vanilla_options.select { |o| options.key?(o) }.each do |key|
data['rbac_policy'][key] = options[key]
end
request(
:body => Fog::JSON.encode(data),
:expects => 200,
:method => 'PUT',
:path => "rbac-policies/#{rbac_policy_id}"
)
end
end
class Mock
def update_rbac_policy(rbac_policy_id, options = {})
response = Excon::Response.new
rbac_policy = list_rbac_policies.body['rbac_policies'].detect do |instance|
instance['id'] == rbac_policy_id
end
if rbac_policy
rbac_policy['target_tenant'] = options[:target_tenant]
response.body = {'rbac_policy' => rbac_policy}
response.status = 200
response
else
raise Fog::OpenStack::Network::NotFound
end
end
end
end
end
end
|