anchor.diff:           forbidden/2,
            is_authorized/2,
            allowed_methods/2,
  -         delete_resource/2,
  -         from_json/2,
            to_json/2
          ]).
   
  
positive.code:     Json = ejson:encode(EJson),
      {Json, Req, State}.
  
  delete_resource(Req, #base_state{chef_db_context = DbContext,
                                   requestor_id = RequestorId,
                                   resource_state = #client_state{
                                     chef_client = Client},
                                   organization_name = OrgName} = State) ->
      ok = chef_object_db:delete(DbContext, Client, RequestorId),
      EJson = chef_client:assemble_client_ejson(Client, OrgName),
      Req1 = chef_wm_util:set_json_body(Req, EJson),
      {true, Req1, State}.
  
  % TODO: this could stand refactoring: I'm sure there is stuff re-used by other
  % endpoints and possibly unused code here
  error_message(Msg) when is_list(Msg) ->
      error_message(iolist_to_binary(Msg));
  error_message(Msg) when is_binary(Msg) ->
      {[{<<"error">>, [Msg]}]}.
  
  malformed_request_message(#ej_invalid{type = json_type, key = Key}, _Req, _State) ->
      case Key of
          undefined -> error_message([<<"Incorrect JSON type for request body">>]);
          _ ->error_message([<<"Incorrect JSON type for ">>, Key])
      end;
  malformed_request_message(#ej_invalid{type = missing, key = Key}, _Req, _State) ->
      error_message([<<"Required value for ">>, Key, <<" is missing">>]);
  malformed_request_message({invalid_key, Key}, _Req, _State) ->
      error_message([<<"Invalid key ">>, Key, <<" in request body">>]);
  malformed_request_message(invalid_json_body, _Req, _State) ->
      error_message([<<"Incorrect JSON type for request body">>]);
  malformed_request_message(#ej_invalid{type = exact, key = Key, msg = Expected},
                            _Req, _State) ->
      error_message([Key, <<" must equal ">>, Expected]);
  malformed_request_message(#ej_invalid{type = string_match, msg = Error},
                            _Req, _State) ->
      error_message([Error]);
  malformed_request_message(#ej_invalid{type = object_key, key = Object, found = Key},
                            _Req, _State) ->
      error_message([<<"Invalid key '">>, Key, <<"' for ">>, Object]);
  % TODO: next two tests can get merged (hopefully) when object_map is extended not
  % to swallow keys
  malformed_request_message(#ej_invalid{type = object_value, key = Object, found = Val},
                            _Req, _State) when is_binary(Val) ->
      error_message([<<"Invalid value '">>, Val, <<"' for ">>, Object]);
  malformed_request_message(#ej_invalid{type = object_value, key = Object, found = Val},
                            _Req, _State) ->
      error_message([<<"Invalid value '">>, io_lib:format("~p", [Val]),
                     <<"' for ">>, Object]);
  malformed_request_message(Any, _Req, _State) ->
      error({unexpected_malformed_request_message, Any}).
  
  
negative.code: %%
  
  
  -module(chef_wm_named_pubkey).
  
  -include("chef_wm.hrl").
  
  