anchor.diff:  %% @end
   -spec put_stream(ReqData::term(),State::term()) -> {boolean(), term(), term()}.
   put_stream(ReqData, State) ->
  -	VStreamId = proplists:get_value('id', wrq:path_info(ReqData)),
  -	{VStream,_,_} = api_help:json_handler(ReqData,State),
  -	Update = lib_json:set_attr(doc,VStream),
  -	case api_help:do_only_fields_exist(VStream,?ACCEPTED_FIELDS_VSTREAMS_UPDATE) of
  -		true-> 
  -			case api_help:update_doc(?INDEX, "virtual_stream", VStreamId, Update) of 
  -				{error, {Code, Body}} -> 
  -					ErrorString = api_help:generate_error(Body, Code),
  -					{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  -				{ok,List} -> 
  -					{true,wrq:set_resp_body(lib_json:encode(List),ReqData),State}
  -			end;
  -		false ->
  -			{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State}
  -	end.
  -
  +	case openidc:authenticate_request(ReqData) of
  +        {error, Msg} -> {{halt, 403}, wrq:set_resp_body(Msg, ReqData), State};
  +        {ok, Token} ->
  +			VStreamId = proplists:get_value('id', wrq:path_info(ReqData)),
  +			{VStream,_,_} = api_help:json_handler(ReqData,State),
  +			Update = lib_json:set_attr(doc,VStream),
  +			case api_help:do_only_fields_exist(VStream,?ACCEPTED_FIELDS_VSTREAMS_UPDATE) of
  +				true->
  +					case api_help:update_doc(?INDEX, "virtual_stream", VStreamId, Update) of
  +						{error, {Code, Body}} ->
  +							ErrorString = api_help:generate_error(Body, Code),
  +							{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  +						{ok,List} ->
  +							{true,wrq:set_resp_body(lib_json:encode(List),ReqData),State}
  +					end;
  +				false ->
  +					{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State}
  +			end
  +	end.
   
   %% @doc
   %% Function: delete_resource/2
  -%% Purpose: Used to handle DELETE requests for deleting the virtual stream and its 
  +%% Purpose: Used to handle DELETE requests for deleting the virtual stream and its
   %% vsdatapoints in elastic search
   %% Returns: {Success, ReqData, State}, where Success is true if delete is successful
   %% and false otherwise.
  
positive.code: %% and the statistical function, it executes a query and posts the vsdatapoints returned
  %% to the current virtual stream
  %% Returns: {true, ReqData, State} || {{error, Reason}, ReqData, State}
  -spec reduce(VirtualStreamId::string(), Streams::string(), TimestampFrom::string(), Function::string(), ReqData::tuple(), State::string()) -> 
  		  {true, tuple(), string()}.
  reduce(VirtualStreamId, Streams, TimestampFrom, Function, ReqData, State) ->
  	Query = create_query(Function, Streams, TimestampFrom),
  
negative.code: %% @end
  -spec delete_resource(ReqData::term(),State::term()) -> {boolean(), term(), term()}.
  delete_resource(ReqData, State) ->
  	case openidc:authenticate_request(ReqData) of
          {error, Msg} -> {{halt, 403}, wrq:set_resp_body(Msg, ReqData), State};
          {ok, Token} ->
  			case {proplists:get_value('id', wrq:path_info(ReqData))} of
  				{Id} ->
  					case streams:delete_data_points_with_stream_id(Id, "virtual_stream") of
  						{error, {Code, Body}} ->
  							ErrorString = api_help:generate_error(Body, Code),
  							{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  						{ok} ->
  							case erlastic_search:delete_doc(?INDEX,"virtual_stream", Id) of
  								{error, {Code, Body}} ->
  									ErrorString = api_help:generate_error(Body, Code),
  									{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  								{ok,List} ->
  									virtual_stream_process_supervisor:terminate_child(Id),
  									{true,wrq:set_resp_body(lib_json:encode(List),ReqData),State}
  							end
  					end
  			end
  	end
  
  
  %% @doc
  