diff options
author | John Keiser <jkeiser@opscode.com> | 2014-08-21 19:56:36 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-08-22 09:20:51 -0700 |
commit | 12e86dc79d609953f5a548cb7adb7ca995c67d23 (patch) | |
tree | ff6b90ac9d40309dbc04e7355996796ddbee9797 /lib/chef_zero/endpoints | |
parent | 0be3f9aea877bf4052ab79933180cb3f281a1e19 (diff) | |
download | chef-zero-12e86dc79d609953f5a548cb7adb7ca995c67d23.tar.gz |
Move CookbookData and DataNormalizer under ChefData
Diffstat (limited to 'lib/chef_zero/endpoints')
18 files changed, 35 insertions, 35 deletions
diff --git a/lib/chef_zero/endpoints/acls_endpoint.rb b/lib/chef_zero/endpoints/acls_endpoint.rb index e62fd36..d05abe5 100644 --- a/lib/chef_zero/endpoints/acls_endpoint.rb +++ b/lib/chef_zero/endpoints/acls_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/rest_base' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' require 'chef_zero/chef_data/acl_path' module ChefZero @@ -21,7 +21,7 @@ module ChefZero raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}") end acls = JSON.parse(get_data(request, acl_path), :create_additions => false) - acls = DataNormalizer.normalize_acls(acls) + acls = ChefData::DataNormalizer.normalize_acls(acls) json_response(200, acls) end end diff --git a/lib/chef_zero/endpoints/actor_endpoint.rb b/lib/chef_zero/endpoints/actor_endpoint.rb index ded6530..7b098ff 100644 --- a/lib/chef_zero/endpoints/actor_endpoint.rb +++ b/lib/chef_zero/endpoints/actor_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -77,9 +77,9 @@ module ChefZero def populate_defaults(request, response_json) response = JSON.parse(response_json, :create_additions => false) if request.rest_path[2] == 'clients' - response = DataNormalizer.normalize_client(response, request.rest_path[3]) + response = ChefData::DataNormalizer.normalize_client(response, request.rest_path[3]) else - response = DataNormalizer.normalize_user(response, request.rest_path[3], identity_keys, server.options[:osc_compat], request.method) + response = ChefData::DataNormalizer.normalize_user(response, request.rest_path[3], identity_keys, server.options[:osc_compat], request.method) end JSON.pretty_generate(response) end diff --git a/lib/chef_zero/endpoints/actors_endpoint.rb b/lib/chef_zero/endpoints/actors_endpoint.rb index 55dac80..90a53d8 100644 --- a/lib/chef_zero/endpoints/actors_endpoint.rb +++ b/lib/chef_zero/endpoints/actors_endpoint.rb @@ -27,7 +27,7 @@ module ChefZero record = get_data(request, request.rest_path + [ name ], :nil) if record record = JSON.parse(record, :create_additions => false) - record = DataNormalizer.normalize_user(record, name, identity_keys, server.options[:osc_compat]) + record = ChefData::DataNormalizer.normalize_user(record, name, identity_keys, server.options[:osc_compat]) results[name] = record end end diff --git a/lib/chef_zero/endpoints/authenticate_user_endpoint.rb b/lib/chef_zero/endpoints/authenticate_user_endpoint.rb index 98dbf04..76751d8 100644 --- a/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +++ b/lib/chef_zero/endpoints/authenticate_user_endpoint.rb @@ -15,7 +15,7 @@ module ChefZero raise RestErrorResponse.new(401, "Bad username or password") end user = JSON.parse(user, :create_additions => false) - user = DataNormalizer.normalize_user(user, name, [ 'username' ], server.options[:osc_compat]) + user = ChefData::DataNormalizer.normalize_user(user, name, [ 'username' ], server.options[:osc_compat]) if user['password'] != password raise RestErrorResponse.new(401, "Bad username or password") end diff --git a/lib/chef_zero/endpoints/container_endpoint.rb b/lib/chef_zero/endpoints/container_endpoint.rb index edb6a7f..e2bb000 100644 --- a/lib/chef_zero/endpoints/container_endpoint.rb +++ b/lib/chef_zero/endpoints/container_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -14,7 +14,7 @@ module ChefZero def populate_defaults(request, response_json) container = JSON.parse(response_json, :create_additions => false) - container = DataNormalizer.normalize_container(container, request.rest_path[3]) + container = ChefData::DataNormalizer.normalize_container(container, request.rest_path[3]) JSON.pretty_generate(container) end end diff --git a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb index 098c6c6..db33d12 100644 --- a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +++ b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb @@ -1,7 +1,7 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' require 'chef_zero/rest_error_response' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' require 'chef_zero/data_store/data_not_found_error' module ChefZero @@ -106,7 +106,7 @@ module ChefZero def populate_defaults(request, response_json) # Inject URIs into each cookbook file cookbook = JSON.parse(response_json, :create_additions => false) - cookbook = DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, request.rest_path[3], request.rest_path[4], request.base_uri, request.method) + cookbook = ChefData::DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, request.rest_path[3], request.rest_path[4], request.base_uri, request.method) JSON.pretty_generate(cookbook) end diff --git a/lib/chef_zero/endpoints/cookbooks_base.rb b/lib/chef_zero/endpoints/cookbooks_base.rb index ccc89ab..76a4914 100644 --- a/lib/chef_zero/endpoints/cookbooks_base.rb +++ b/lib/chef_zero/endpoints/cookbooks_base.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/rest_base' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints diff --git a/lib/chef_zero/endpoints/data_bag_item_endpoint.rb b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb index b92fe92..1ab8793 100644 --- a/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +++ b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb @@ -1,7 +1,7 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' require 'chef_zero/endpoints/data_bag_item_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -17,7 +17,7 @@ module ChefZero def self.populate_defaults(request, response_json, data_bag, data_bag_item) response = JSON.parse(response_json, :create_additions => false) - response = DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method) + response = ChefData::DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method) JSON.pretty_generate(response) end end diff --git a/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb b/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb index d6e1a80..ae4a85a 100644 --- a/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +++ b/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb @@ -49,7 +49,7 @@ module ChefZero result = {} solved.each_pair do |name, versions| cookbook = JSON.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false) - result[name] = DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, name, versions[0], request.base_uri, 'MIN') + result[name] = ChefData::DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, name, versions[0], request.base_uri, 'MIN') end json_response(200, result) end diff --git a/lib/chef_zero/endpoints/environment_endpoint.rb b/lib/chef_zero/endpoints/environment_endpoint.rb index d792b98..74a175b 100644 --- a/lib/chef_zero/endpoints/environment_endpoint.rb +++ b/lib/chef_zero/endpoints/environment_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -25,7 +25,7 @@ module ChefZero def populate_defaults(request, response_json) response = JSON.parse(response_json, :create_additions => false) - response = DataNormalizer.normalize_environment(response, request.rest_path[3]) + response = ChefData::DataNormalizer.normalize_environment(response, request.rest_path[3]) JSON.pretty_generate(response) end end diff --git a/lib/chef_zero/endpoints/group_endpoint.rb b/lib/chef_zero/endpoints/group_endpoint.rb index 74d55f6..48f05cd 100644 --- a/lib/chef_zero/endpoints/group_endpoint.rb +++ b/lib/chef_zero/endpoints/group_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -12,7 +12,7 @@ module ChefZero def populate_defaults(request, response_json) group = JSON.parse(response_json, :create_additions => false) - group = DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1]) + group = ChefData::DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1]) JSON.pretty_generate(group) end end diff --git a/lib/chef_zero/endpoints/node_endpoint.rb b/lib/chef_zero/endpoints/node_endpoint.rb index 5c35e0c..c87e658 100644 --- a/lib/chef_zero/endpoints/node_endpoint.rb +++ b/lib/chef_zero/endpoints/node_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -8,7 +8,7 @@ module ChefZero class NodeEndpoint < RestObjectEndpoint def populate_defaults(request, response_json) node = JSON.parse(response_json, :create_additions => false) - node = DataNormalizer.normalize_node(node, request.rest_path[3]) + node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3]) JSON.pretty_generate(node) end end diff --git a/lib/chef_zero/endpoints/organization_endpoint.rb b/lib/chef_zero/endpoints/organization_endpoint.rb index b33b105..4a0bcad 100644 --- a/lib/chef_zero/endpoints/organization_endpoint.rb +++ b/lib/chef_zero/endpoints/organization_endpoint.rb @@ -33,7 +33,7 @@ module ChefZero def populate_defaults(request, response_json) org = JSON.parse(response_json, :create_additions => false) - org = DataNormalizer.normalize_organization(org, request.rest_path[1]) + org = ChefData::DataNormalizer.normalize_organization(org, request.rest_path[1]) JSON.pretty_generate(org) end end diff --git a/lib/chef_zero/endpoints/organization_user_endpoint.rb b/lib/chef_zero/endpoints/organization_user_endpoint.rb index 368a068..c7b4817 100644 --- a/lib/chef_zero/endpoints/organization_user_endpoint.rb +++ b/lib/chef_zero/endpoints/organization_user_endpoint.rb @@ -10,14 +10,14 @@ module ChefZero get_data(request) # 404 if user is not in org user = get_data(request, [ 'users', username ]) user = JSON.parse(user, :create_additions => false) - json_response(200, DataNormalizer.normalize_user(user, username, ['username'], server.options[:osc_compat], request.method)) + json_response(200, ChefData::DataNormalizer.normalize_user(user, username, ['username'], server.options[:osc_compat], request.method)) end def delete(request) user = get_data(request) delete_data(request) user = JSON.parse(user, :create_additions => false) - json_response(200, DataNormalizer.normalize_user(user, request.rest_path[3], ['username'], server.options[:osc_compat])) + json_response(200, ChefData::DataNormalizer.normalize_user(user, request.rest_path[3], ['username'], server.options[:osc_compat])) end end end diff --git a/lib/chef_zero/endpoints/role_endpoint.rb b/lib/chef_zero/endpoints/role_endpoint.rb index 5b7a1b3..6cf91c8 100644 --- a/lib/chef_zero/endpoints/role_endpoint.rb +++ b/lib/chef_zero/endpoints/role_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints @@ -8,7 +8,7 @@ module ChefZero class RoleEndpoint < RestObjectEndpoint def populate_defaults(request, response_json) role = JSON.parse(response_json, :create_additions => false) - role = DataNormalizer.normalize_role(role, request.rest_path[3]) + role = ChefData::DataNormalizer.normalize_role(role, request.rest_path[3]) JSON.pretty_generate(role) end end diff --git a/lib/chef_zero/endpoints/search_endpoint.rb b/lib/chef_zero/endpoints/search_endpoint.rb index 73c44b0..db29f7c 100644 --- a/lib/chef_zero/endpoints/search_endpoint.rb +++ b/lib/chef_zero/endpoints/search_endpoint.rb @@ -1,6 +1,6 @@ require 'json' require 'chef_zero/endpoints/rest_object_endpoint' -require 'chef_zero/data_normalizer' +require 'chef_zero/chef_data/data_normalizer' require 'chef_zero/rest_error_response' require 'chef_zero/solr/solr_parser' require 'chef_zero/solr/solr_doc' @@ -48,15 +48,15 @@ module ChefZero def search_container(request, index) relative_parts, normalize_proc = case index when 'client' - [ ['clients'], Proc.new { |client, name| DataNormalizer.normalize_client(client, name) } ] + [ ['clients'], Proc.new { |client, name| ChefData::DataNormalizer.normalize_client(client, name) } ] when 'node' - [ ['nodes'], Proc.new { |node, name| DataNormalizer.normalize_node(node, name) } ] + [ ['nodes'], Proc.new { |node, name| ChefData::DataNormalizer.normalize_node(node, name) } ] when 'environment' - [ ['environments'], Proc.new { |environment, name| DataNormalizer.normalize_environment(environment, name) } ] + [ ['environments'], Proc.new { |environment, name| ChefData::DataNormalizer.normalize_environment(environment, name) } ] when 'role' - [ ['roles'], Proc.new { |role, name| DataNormalizer.normalize_role(role, name) } ] + [ ['roles'], Proc.new { |role, name| ChefData::DataNormalizer.normalize_role(role, name) } ] else - [ ['data', index], Proc.new { |data_bag_item, id| DataNormalizer.normalize_data_bag_item(data_bag_item, index, id, 'DELETE') } ] + [ ['data', index], Proc.new { |data_bag_item, id| ChefData::DataNormalizer.normalize_data_bag_item(data_bag_item, index, id, 'DELETE') } ] end [ request.rest_path[0..1] + relative_parts, @@ -86,7 +86,7 @@ module ChefZero result elsif !%w(client environment role).include?(index) - DataNormalizer.normalize_data_bag_item(value, index, id, 'GET') + ChefData::DataNormalizer.normalize_data_bag_item(value, index, id, 'GET') else value end diff --git a/lib/chef_zero/endpoints/system_recovery_endpoint.rb b/lib/chef_zero/endpoints/system_recovery_endpoint.rb index 125643b..a3c62fa 100644 --- a/lib/chef_zero/endpoints/system_recovery_endpoint.rb +++ b/lib/chef_zero/endpoints/system_recovery_endpoint.rb @@ -15,7 +15,7 @@ module ChefZero end user = JSON.parse(user, :create_additions => false) - user = DataNormalizer.normalize_user(user, name, [ 'username' ], server.options[:osc_compat]) + user = ChefData::DataNormalizer.normalize_user(user, name, [ 'username' ], server.options[:osc_compat]) if !user['recovery_authentication_enabled'] raise RestErrorResponse.new(403, "Only users with recovery_authentication_enabled=true may use /system_recovery to log in") end diff --git a/lib/chef_zero/endpoints/user_organizations_endpoint.rb b/lib/chef_zero/endpoints/user_organizations_endpoint.rb index aa5034c..98824d6 100644 --- a/lib/chef_zero/endpoints/user_organizations_endpoint.rb +++ b/lib/chef_zero/endpoints/user_organizations_endpoint.rb @@ -13,7 +13,7 @@ module ChefZero result = result.map do |orgname| org = get_data(request, [ 'organizations', orgname, 'org' ]) org = JSON.parse(org, :create_additions => false) - DataNormalizer.normalize_organization(org, orgname) + ChefData::DataNormalizer.normalize_organization(org, orgname) end json_response(200, result) end |