Class: ChefZero::Endpoints::NodeEndpoint
- Inherits:
-
RestObjectEndpoint
- Object
- RestBase
- RestObjectEndpoint
- ChefZero::Endpoints::NodeEndpoint
- Defined in:
- lib/chef_zero/endpoints/node_endpoint.rb
Overview
/nodes/ID
Constant Summary
Constants inherited from RestBase
RestBase::DEFAULT_REQUEST_VERSION, RestBase::DEFAULT_RESPONSE_VERSION
Instance Attribute Summary
Attributes inherited from RestObjectEndpoint
Attributes inherited from RestBase
Instance Method Summary collapse
Methods inherited from RestObjectEndpoint
#delete, #get, #initialize, #patch_request_body
Methods inherited from RestBase
#accepts?, #already_json_response, #build_uri, build_uri, #call, #check_api_version, #create_data, #create_data_dir, #data_store, #delete_data, #delete_data_dir, #error, #exists_data?, #exists_data_dir?, #get_data, #get_data_or_else, #hashify_list, #head_request, #initialize, #json_only, #json_response, #list_data, #list_data_or_else, #parse_json, #policy_name_invalid?, rfc2396_parser, #set_data, #text_response, #to_json
Constructor Details
This class inherits a constructor from ChefZero::Endpoints::RestObjectEndpoint
Instance Method Details
#head(request) ⇒ Object
23 24 25 |
# File 'lib/chef_zero/endpoints/node_endpoint.rb', line 23 def head(request) head_request(request) end |
#populate_defaults(request, response_json) ⇒ Object
27 28 29 30 31 |
# File 'lib/chef_zero/endpoints/node_endpoint.rb', line 27 def populate_defaults(request, response_json) node = FFI_Yajl::Parser.parse(response_json) node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3]) FFI_Yajl::Encoder.encode(node, pretty: true) end |
#put(request) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/chef_zero/endpoints/node_endpoint.rb', line 9 def put(request) data = parse_json(request.body) if data.key?("policy_name") && policy_name_invalid?(data["policy_name"]) return error(400, "Field 'policy_name' invalid", pretty: false) end if data.key?("policy_group") && policy_name_invalid?(data["policy_group"]) return error(400, "Field 'policy_group' invalid", pretty: false) end super(request) end |