diff options
author | tylercloke <tylercloke@gmail.com> | 2015-06-03 13:21:50 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-06-05 10:38:49 -0700 |
commit | eb49eedb6333bc1c6b82d0c7befffb9188c5b523 (patch) | |
tree | 50272e378ea73a4692dc5b9c160a0a1fb5d1f98c /lib | |
parent | a929c389252d5da4c3ddc2f0cce10e43e6dc19ab (diff) | |
download | chef-eb49eedb6333bc1c6b82d0c7befffb9188c5b523.tar.gz |
Use Chef::ServerAPI to create versioned API requests in Chef::(User|Client).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/api_client.rb | 7 | ||||
-rw-r--r-- | lib/chef/user.rb | 7 | ||||
-rw-r--r-- | lib/chef/versioned_rest.rb | 27 |
3 files changed, 6 insertions, 35 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index 383095b273..d486cc9808 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -24,15 +24,14 @@ require 'chef/mash' require 'chef/json_compat' require 'chef/search/query' require 'chef/exceptions' -require 'chef/versioned_rest' require 'chef/mixin/api_version_request_handling' +require 'chef/server_api' class Chef class ApiClient include Chef::Mixin::FromFile include Chef::Mixin::ParamsValidate - include Chef::VersionedRest include Chef::ApiVersionRequestHandling SUPPORTED_API_VERSIONS = [0,1] @@ -48,11 +47,11 @@ class Chef end def chef_rest_v0 - @chef_rest_v0 ||= get_versioned_rest_object(Chef::Config[:chef_server_url], "0") + @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}) end def chef_rest_v1 - @chef_rest_v1 ||= get_versioned_rest_object(Chef::Config[:chef_server_url], "1") + @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "1"}) end def http_api diff --git a/lib/chef/user.rb b/lib/chef/user.rb index 0ec7e87ed3..2ffba18005 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -21,16 +21,15 @@ require 'chef/mixin/from_file' require 'chef/mash' require 'chef/json_compat' require 'chef/search/query' -require 'chef/versioned_rest' require 'chef/mixin/api_version_request_handling' require 'chef/exceptions' +require 'chef/server_api' class Chef class User include Chef::Mixin::FromFile include Chef::Mixin::ParamsValidate - include Chef::VersionedRest include Chef::ApiVersionRequestHandling SUPPORTED_API_VERSIONS = [0,1] @@ -50,11 +49,11 @@ class Chef end def chef_root_rest_v0 - @chef_root_rest_v0 ||= get_versioned_rest_object(Chef::Config[:chef_server_root], "0") + @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], {:api_version => "0"}) end def chef_root_rest_v1 - @chef_root_rest_v1 ||= get_versioned_rest_object(Chef::Config[:chef_server_root], "1") + @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], {:api_version => "1"}) end def username(arg=nil) diff --git a/lib/chef/versioned_rest.rb b/lib/chef/versioned_rest.rb deleted file mode 100644 index b37a7e2249..0000000000 --- a/lib/chef/versioned_rest.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# Author:: Tyler Cloke (tyler@chef.io) -# Copyright:: Copyright 2015 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module VersionedRest - # Helper for getting a sane interface to passing an API version to Chef::REST - # api_version should be a string of an integer - def get_versioned_rest_object(url, api_version) - Chef::REST.new(url, Chef::Config[:node_name], Chef::Config[:client_key], {:api_version => api_version}) - end - end -end |