42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb', line 42
def write(contents)
desired_invites = minimize_value(Chef::JSONCompat.parse(contents, create_additions: false))
actual_invites = _read_json.inject({}) { |h, val| h[val["username"]] = val["id"]; h }
invites = actual_invites.keys
(desired_invites - invites).each do |invite|
rest.post(api_path, { "user" => invite })
rescue Net::HTTPClientException => e
if e.response.code == "409"
Chef::Log.warn("Could not invite #{invite} to organization #{org}: #{api_error_text(e.response)}")
else
raise
end
end
(invites - desired_invites).each do |invite|
rest.delete(File.join(api_path, actual_invites[invite]))
end
end
|