Class: ChefFS::FileSystem::NodesDir
- Inherits:
-
RestListDir
- Object
- BaseFSObject
- BaseFSDir
- RestListDir
- ChefFS::FileSystem::NodesDir
- Defined in:
- lib/chef_fs/file_system/nodes_dir.rb
Instance Attribute Summary
Attributes inherited from RestListDir
Attributes inherited from BaseFSObject
Instance Method Summary collapse
-
#children ⇒ Object
Identical to RestListDir.children, except supports environments.
- #env_api_path ⇒ Object
-
#initialize(parent) ⇒ NodesDir
constructor
A new instance of NodesDir.
Methods inherited from RestListDir
#_make_child_entry, #can_have_child?, #child, #create_child, #environment, #org, #rest
Methods inherited from BaseFSDir
#can_have_child?, #child, #dir?
Methods inherited from BaseFSObject
#can_have_child?, #chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write
Constructor Details
#initialize(parent) ⇒ NodesDir
Returns a new instance of NodesDir.
27 28 29 |
# File 'lib/chef_fs/file_system/nodes_dir.rb', line 27 def initialize(parent) super("nodes", parent, nil, ChefFS::DataHandler::NodeDataHandler.new) end |
Instance Method Details
#children ⇒ Object
Identical to RestListDir.children, except supports environments
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/chef_fs/file_system/nodes_dir.rb', line 32 def children begin @children ||= ChefFS::RawRequest.raw_json(rest, env_api_path).keys.sort.map do |key| _make_child_entry("#{key}.json", true) end rescue Timeout::Error => e raise ChefFS::FileSystem::OperationFailedError.new(:children, self, e), "Timeout retrieving children: #{e}" rescue Net::HTTPServerException => e if $!.response.code == "404" raise ChefFS::FileSystem::NotFoundError.new(self, $!) else raise ChefFS::FileSystem::OperationFailedError.new(:children, self, e), "HTTP error retrieving children: #{e}" end end end |
#env_api_path ⇒ Object
48 49 50 |
# File 'lib/chef_fs/file_system/nodes_dir.rb', line 48 def env_api_path environment ? "environments/#{environment}/#{api_path}" : api_path end |