/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cdancy.bitbucket.rest.features;

import com.cdancy.bitbucket.rest.annotations.Documentation;
import com.cdancy.bitbucket.rest.domain.comment.Task;
import com.cdancy.bitbucket.rest.domain.common.RequestStatus;
import com.cdancy.bitbucket.rest.fallbacks.BitbucketFallbacks;
import com.cdancy.bitbucket.rest.filters.BitbucketAuthenticationFilter;
import com.cdancy.bitbucket.rest.options.CreateTask;
import com.cdancy.bitbucket.rest.parsers.RequestStatusParser;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToJsonPayload;

import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import javax.ws.rs.core.MediaType;
import org.jclouds.rest.annotations.ResponseParser;

@Produces(MediaType.APPLICATION_JSON)
@RequestFilters(BitbucketAuthenticationFilter.class)
@Path("/rest/api/1.0/tasks")
public interface TasksApi {

    @Named("tasks:create")
    @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45319070694864"})
    @Consumes(MediaType.APPLICATION_JSON)
    @Fallback(BitbucketFallbacks.TaskOnError.class)
    @POST
    Task create(@BinderParam(BindToJsonPayload.class) CreateTask createTask);
    

    @Named("tasks:get")
    @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45701777641664"})
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/{taskId}")
    @Fallback(BitbucketFallbacks.TaskOnError.class)
    @GET
    Task get(@PathParam("taskId") int taskId);
    
    @Named("tasks:delete")
    @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45701777664960"})
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/{taskId}")
    @Fallback(BitbucketFallbacks.RequestStatusOnError.class)
    @ResponseParser(RequestStatusParser.class)
    @DELETE
    RequestStatus delete(@PathParam("taskId") int taskId);
}

@@ -1201,24 +1201,83 @@
 CreateTask;%0A
+import com.cdancy.bitbucket.rest.options.CreateTaskUpdate;%0A
 import com.c
@@ -1322,24 +1322,24 @@
 atusParser;%0A
-
 import org.j
@@ -1575,176 +1575,9 @@
 .rs.
-Consumes;%0Aimport javax.ws.rs.DELETE;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.PathParam;%0Aimport javax.ws.rs.Produces
+*
 ;%0A%0Ai
@@ -2073,16 +2073,16 @@
   @POST%0A
-
     Task
@@ -2150,16 +2150,538 @@
 teTask);
+%0A%0A    /* TODO: Remove this example%0A %7B%0A%22anchor%22: %7B%0A %22id%22: 329696,%0A %22type%22: %22COMMENT%22%0A%7D,%0A%22id%22: 21127,%0A%22state%22: %22OPEN%22,%0A%22pullRequestId%22: 12,%0A%22repositoryId%22: 9594%0A%7D%0A  */%0A    @Named(%22tasks:update%22)%0A    @Documentation(%7B%22https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8288367088%22%7D)%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    @Path(%22/%7BtaskId%7D%22)%0A    @Fallback(BitbucketFallbacks.TaskOnError.class)%0A    @PUT%0A    Task update(@BinderParam(BindToJsonPayload.class) CreateTaskUpdate createTaskUpdate);
 %0A    %0A%0A 

Add update method for TasksApi