diff options
Diffstat (limited to 'lib/chef/api_client.rb')
-rw-r--r-- | lib/chef/api_client.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index 334fb23f38..ce9ceb312c 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -96,7 +96,7 @@ class Chef set_or_return( :private_key, arg, - :kind_of => String + :kind_of => [String, FalseClass] ) end @@ -124,7 +124,7 @@ class Chef Chef::JSONCompat.to_json(to_hash, *a) end - def self.json_create(o) + def self.from_hash(o) client = Chef::ApiClient.new client.name(o["name"] || o["clientname"]) client.private_key(o["private_key"]) if o.key?("private_key") @@ -134,6 +134,14 @@ class Chef client end + def self.json_create(data) + from_hash(data) + end + + def self.from_json(j) + from_hash(Chef::JSONCompat.parse(j)) + end + def self.http_api Chef::REST.new(Chef::Config[:chef_server_url]) end |