summaryrefslogtreecommitdiff
path: root/lib/chef/search
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2015-12-02 12:19:33 +0000
committerThom May <thom@chef.io>2016-01-11 15:40:42 +0000
commitd99e306a41b1402209d320cb7119b12a3bbb962f (patch)
treef65940702826deb991e6198967d3e9e96cb2857a /lib/chef/search
parent1b71aeb423b009f6d1a44215c89e9976957b47e9 (diff)
downloadchef-d99e306a41b1402209d320cb7119b12a3bbb962f.tar.gz
Convert all uses of Chef::REST to Chef::ServerAPItm/no_more_rest
In the process, stop auto-expanding JSON in the HTTP client, and let individual classes control that themselves. Fixes #2737, Fixes #3518
Diffstat (limited to 'lib/chef/search')
-rw-r--r--lib/chef/search/query.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index 658af8779c..c5c6bc6ce0 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -18,7 +18,7 @@
require 'chef/config'
require 'chef/exceptions'
-require 'chef/rest'
+require 'chef/server_api'
require 'uri'
@@ -35,7 +35,7 @@ class Chef
end
def rest
- @rest ||= Chef::REST.new(@url || @config[:chef_server_url])
+ @rest ||= Chef::ServerAPI.new(@url || @config[:chef_server_url])
end
# Backwards compatability for cookbooks.
@@ -150,12 +150,26 @@ WARNDEP
query_string = create_query_string(type, query, rows, start, sort)
if filter_result
- response = rest.post_rest(query_string, filter_result)
+ response = rest.post(query_string, filter_result)
# response returns rows in the format of
# { "url" => url_to_node, "data" => filter_result_hash }
response['rows'].map! { |row| row['data'] }
else
- response = rest.get_rest(query_string)
+ response = rest.get(query_string)
+ response['rows'].map! do |row|
+ case type.to_s
+ when 'node'
+ Chef::Node.from_hash(row)
+ when 'role'
+ Chef::Role.from_hash(row)
+ when 'environment'
+ Chef::Environment.from_hash(row)
+ when 'client'
+ Chef::ApiClient.from_hash(row)
+ else
+ Chef::DataBagItem.from_hash(row)
+ end
+ end
end
response