diff options
author | Thom May <thom@chef.io> | 2015-12-02 12:19:33 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-11 15:40:42 +0000 |
commit | d99e306a41b1402209d320cb7119b12a3bbb962f (patch) | |
tree | f65940702826deb991e6198967d3e9e96cb2857a /lib/chef/environment.rb | |
parent | 1b71aeb423b009f6d1a44215c89e9976957b47e9 (diff) | |
download | chef-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/environment.rb')
-rw-r--r-- | lib/chef/environment.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index 7d4b410639..5612978a08 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -24,6 +24,7 @@ require 'chef/mash' require 'chef/mixin/params_validate' require 'chef/mixin/from_file' require 'chef/version_constraint' +require 'chef/server_api' class Chef class Environment @@ -47,11 +48,11 @@ class Chef end def chef_server_rest - @chef_server_rest ||= Chef::REST.new(Chef::Config[:chef_server_url]) + @chef_server_rest ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url]) end def self.chef_server_rest - Chef::REST.new(Chef::Config[:chef_server_url]) + Chef::ServerAPI.new(Chef::Config[:chef_server_url]) end def name(arg=nil) @@ -216,6 +217,10 @@ class Chef end def self.json_create(o) + from_hash(o) + end + + def self.from_hash(o) environment = new environment.name(o["name"]) environment.description(o["description"]) @@ -233,7 +238,7 @@ class Chef end response else - chef_server_rest.get_rest("environments") + chef_server_rest.get("environments") end end @@ -241,7 +246,7 @@ class Chef if Chef::Config[:solo] load_from_file(name) else - chef_server_rest.get_rest("environments/#{name}") + chef_server_rest.get("environments/#{name}") end end @@ -267,26 +272,26 @@ class Chef end def destroy - chef_server_rest.delete_rest("environments/#{@name}") + chef_server_rest.delete("environments/#{@name}") end def save begin - chef_server_rest.put_rest("environments/#{@name}", self) + chef_server_rest.put("environments/#{@name}", self) rescue Net::HTTPServerException => e raise e unless e.response.code == "404" - chef_server_rest.post_rest("environments", self) + chef_server_rest.post("environments", self) end self end def create - chef_server_rest.post_rest("environments", self) + chef_server_rest.post("environments", self) self end def self.load_filtered_recipe_list(environment) - chef_server_rest.get_rest("environments/#{environment}/recipes") + chef_server_rest.get("environments/#{environment}/recipes") end def to_s |