Class: Chef::ChefFS::FileSystem::ChefServer::DataBagsDir
- Inherits:
-
RestListDir
show all
- Defined in:
- lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb
Instance Attribute Summary
Attributes inherited from RestListDir
#api_path, #data_handler
Attributes inherited from BaseFSObject
#name, #parent, #path
Instance Method Summary
collapse
Methods inherited from RestListDir
#environment, #initialize, #org, #rest
Methods inherited from BaseFSDir
#dir?, #empty?, #initialize
#chef_object, #child, #compare_to, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root, #write
Instance Method Details
#can_have_child?(name, is_dir) ⇒ Boolean
44
45
46
|
# File 'lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb', line 44
def can_have_child?(name, is_dir)
is_dir
end
|
#create_child(name, file_contents) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb', line 48
def create_child(name, file_contents)
begin
rest.post(api_path, { "name" => name })
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, "Timeout creating child '#{name}': #{e}")
rescue Net::HTTPClientException => e
if e.response.code == "409"
raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self, e, "Cannot create #{name} under #{path}: already exists")
else
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, "HTTP error creating child '#{name}': #{e}")
end
end
@children = nil
DataBagDir.new(name, self, true)
end
|
#make_child_entry(name, exists = false) ⇒ Object
27
28
29
30
|
# File 'lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb', line 27
def make_child_entry(name, exists = false)
result = @children.find { |child| child.name == name } if @children
result || DataBagDir.new(name, self, exists)
end
|