Class: Chef::ChefFS::FileSystem::ChefServer::PolicyRevisionEntry

Inherits:
RestListEntry show all
Defined in:
lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb

Overview

/policies/NAME-REVISION.json Represents the actual data at /organizations/ORG/policies/NAME/revisions/REVISION

Instance Attribute Summary

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from RestListEntry

#_read_json, #api_child_name, #api_error_text, #chef_object, #compare_to, #data_handler, #delete, #display_name, #environment, #exists?, #initialize, #minimize_value, #normalize_value, #org, #read, #rest

Methods inherited from BaseFSObject

#can_have_child?, #chef_object, #child, #children, #compare_to, #create_child, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::ChefServer::RestListEntry

Instance Method Details

#api_path(options = {}) ⇒ Object

/policies/foo-1.0.0.json -> /policies/foo/revisions/1.0.0



13
14
15
# File 'lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb', line 13

def api_path(options = {})
  "#{parent.api_path}/#{policy_name}/revisions/#{revision_id}"
end

#display_pathObject



17
18
19
# File 'lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb', line 17

def display_path
  "/policies/#{policy_name}-#{revision_id}.json"
end

#policy_nameObject



25
26
27
28
# File 'lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb', line 25

def policy_name
  policy_name, revision_id = data_handler.name_and_revision(name)
  policy_name
end

#revision_idObject



30
31
32
33
# File 'lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb', line 30

def revision_id
  policy_name, revision_id = data_handler.name_and_revision(name)
  revision_id
end

#write(file_contents) ⇒ Object



21
22
23
# File 'lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb', line 21

def write(file_contents)
  raise OperationNotAllowedError.new(:write, self, nil, "cannot be updated: policy revisions are immutable once uploaded. If you want to change the policy, create a new revision with your changes")
end