diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java index aa3f4c1ae0..4ee53ec393 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventAsyncClient.java @@ -24,12 +24,15 @@ import javax.ws.rs.core.MediaType; import java.util.Set; import com.google.common.util.concurrent.ListenableFuture; +import org.jclouds.cloudstack.domain.Event; import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse; +import org.jclouds.cloudstack.options.ListEventsOptions; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; /** @@ -53,4 +56,14 @@ public interface EventAsyncClient { @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture> listEventTypes(); + /** + * @see EventClient#listEventTypes() + */ + @GET + @QueryParams(keys = "command", values = "listEvents") + @SelectJson("event") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listEvents(ListEventsOptions...options); + } diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventClient.java index ef7c28ddce..d75004fd1b 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventClient.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/EventClient.java @@ -21,6 +21,8 @@ package org.jclouds.cloudstack.features; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jclouds.cloudstack.domain.Event; +import org.jclouds.cloudstack.options.ListEventsOptions; import org.jclouds.concurrent.Timeout; /** @@ -40,6 +42,12 @@ public interface EventClient { */ Set listEventTypes(); + /** + * List Events + * + * @return event list or null if not found + */ + Set listEvents(ListEventsOptions... options); } diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEventsOptions.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEventsOptions.java index 31fa3bc0dc..770213ea78 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEventsOptions.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEventsOptions.java @@ -74,23 +74,56 @@ public class ListEventsOptions extends BaseHttpRequestOptions { return this; } -// page -// pagesize -// startdate -// type - - /** - * @param name the SSHKeyPair name - */ - public ListEventsOptions name(String name) { - this.queryParameters.replaceValues("name", ImmutableSet.of(name)); + public ListEventsOptions type(String type) { + this.queryParameters.replaceValues("type", ImmutableSet.of(type)); return this; } + public static class Builder { - public static ListEventsOptions name(String name) { - ListEventsOptions options = new ListEventsOptions(); - return options.name(name); + public static ListEventsOptions account(String account) { + final ListEventsOptions options = new ListEventsOptions(); + return options.account(account); + } + + public static ListEventsOptions domainId(long domainId) { + final ListEventsOptions options = new ListEventsOptions(); + return options.domainId(domainId); + } + + public static ListEventsOptions duration(String duration) { + final ListEventsOptions options = new ListEventsOptions(); + return options.duration(duration); + } + + public static ListEventsOptions endDate(Date enddate) { + final ListEventsOptions options = new ListEventsOptions(); + return options.endDate(enddate); + } + + public static ListEventsOptions entryTime(Date entrytime) { + final ListEventsOptions options = new ListEventsOptions(); + return options.entryTime(entrytime); + } + + public static ListEventsOptions id(String id) { + final ListEventsOptions options = new ListEventsOptions(); + return options.id(id); + } + + public static ListEventsOptions keyword(String keyword) { + final ListEventsOptions options = new ListEventsOptions(); + return options.keyword(keyword); + } + + public static ListEventsOptions level(String level) { + final ListEventsOptions options = new ListEventsOptions(); + return options.level(level); + } + + public static ListEventsOptions type(String type) { + final ListEventsOptions options = new ListEventsOptions(); + return options.type(type); } } diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java index cfa92af83b..a616fab1ba 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java @@ -23,7 +23,9 @@ import java.lang.reflect.Method; import com.google.inject.TypeLiteral; import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse; +import org.jclouds.cloudstack.options.ListEventsOptions; import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -51,6 +53,39 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest