Method: Chef::ApiClientV1#update
- Defined in:
- lib/chef/api_client_v1.rb
#update ⇒ Object
Updates the client via the REST API
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/chef/api_client_v1.rb', line 257 def update # NOTE: API V1 dropped support for updating client keys via update (aka PUT), # but this code never supported key updating in the first place. Since # it was never implemented, we will simply ignore that functionality # as it is being deprecated. # Delete this comment after V0 support is dropped. payload = { name: name } payload[:validator] = validator unless validator.nil? # DEPRECATION # This field is ignored in API V1, but left for backwards-compat, # can remove after API V0 is no longer supported. payload[:admin] = admin unless admin.nil? begin new_client = chef_rest_v1.put("clients/#{name}", payload) rescue Net::HTTPClientException => e # rescue API V0 if 406 and the server supports V0 supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS) raise e unless supported_versions && supported_versions.include?(0) new_client = chef_rest_v0.put("clients/#{name}", payload) end Chef::ApiClientV1.from_hash(new_client) end |