From 39cd3cba2afbf24a9df432b02648d0b05cdae34d Mon Sep 17 00:00:00 2001 From: andreisavu Date: Sun, 11 Dec 2011 13:10:39 +0200 Subject: [PATCH] Added DomainAccountClient methods for disabling and enabling an account --- .../features/DomainAccountAsyncClient.java | 36 +++++++++++++++++-- .../features/DomainAccountClient.java | 22 ++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java index 67e33aef47..ce35be08e9 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountAsyncClient.java @@ -18,14 +18,24 @@ */ package org.jclouds.cloudstack.features; +import com.google.common.util.concurrent.ListenableFuture; +import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; /** * Provides asynchronous access to CloudStack Account features available to Domain * Admin users. - * + * * @author Adrian Cole * @see enableAccount(@QueryParam("account") long accountId, @QueryParam("domainid") long domainId); + + + /** + * @see DomainAccountAsyncClient#disableAccount + */ + @GET + @QueryParams(keys = "command", values = "disableAccount") + @SelectJson("account") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture disableAccount(@QueryParam("account") long accountId, + @QueryParam("domainid") long domainId, @QueryParam("lock") boolean onlyLock); + } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountClient.java index b1a8d367c2..921123169d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/DomainAccountClient.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features; import java.util.concurrent.TimeUnit; +import org.jclouds.cloudstack.domain.Account; import org.jclouds.concurrent.Timeout; /** @@ -34,5 +35,26 @@ import org.jclouds.concurrent.Timeout; @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) public interface DomainAccountClient extends AccountClient { + /** + * Enable an account + * + * @param accountId + * the account ID you are enabling + * @param domainId + * the domain ID + */ + public Account enableAccount(long accountId, long domainId); + + /** + * Disable or lock an account + * + * @param accountId + * the account ID you are disabling + * @param domainId + * the domain ID + * @param onlyLock + * only lock if true disable otherwise + */ + public Account disableAccount(long accountId, long domainId, boolean onlyLock); }