class Chef::ChefFS::FileSystem::ChefServer::AclEntry

Constants

PERMISSIONS

Public Instance Methods

api_path() click to toggle source
# File lib/chef/chef_fs/file_system/chef_server/acl_entry.rb, line 29
def api_path
  "#{super}/_acl"
end
delete(recurse) click to toggle source
# File lib/chef/chef_fs/file_system/chef_server/acl_entry.rb, line 42
def delete(recurse)
  raise Chef::ChefFS::FileSystem::OperationNotAllowedError.new(:delete, self, nil, "ACLs cannot be deleted")
end
display_path() click to toggle source
# 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) click to toggle source
# File lib/chef/chef_fs/file_system/chef_server/acl_entry.rb, line 46
def write(file_contents)
  # ACL writes are fun.
  acls = data_handler.normalize(Chef::JSONCompat.parse(file_contents), self)
  PERMISSIONS.each do |permission|
    begin
      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
end