package com.kryptnostic.directory.v1.http;

import java.util.Set;
import java.util.UUID;

import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Optional;
import com.kryptnostic.directory.v1.model.DomainUpdate;

import retrofit.client.Response;
import retrofit.http.Body;
import retrofit.http.DELETE;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.PUT;
import retrofit.http.Path;

/**
 * {@code Domain} management functionality.
 * 
 * @author Nick Hewitt
 * @author Yao Pan
 *
 */
public interface DomainManagementApi {
    public static final String DOMAIN        = "/domain";
    public static final String NAME          = "name";
    public static final String NAME_PATH     = "/{" + NAME + "}";
    public static final String NAME_WITH_DOT = "/{" + NAME + ":.+}";

    public static final String WHITE_LIST    = "/whitelist";

    public static final String DOMAIN_LIST   = "/domainlist";

    /**
     * Update domain settings.
     * 
     * @param request
     * @return
     */
    @Timed
    @POST( DOMAIN )
    Response updateDomain( @Body DomainUpdate request );

    @Timed
    @GET( DOMAIN + NAME_PATH )
    Optional<UUID> getDomainId( @Path( NAME ) String domainName);

    /**
     * Update white list settings.
     * 
     * @param domains
     * @return
     */
    @PUT( WHITE_LIST )
    Response addToDomainWhiteList( @Body Set<String> domains );

    @GET( WHITE_LIST )
    Set<String> getDomainWhiteList();

    @DELETE( WHITE_LIST )
    Response removeFromDomainWhiteList( @Body Set<String> domains );

    @GET( DOMAIN_LIST )
    Set<String> getListableDomainsForWhiteList();
}
@@ -603,24 +603,25 @@
 MAIN        
+ 
 = %22/domain%22;
@@ -621,16 +621,17 @@
 omain%22;%0A
+%0A
     publ
@@ -657,32 +657,40 @@
 ing 
-NAME          = %22name
+WHITE_LIST     = %22/whitelist
 %22;%0A
+%0A
     
@@ -720,40 +720,94 @@
 ing 
-NAME_PATH     = %22/%7B%22 + NAME + %22%7D
+DOMAIN_LIST    = %22/domainlist%22;%0A%0A    public static final String NAME           = %22name
 %22;%0A 
@@ -845,16 +845,17 @@
 AME_
-WITH_DOT
+PATH     
  = %22
@@ -872,16 +872,12 @@
  + %22
-:.+
 %7D%22;%0A
-%0A
     
@@ -907,39 +907,47 @@
 ing 
-WHITE_LIST    = %22/whitelist
+NAME_WITH_DOT  = %22/%7B%22 + NAME + %22:.+%7D
 %22;%0A
-%0A
     
@@ -977,36 +977,40 @@
 ing 
-DOMAIN_LIST   = %22/domainlist
+SHARING_POLICY = %22/sharingpolicy
 %22;%0A%0A
@@ -1295,24 +1295,98 @@
 mainName);%0A%0A
+    @GET( DOMAIN + SHARING_POLICY )%0A    String getDomainSharingPolicy();%0A%0A
     /**%0A    
@@ -1789,9 +1789,10 @@
 List();%0A
+%0A
 %7D

add endpoint to get domain sharing policy