diff options
Diffstat (limited to 'lib/chef_zero/server.rb')
-rw-r--r-- | lib/chef_zero/server.rb | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 1686301..2d84a52 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -69,11 +69,16 @@ require 'chef_zero/endpoints/organization_endpoint' require 'chef_zero/endpoints/organization_association_requests_endpoint' require 'chef_zero/endpoints/organization_association_request_endpoint' require 'chef_zero/endpoints/organization_authenticate_user_endpoint' -require 'chef_zero/endpoints/organization_policies_endpoint' -require 'chef_zero/endpoints/organization_policy_groups_endpoint' require 'chef_zero/endpoints/organization_users_endpoint' require 'chef_zero/endpoints/organization_user_endpoint' require 'chef_zero/endpoints/organization_validator_key_endpoint' +require 'chef_zero/endpoints/policies_endpoint' +require 'chef_zero/endpoints/policy_endpoint' +require 'chef_zero/endpoints/policy_revisions_endpoint' +require 'chef_zero/endpoints/policy_revision_endpoint' +require 'chef_zero/endpoints/policy_groups_endpoint' +require 'chef_zero/endpoints/policy_group_endpoint' +require 'chef_zero/endpoints/policy_group_policy_endpoint' require 'chef_zero/endpoints/principal_endpoint' require 'chef_zero/endpoints/role_endpoint' require 'chef_zero/endpoints/role_environments_endpoint' @@ -447,6 +452,24 @@ module ChefZero end end + if contents['policies'] + contents['policies'].each_pair do |policy_name, policy_struct| + # data_store.create_dir(['organizations', org_name, 'policies', policy_name], "revisions", :recursive) + dejsonize_children(policy_struct).each do |revision, policy_data| + data_store.set(['organizations', org_name, 'policies', policy_name, + "revisions", revision], policy_data, :create, :create_dir) + end + end + end + + if contents['policy_groups'] + contents['policy_groups'].each_pair do |group_name, group| + group['policies'].each do |policy_name, policy_revision| + data_store.set(['organizations', org_name, 'policy_groups', group_name, 'policies', policy_name], FFI_Yajl::Encoder.encode(policy_revision['revision_id'], :pretty => true), :create, :create_dir) + end + end + end + if contents['cookbooks'] contents['cookbooks'].each_pair do |name_version, cookbook| if name_version =~ /(.+)-(\d+\.\d+\.\d+)$/ @@ -549,13 +572,13 @@ module ChefZero [ "/organizations/*/nodes", NodesEndpoint.new(self) ], [ "/organizations/*/nodes/*", NodeEndpoint.new(self) ], [ "/organizations/*/nodes/*/_identifiers", NodeIdentifiersEndpoint.new(self) ], - [ "/organizations/*/policies", OrganizationPoliciesEndpoint.new(self) ], - [ "/organizations/*/policies/*", OrganizationPoliciesEndpoint.new(self) ], - [ "/organizations/*/policies/*/revisions", OrganizationPoliciesEndpoint.new(self) ], - [ "/organizations/*/policies/*/revisions/*", OrganizationPoliciesEndpoint.new(self) ], - [ "/organizations/*/policy_groups", OrganizationPolicyGroupsEndpoint.new(self) ], - [ "/organizations/*/policy_groups/*", OrganizationPolicyGroupsEndpoint.new(self) ], - [ "/organizations/*/policy_groups/*/policies/*", OrganizationPolicyGroupsEndpoint.new(self) ], + [ "/organizations/*/policies", PoliciesEndpoint.new(self) ], + [ "/organizations/*/policies/*", PolicyEndpoint.new(self) ], + [ "/organizations/*/policies/*/revisions", PolicyRevisionsEndpoint.new(self) ], + [ "/organizations/*/policies/*/revisions/*", PolicyRevisionEndpoint.new(self) ], + [ "/organizations/*/policy_groups", PolicyGroupsEndpoint.new(self) ], + [ "/organizations/*/policy_groups/*", PolicyGroupEndpoint.new(self) ], + [ "/organizations/*/policy_groups/*/policies/*", PolicyGroupPolicyEndpoint.new(self) ], [ "/organizations/*/principals/*", PrincipalEndpoint.new(self) ], [ "/organizations/*/roles", RestListEndpoint.new(self) ], [ "/organizations/*/roles/*", RoleEndpoint.new(self) ], |