/*
 * Copyright 2015-2016 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.hod.client.api.queryprofile;

import com.hp.autonomy.hod.client.api.authentication.AuthenticationToken;
import com.hp.autonomy.hod.client.api.resource.ResourceIdentifier;
import com.hp.autonomy.hod.client.error.HodErrorException;
import retrofit.client.Response;
import retrofit.http.DELETE;
import retrofit.http.GET;
import retrofit.http.Header;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.PUT;
import retrofit.http.Part;
import retrofit.http.PartMap;
import retrofit.http.Path;

import java.util.Map;

interface QueryProfileBackend {

    String PROFILE_VARIABLE = "query_profile";
    String INDEX_PART = "query_manipulation_index";
    String URL = "/2/api/sync/queryprofile/{" + PROFILE_VARIABLE +"}/v1";
    String TOKEN_HEADER = "token";

    @POST(URL)
    @Multipart
    Response createQueryProfile(
        @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token,
        @Path(PROFILE_VARIABLE) String name,
        @Part(INDEX_PART) String queryManipulationIndex,
        @PartMap Map<String, Object> params
    ) throws HodErrorException;

    @GET(URL)
    Response retrieveQueryProfile(
        @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token,
        @Path(PROFILE_VARIABLE) ResourceIdentifier queryProfile
    ) throws HodErrorException;

    @PUT(URL)
    @Multipart
    Response updateQueryProfile(
        @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token,
        @Path(PROFILE_VARIABLE) ResourceIdentifier queryProfile,
        @Part(INDEX_PART) String queryManipulationIndex,
        @PartMap Map<String, Object> params
    ) throws HodErrorException;

    @DELETE(URL)
    Response deleteQueryProfile(
        @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token,
        @Path(PROFILE_VARIABLE) ResourceIdentifier queryProfile
    ) throws HodErrorException;

}

@@ -948,13 +948,57 @@
 LE +
-%22%7D/v1
+ '%7D';%0A    String V1 = %22/v1%22;%0A    String V2 = %22/v2
 %22;%0A 
@@ -1041,24 +1041,29 @@
    @POST(URL
+ + V2
 )%0A    @Multi
@@ -1350,24 +1350,29 @@
     @GET(URL
+ + V1
 )%0A    Respon
@@ -1564,24 +1564,29 @@
     @PUT(URL
+ + V1
 )%0A    @Multi
@@ -1881,24 +1881,24 @@
 Exception;%0A%0A
-
     @DELETE(
@@ -1900,16 +1900,21 @@
 LETE(URL
+ + V1
 )%0A    Re

Upgrade queryProfile create api to v2 [rev. alex.scown]