summaryrefslogtreecommitdiff
path: root/lib/chef/api_client.rb
diff options
context:
space:
mode:
authortylercloke <tylercloke@gmail.com>2015-06-02 16:54:21 -0700
committertylercloke <tylercloke@gmail.com>2015-06-05 10:38:49 -0700
commit4f2400c8cce57e68f14cb9d4b756ab82b23dd69d (patch)
tree836ac3d3f71ec2ab234f975d2ed2f4fad93e94a5 /lib/chef/api_client.rb
parenteb49eedb6333bc1c6b82d0c7befffb9188c5b523 (diff)
downloadchef-4f2400c8cce57e68f14cb9d4b756ab82b23dd69d.tar.gz
Backwards compatible support for OSC 11 in knife user commands.
All knife user commands can detect when they have failed for OSC 11 reasons and forward the request to backwards compatible knife osc_user commands.
Diffstat (limited to 'lib/chef/api_client.rb')
-rw-r--r--lib/chef/api_client.rb23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index d486cc9808..3b777b3574 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Nuo Yan (<nuo@chef.io>)
-# Copyright:: Copyright (c) 2015 Chef Software, Inc.
+# Copyright:: Copyright (c) 2008, 2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,10 +54,12 @@ class Chef
@chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "1"})
end
+ # will default to the current version (Chef::Authenticator::DEFAULT_SERVER_API_VERSION)
def http_api
@http_api ||= Chef::REST.new(Chef::Config[:chef_server_url])
end
+ # will default to the current version (Chef::Authenticator::DEFAULT_SERVER_API_VERSION)
def self.http_api
Chef::REST.new(Chef::Config[:chef_server_url])
end
@@ -304,15 +306,15 @@ class Chef
new_client.delete('chef_key')
end
- rescue Net::HTTPServerException => e
- # rescue API V0 if 406 and the server supports V0
- raise e unless handle_version_http_exception(e, SUPPORTED_API_VERSIONS[0], SUPPORTED_API_VERSIONS[-1])
+ rescue Net::HTTPServerException => e
+ # rescue API V0 if 406 and the server supports V0
+ raise e unless handle_version_http_exception(e, SUPPORTED_API_VERSIONS[0], SUPPORTED_API_VERSIONS[-1])
- # under API V0, a key pair will always be created unless public_key is
- # passed on initial POST
- payload[:public_key] = public_key unless public_key.nil?
+ # under API V0, a key pair will always be created unless public_key is
+ # passed on initial POST
+ payload[:public_key] = public_key unless public_key.nil?
- new_client = chef_rest_v0.post("clients", payload)
+ new_client = chef_rest_v0.post("clients", payload)
end
Chef::ApiClient.from_hash(self.to_hash.merge(new_client))
end
@@ -322,10 +324,5 @@ class Chef
"client[#{@name}]"
end
- # def inspect
- # "Chef::ApiClient name:'#{name}' admin:'#{admin.inspect}' validator:'#{validator}' " +
- # "public_key:'#{public_key}' private_key:'#{private_key}'"
- # end
-
end
end