Class: Chef::ChefFS::FileSystem::ChefServer::AclEntry
Constant Summary
collapse
- PERMISSIONS =
%w{create read update delete grant}.freeze
Instance Attribute Summary
Attributes inherited from BaseFSObject
#name, #parent, #path
Instance Method Summary
collapse
#_read_json, #api_child_name, #api_error_text, #chef_object, #compare_to, #data_handler, #display_name, #environment, #exists?, #initialize, #minimize_value, #normalize_value, #org, #read, #rest
#can_have_child?, #chef_object, #child, #children, #compare_to, #create_child, #dir?, #exists?, #initialize, #path_for_printing, #read, #root
Instance Method Details
#api_path ⇒ Object
29
30
31
|
# File 'lib/chef/chef_fs/file_system/chef_server/acl_entry.rb', line 29
def api_path
"#{super}/_acl"
end
|
#delete(recurse) ⇒ Object
#display_path ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/chef/chef_fs/file_system/chef_server/acl_entry.rb', line 33
def display_path
pth = if parent.name == "acls"
"/acls/#{name}"
else
"/acls/#{parent.name}/#{name}"
end
File.extname(pth).empty? ? pth + ".json" : pth
end
|
#write(file_contents) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/chef/chef_fs/file_system/chef_server/acl_entry.rb', line 46
def write(file_contents)
acls = data_handler.normalize(Chef::JSONCompat.parse(file_contents), self)
PERMISSIONS.each do |permission|
rest.put("#{api_path}/#{permission}", { permission => acls[permission] })
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, e, "Timeout writing: #{e}")
rescue Net::HTTPClientException => e
if e.response.code == "404"
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
else
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, e, "HTTP error writing: #{e}")
end
end
end
|