diff options
Diffstat (limited to 'lib/chef/api_client.rb')
-rw-r--r-- | lib/chef/api_client.rb | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index 3c1ef7a2b6..656a0e364f 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -47,7 +47,7 @@ class Chef # Gets or sets the client name. # - # @params [Optional String] The name must be alpha-numeric plus - and _. + # @param [Optional String] The name must be alpha-numeric plus - and _. # @return [String] The current value of the name. def name(arg = nil) set_or_return( @@ -59,7 +59,7 @@ class Chef # Gets or sets whether this client is an admin. # - # @params [Optional True/False] Should be true or false - default is false. + # @param [Optional True/False] Should be true or false - default is false. # @return [True/False] The current value def admin(arg = nil) set_or_return( @@ -71,7 +71,7 @@ class Chef # Gets or sets the public key. # - # @params [Optional String] The string representation of the public key. + # @param [Optional String] The string representation of the public key. # @return [String] The current value. def public_key(arg = nil) set_or_return( @@ -83,7 +83,7 @@ class Chef # Gets or sets whether this client is a validator. # - # @params [Boolean] whether or not the client is a validator. If + # @param [Boolean] arg whether or not the client is a validator. If # `nil`, retrieves the already-set value. # @return [Boolean] The current value def validator(arg = nil) @@ -96,7 +96,7 @@ class Chef # Gets or sets the private key. # - # @params [Optional String] The string representation of the private key. + # @param [Optional String] The string representation of the private key. # @return [String] The current value. def private_key(arg = nil) set_or_return( @@ -140,11 +140,6 @@ class Chef client end - def self.json_create(data) - Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::ApiClient#from_hash") - from_hash(data) - end - def self.from_json(j) from_hash(Chef::JSONCompat.parse(j)) end @@ -162,7 +157,7 @@ class Chef if inflate response = Hash.new Chef::Search::Query.new.search(:client) do |n| - n = self.json_create(n) if n.instance_of?(Hash) + n = json_create(n) if n.instance_of?(Hash) response[n.name] = n end response @@ -188,15 +183,13 @@ class Chef # Save this client via the REST API, returns a hash including the private key def save - begin - http_api.put("clients/#{name}", { :name => self.name, :admin => self.admin, :validator => self.validator }) - rescue Net::HTTPServerException => e - # If that fails, go ahead and try and update it - if e.response.code == "404" - http_api.post("clients", { :name => self.name, :admin => self.admin, :validator => self.validator }) - else - raise e - end + http_api.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator }) + rescue Net::HTTPServerException => e + # If that fails, go ahead and try and update it + if e.response.code == "404" + http_api.post("clients", { :name => name, :admin => admin, :validator => validator }) + else + raise e end end |