package io.searchbox.core;

import io.searchbox.AbstractAction;
import io.searchbox.Action;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Dogukan Sonmez
 */


public class Delete extends AbstractAction implements Action {

    final static Logger log = LoggerFactory.getLogger(Delete.class);

    public static class Builder {
        private String index;
        private String type;
        private final String id;

        public Builder(String id) {
            this.id = id;
        }

        public Builder index(String val) {
            index = val;
            return this;
        }

        public Builder type(String val) {
            type = val;
            return this;
        }

        public Delete build() {
            return new Delete(this);
        }
    }

    private Delete(Builder builder) {
        indexName = builder.index;
        typeName = builder.type;
        id = builder.id;
    }

    @Override
    public String getURI() {
        StringBuilder sb = new StringBuilder();
        sb.append(buildURI(indexName, typeName, id));
        String queryString = buildQueryString();
        if (StringUtils.isNotBlank(queryString)) sb.append(queryString);
        return sb.toString();
    }

    @Override
    public String getName() {
        return "DELETE";
    }

    @Override
    public String getRestMethodName() {
        return "DELETE";
    }

    @Override
    public String getPathToResult() {
        return "ok";
    }

}

@@ -466,22 +466,16 @@
 private 
-final 
 String i
@@ -478,16 +478,62 @@
 ng id;%0A%0A
+        public Builder() %7B%0A        %7D%0A        %0A
         

delete index