anchor.diff:  	end.
   
   
  +%% @doc
  +%% Function: id_from_path/2
  +%% Purpose: Retrieves the id from the path.
  +%% Returns: Id
  +%% @end
  +-spec id_from_path(string()) -> string().
  +id_from_path(RD) ->
  +    case wrq:path_info(id, RD) of
  +        undefined ->
  +            case string:tokens(wrq:disp_path(RD), "/") of
  +                ["vstreams", Id] -> Id;
  +                _ -> undefined
  +            end;
  +        Id -> Id
  +    end.
  +
   
   %% @doc
   %% Function: msToDate/3
  
positive.code: %% @end
  -spec content_types_provided(ReqData::tuple(), State::string()) -> {list(), tuple(), string()}.
  content_types_provided(ReqData, State) ->
  		{[{"application/json", get_datapoint}], ReqData, State}.
  
  
  %% @doc
  
negative.code: 
   
  %% @doc
  %% Function: get_vstream/2
  %% Purpose: Used to handle GET requests by giving the document with the given
  %% Id or listing the documents that can be found from the restrictions
  %% given by the URI.
  %% Returns: {Success, ReqData, State}, where Success is true if the PUT request is
  %% successful and false otherwise.
  %% @end
  -spec get_vstream(ReqData::term(),State::term()) -> {boolean(), term(), term()}.
  get_vstream(ReqData, State) ->
  	case id_from_path(ReqData) of
                  undefined ->
                      % Get all vstreams
                      case wrq:get_qs_value("size",ReqData) of 
                          undefined ->
                              Size = 100;
                          SizeParam ->
                              Size = list_to_integer(SizeParam)
                      end,
  					Query = "{\"size\" :" ++ integer_to_list(Size) ++",\"query\" : {\"match_all\" : {}},\"filter\" : {\"bool\":{\"must_not\":{\"term\":{\"private\":\"true\"}}}}}",
  					case erlastic_search:search_json(#erls_params{},?INDEX, "virtual_stream", Query) of
                          {error, {Code, Body}} -> 
                              ErrorString = api_help:generate_error(Body, Code),
                              {{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  					    {ok,JsonStruct} ->
  						    FinalJson = lib_json:get_list_and_add_id(JsonStruct, users),
  						    {FinalJson, ReqData, State}  
                      end;
                  Id ->
  				    %% Get specific virtual stream
                      case erlastic_search:get_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,JsonStruct} ->
                              FinalJson = lib_json:get_and_add_id(JsonStruct),
                              {FinalJson, ReqData, State} 
                      end
              end.
  
  	
  %% @doc
  %% Function: put_stream/2
  %% Purpose: Used to handle PUT requests by updating the given documents in elastic search
  %% Returns: {Success, ReqData, State}, where Success is true if the PUT request is
  