You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/27 22:40:58 UTC
[2/2] git commit: JCLOUDS-150. De-async CloudWatch.
JCLOUDS-150. De-async CloudWatch.
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/91d6736c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/91d6736c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/91d6736c
Branch: refs/heads/master
Commit: 91d6736c22d9cb488c0c0ba1ed3ec54f26ac146e
Parents: 100afba
Author: Andrew Bayer <an...@gmail.com>
Authored: Tue Jul 2 18:42:28 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Tue Aug 27 12:16:30 2013 -0700
----------------------------------------------------------------------
.../cloudwatch/CloudWatchApiMetadata.java | 39 ++--
.../jclouds/cloudwatch/CloudWatchAsyncApi.java | 75 -------
.../config/CloudWatchHttpApiModule.java | 51 +++++
.../config/CloudWatchRestClientModule.java | 59 ------
.../jclouds/cloudwatch/features/AlarmApi.java | 104 +++++++++-
.../cloudwatch/features/AlarmAsyncApi.java | 193 -------------------
.../jclouds/cloudwatch/features/MetricApi.java | 60 +++++-
.../cloudwatch/features/MetricAsyncApi.java | 117 -----------
.../cloudwatch/CloudWatchApiMetadataTest.java | 4 +-
.../internal/BaseCloudWatchExpectTest.java | 10 +-
10 files changed, 227 insertions(+), 485 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java
index d48863b..14ef3d4 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java
@@ -24,50 +24,40 @@ import java.util.Properties;
import com.google.common.reflect.TypeToken;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.cloudwatch.config.CloudWatchHttpApiModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Amazon's CloudWatch api.
*
* @author Adrian Cole
*/
-public class CloudWatchApiMetadata extends BaseRestApiMetadata {
+public class CloudWatchApiMetadata extends BaseHttpApiMetadata {
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudWatchApi.class)} as
- * {@link CloudWatchAsyncApi} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<CloudWatchApi, CloudWatchAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudWatchApi, CloudWatchAsyncApi>>() {
- private static final long serialVersionUID = 1L;
- };
@Override
- public Builder toBuilder() {
- return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromApiMetadata(this);
}
- @SuppressWarnings("deprecation")
public CloudWatchApiMetadata() {
- this(new Builder(CloudWatchApi.class, CloudWatchAsyncApi.class));
+ this(new ConcreteBuilder());
}
- protected CloudWatchApiMetadata(Builder builder) {
- super(Builder.class.cast(builder));
+ protected CloudWatchApiMetadata(Builder<?> builder) {
+ super(builder);
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public abstract static class Builder<T extends Builder<T>> extends BaseHttpApiMetadata.Builder<CloudWatchApi, T> {
- protected Builder(Class<?> api, Class<?> asyncApi) {
- super(api, asyncApi);
+ protected Builder() {
id("cloudwatch")
.name("Amazon CloudWatch Api")
.identityName("Access Key ID")
@@ -76,7 +66,7 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"))
.defaultEndpoint("https://monitoring.us-east-1.amazonaws.com")
.defaultProperties(CloudWatchApiMetadata.defaultProperties())
- .defaultModule(CloudWatchRestClientModule.class);
+ .defaultModule(CloudWatchHttpApiModule.class);
}
@Override
@@ -84,8 +74,11 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
return new CloudWatchApiMetadata(this);
}
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
- protected Builder self() {
+ protected ConcreteBuilder self() {
return this;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java
deleted file mode 100644
index 946280a..0000000
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 org.jclouds.cloudwatch;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import com.google.inject.Provides;
-import org.jclouds.cloudwatch.features.AlarmAsyncApi;
-import org.jclouds.cloudwatch.features.MetricAsyncApi;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.location.Region;
-import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
-import org.jclouds.rest.annotations.Delegate;
-import org.jclouds.rest.annotations.EndpointParam;
-
-/**
- * Provides access to Amazon CloudWatch via the Query API
- * <p/>
- *
- * @see <a
- * href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference"
- * />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudWatchApi.class)} as
- * {@link CloudWatchAsyncApi} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public interface CloudWatchAsyncApi extends Closeable {
- /**
- *
- * @return the Region codes configured
- */
- @Provides
- @Region
- Set<String> getConfiguredRegions();
-
- /**
- * Provides asynchronous access to Metric features.
- */
- @Delegate
- MetricAsyncApi getMetricApi();
-
- /**
- * Provides asynchronous access to Metric features.
- */
- @Delegate
- MetricAsyncApi getMetricApiForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
-
- /**
- * Provides asynchronous access to Alarm features.
- */
- @Delegate
- AlarmAsyncApi getAlarmApi();
-
- /**
- * Provides asynchronous access to Metric features.
- */
- @Delegate
- AlarmAsyncApi getAlarmApiForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java
new file mode 100644
index 0000000..500e7e7
--- /dev/null
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.jclouds.cloudwatch.config;
+
+import com.google.common.collect.ImmutableMap;
+import org.jclouds.aws.config.FormSigningHttpApiModule;
+import org.jclouds.cloudwatch.CloudWatchApi;
+import org.jclouds.cloudwatch.features.AlarmApi;
+import org.jclouds.cloudwatch.features.MetricApi;
+import org.jclouds.cloudwatch.handlers.CloudWatchErrorHandler;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.rest.ConfiguresHttpApi;
+
+import java.util.Map;
+
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+/**
+ * Configures the Monitoring connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresHttpApi
+public class CloudWatchHttpApiModule extends FormSigningHttpApiModule<CloudWatchApi> {
+ public CloudWatchHttpApiModule() {
+ super(CloudWatchApi.class);
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CloudWatchErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CloudWatchErrorHandler.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java
deleted file mode 100644
index 8c92594..0000000
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 org.jclouds.cloudwatch.config;
-
-import com.google.common.collect.ImmutableMap;
-import org.jclouds.aws.config.FormSigningRestClientModule;
-import org.jclouds.cloudwatch.CloudWatchApi;
-import org.jclouds.cloudwatch.CloudWatchAsyncApi;
-import org.jclouds.cloudwatch.features.AlarmApi;
-import org.jclouds.cloudwatch.features.AlarmAsyncApi;
-import org.jclouds.cloudwatch.features.MetricApi;
-import org.jclouds.cloudwatch.features.MetricAsyncApi;
-import org.jclouds.cloudwatch.handlers.CloudWatchErrorHandler;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.rest.ConfiguresRestClient;
-
-import java.util.Map;
-
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-/**
- * Configures the Monitoring connection.
- *
- * @author Adrian Cole
- */
-@ConfiguresRestClient
-public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchApi, CloudWatchAsyncApi> {
- public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
- .put(MetricApi.class, MetricAsyncApi.class)
- .put(AlarmApi.class, AlarmAsyncApi.class)
- .build();
-
- public CloudWatchRestClientModule() {
- super(typeToken(CloudWatchApi.class), typeToken(CloudWatchAsyncApi.class), DELEGATE_MAP);
- }
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CloudWatchErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CloudWatchErrorHandler.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmApi.java
index be22656..25ab508 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmApi.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmApi.java
@@ -16,26 +16,46 @@
*/
package org.jclouds.cloudwatch.features;
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
import com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.cloudwatch.binders.AlarmNamesBinder;
import org.jclouds.cloudwatch.domain.Alarm;
import org.jclouds.cloudwatch.domain.AlarmHistoryItem;
+import org.jclouds.cloudwatch.functions.ListAlarmsToPagedIterable;
import org.jclouds.cloudwatch.options.ListAlarmHistoryOptions;
import org.jclouds.cloudwatch.options.ListAlarmsForMetric;
import org.jclouds.cloudwatch.options.ListAlarmsOptions;
import org.jclouds.cloudwatch.options.SaveAlarmOptions;
+import org.jclouds.cloudwatch.xml.ListAlarmHistoryResponseHandler;
+import org.jclouds.cloudwatch.xml.ListAlarmsForMetricResponseHandler;
+import org.jclouds.cloudwatch.xml.ListAlarmsResponseHandler;
import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
/**
* Provides access to Amazon CloudWatch via the Query API
* <p/>
*
- * @see AlarmAsyncApi
* @see <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference" />
* @author Jeremy Whitlock
*/
+@RequestFilters(FormSigner.class)
+@VirtualHost
@Beta
public interface AlarmApi {
@@ -47,13 +67,24 @@ public interface AlarmApi {
*
* @param alarmNames the list of alarms to delete
*/
- void delete(Iterable<String> alarmNames);
+ @Named("DeleteAlarms")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "DeleteAlarms")
+ void delete(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
/**
* Return all history for all alarms.
*
* @return the response object
*/
+ @Named("DescribeAlarmHistory")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarmHistory")
+ @Transform(ListAlarmsToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
PagedIterable<AlarmHistoryItem> listHistory();
/**
@@ -61,6 +92,13 @@ public interface AlarmApi {
*
* @return the response object
*/
+ @Named("DescribeAlarmHistory")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarmHistory")
+ @Transform(ListAlarmsToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
PagedIterable<AlarmHistoryItem> listHistory(ListAlarmHistoryOptions options);
/**
@@ -70,13 +108,27 @@ public interface AlarmApi {
*
* @return the response object
*/
- IterableWithMarker<AlarmHistoryItem> listHistoryAt(String nextToken);
+ @Named("DescribeAlarmHistory")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarmHistory")
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
+ IterableWithMarker<AlarmHistoryItem> listHistoryAt(@FormParam("NextToken")
+ String nextToken);
/**
* Return all alarms.
*
* @return the response object
*/
+ @Named("DescribeAlarms")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmsResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarms")
+ @Transform(ListAlarmsToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
PagedIterable<Alarm> list();
/**
@@ -86,6 +138,13 @@ public interface AlarmApi {
*
* @return the response object
*/
+ @Named("DescribeAlarms")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmsResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarms")
+ @Transform(ListAlarmsToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
PagedIterable<Alarm> list(ListAlarmsOptions options);
/**
@@ -95,7 +154,13 @@ public interface AlarmApi {
*
* @return the response object
*/
- IterableWithMarker<Alarm> listAt(String nextToken);
+ @Named("DescribeAlarms")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmsResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarms")
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
+ IterableWithMarker<Alarm> listAt(@FormParam("NextToken") String nextToken);
/**
* Return alarms all alarms for a single metric.
@@ -104,6 +169,12 @@ public interface AlarmApi {
*
* @return the response object
*/
+ @Named("DescribeAlarmsForMetric")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListAlarmsForMetricResponseHandler.class)
+ @FormParams(keys = "Action", values = "DescribeAlarmsForMetric")
+ @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
FluentIterable<Alarm> listForMetric(ListAlarmsForMetric options);
/**
@@ -111,20 +182,32 @@ public interface AlarmApi {
*
* @param alarmNames the list of alarms to disable
*/
- void disable(Iterable<String> alarmNames);
+ @Named("DisableAlarmActions")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "DisableAlarmActions")
+ void disable(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
/**
* Enables actions for the specified alarms.
*
* @param alarmNames the list of alarms to enable
*/
- void enable(Iterable<String> alarmNames);
+ @Named("EnableAlarmActions")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "EnableAlarmActions")
+ void enable(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
/**
* Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric.
*
* @param options the options describing the metric alarm to create/update
*/
+ @Named("PutMetricAlarm")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "PutMetricAlarm")
void save(SaveAlarmOptions options);
/**
@@ -135,6 +218,13 @@ public interface AlarmApi {
* @param stateReasonData the reason that this alarm is set to this specific state (in machine-readable JSON format)
* @param state the value of the state
*/
- void setState(String alarmName, String stateReason, @Nullable String stateReasonData, Alarm.State state);
+ @Named("SetAlarmState")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "SetAlarmState")
+ void setState(@FormParam("AlarmName") String alarmName,
+ @FormParam("StateReason") String stateReason,
+ @FormParam("StateReasonData") @Nullable String stateReasonData,
+ @FormParam("StateValue") Alarm.State state);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmAsyncApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmAsyncApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmAsyncApi.java
deleted file mode 100644
index 28a9255..0000000
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/AlarmAsyncApi.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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 org.jclouds.cloudwatch.features;
-
-import javax.inject.Named;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.jclouds.Fallbacks;
-import org.jclouds.aws.filters.FormSigner;
-import org.jclouds.cloudwatch.binders.AlarmNamesBinder;
-import org.jclouds.cloudwatch.domain.Alarm;
-import org.jclouds.cloudwatch.domain.AlarmHistoryItem;
-import org.jclouds.cloudwatch.functions.ListAlarmsToPagedIterable;
-import org.jclouds.cloudwatch.options.ListAlarmHistoryOptions;
-import org.jclouds.cloudwatch.options.ListAlarmsForMetric;
-import org.jclouds.cloudwatch.options.ListAlarmsOptions;
-import org.jclouds.cloudwatch.options.SaveAlarmOptions;
-import org.jclouds.cloudwatch.xml.ListAlarmHistoryResponseHandler;
-import org.jclouds.cloudwatch.xml.ListAlarmsForMetricResponseHandler;
-import org.jclouds.cloudwatch.xml.ListAlarmsResponseHandler;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.FormParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.Transform;
-import org.jclouds.rest.annotations.VirtualHost;
-import org.jclouds.rest.annotations.XMLResponseParser;
-
-/**
- * Provides access to Amazon CloudWatch via the Query API
- * <p/>
- *
- * @see <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference" />
- * @author Jeremy Whitlock
- */
-@RequestFilters(FormSigner.class)
-@VirtualHost
-@Beta
-public interface AlarmAsyncApi {
-
- /**
- * @see AlarmApi#delete(Iterable)
- */
- @Named("DeleteAlarms")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "DeleteAlarms")
- ListenableFuture<Void> delete(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
-
- /**
- * @see AlarmApi#listHistory()
- */
- @Named("DescribeAlarmHistory")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarmHistory")
- @Transform(ListAlarmsToPagedIterable.class)
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends PagedIterable<AlarmHistoryItem>> listHistory();
-
- /**
- * @see AlarmApi#listHistory(org.jclouds.cloudwatch.options.ListAlarmHistoryOptions)
- */
- @Named("DescribeAlarmHistory")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarmHistory")
- @Transform(ListAlarmsToPagedIterable.class)
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends PagedIterable<AlarmHistoryItem>> listHistory(ListAlarmHistoryOptions options);
-
- /**
- * @see AlarmApi#listHistoryAt(String)
- */
- @Named("DescribeAlarmHistory")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmHistoryResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarmHistory")
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends IterableWithMarker<AlarmHistoryItem>> listHistoryAt(@FormParam("NextToken")
- String nextToken);
-
- /**
- * @see org.jclouds.cloudwatch.features.AlarmApi#list()
- */
- @Named("DescribeAlarms")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmsResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarms")
- @Transform(ListAlarmsToPagedIterable.class)
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends PagedIterable<Alarm>> list();
-
- /**
- * @see AlarmApi#list(org.jclouds.cloudwatch.options.ListAlarmsOptions)
- */
- @Named("DescribeAlarms")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmsResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarms")
- @Transform(ListAlarmsToPagedIterable.class)
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends PagedIterable<Alarm>> list(ListAlarmsOptions options);
-
- /**
- * @see AlarmApi#listAt(String)
- */
- @Named("DescribeAlarms")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmsResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarms")
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends IterableWithMarker<Alarm>> listAt(@FormParam("NextToken") String nextToken);
-
- /**
- * @see AlarmApi#listForMetric(org.jclouds.cloudwatch.options.ListAlarmsForMetric)
- */
- @Named("DescribeAlarmsForMetric")
- @POST
- @Path("/")
- @XMLResponseParser(ListAlarmsForMetricResponseHandler.class)
- @FormParams(keys = "Action", values = "DescribeAlarmsForMetric")
- @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends FluentIterable<Alarm>> listForMetric(ListAlarmsForMetric options);
-
- /**
- * @see AlarmApi#disable(Iterable)
- */
- @Named("DisableAlarmActions")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "DisableAlarmActions")
- ListenableFuture<Void> disable(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
-
- /**
- * @see AlarmApi#enable(Iterable)
- */
- @Named("EnableAlarmActions")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "EnableAlarmActions")
- ListenableFuture<Void> enable(@BinderParam(AlarmNamesBinder.class) Iterable<String> alarmNames);
-
- /**
- * @see AlarmApi#save(org.jclouds.cloudwatch.options.SaveAlarmOptions)
- */
- @Named("PutMetricAlarm")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "PutMetricAlarm")
- ListenableFuture<Void> save(SaveAlarmOptions options);
-
- /**
- * @see AlarmApi#setState(String, String, String, org.jclouds.cloudwatch.domain.Alarm.State)
- */
- @Named("SetAlarmState")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "SetAlarmState")
- ListenableFuture<Void> setState(@FormParam("AlarmName") String alarmName,
- @FormParam("StateReason") String stateReason,
- @FormParam("StateReasonData") @Nullable String stateReasonData,
- @FormParam("StateValue") Alarm.State state);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
index 8ff7079..9d47745 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
@@ -16,23 +16,44 @@
*/
package org.jclouds.cloudwatch.features;
+import javax.inject.Named;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.cloudwatch.binders.GetMetricStatisticsBinder;
+import org.jclouds.cloudwatch.binders.MetricDataBinder;
import org.jclouds.cloudwatch.domain.GetMetricStatistics;
import org.jclouds.cloudwatch.domain.GetMetricStatisticsResponse;
import org.jclouds.cloudwatch.domain.Metric;
import org.jclouds.cloudwatch.domain.MetricDatum;
+import org.jclouds.cloudwatch.functions.MetricsToPagedIterable;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
+import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandlerV2;
+import org.jclouds.cloudwatch.xml.ListMetricsResponseHandler;
import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.VirtualHost;
+import org.jclouds.rest.annotations.XMLResponseParser;
/**
* Provides access to Amazon CloudWatch via the Query API
* <p/>
*
- * @see MetricAsyncApi
* @see <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference" />
* @author Jeremy Whitlock
*/
+@RequestFilters(FormSigner.class)
+@VirtualHost
public interface MetricApi {
/**
@@ -50,8 +71,21 @@ public interface MetricApi {
*
* @return the response object
*/
+ @Named("ListMetrics")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListMetricsResponseHandler.class)
+ @FormParams(keys = "Action", values = "ListMetrics")
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
IterableWithMarker<Metric> list(ListMetricsOptions options);
+ @Named("ListMetrics")
+ @POST
+ @Path("/")
+ @XMLResponseParser(ListMetricsResponseHandler.class)
+ @Transform(MetricsToPagedIterable.class)
+ @FormParams(keys = "Action", values = "ListMetrics")
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
PagedIterable<Metric> list();
/**
@@ -62,9 +96,22 @@ public interface MetricApi {
*
* @return the response object
*/
- GetMetricStatisticsResponse getMetricStatistics(GetMetricStatistics statistics, GetMetricStatisticsOptions options);
+ @Named("GetMetricStatistics")
+ @POST
+ @Path("/")
+ @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class)
+ @FormParams(keys = "Action", values = "GetMetricStatistics")
+ GetMetricStatisticsResponse getMetricStatistics(
+ @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics,
+ GetMetricStatisticsOptions options);
- GetMetricStatisticsResponse getMetricStatistics(GetMetricStatistics statistics);
+ @Named("GetMetricStatistics")
+ @POST
+ @Path("/")
+ @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class)
+ @FormParams(keys = "Action", values = "GetMetricStatistics")
+ GetMetricStatisticsResponse getMetricStatistics(
+ @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics);
/**
* Publishes metric data points to Amazon CloudWatch.
@@ -72,6 +119,11 @@ public interface MetricApi {
* @param metrics the metrics to publish
* @param namespace the namespace to publish the metrics to
*/
- void putMetricsInNamespace(Iterable<MetricDatum> metrics, String namespace);
+ @Named("PutMetricData")
+ @POST
+ @Path("/")
+ @FormParams(keys = "Action", values = "PutMetricData")
+ void putMetricsInNamespace(@BinderParam(MetricDataBinder.class) Iterable<MetricDatum> metrics,
+ @FormParam("Namespace") String namespace);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
deleted file mode 100644
index 7a760ed..0000000
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 org.jclouds.cloudwatch.features;
-
-import javax.inject.Named;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
-import org.jclouds.aws.filters.FormSigner;
-import org.jclouds.cloudwatch.binders.GetMetricStatisticsBinder;
-import org.jclouds.cloudwatch.binders.MetricDataBinder;
-import org.jclouds.cloudwatch.domain.GetMetricStatistics;
-import org.jclouds.cloudwatch.domain.GetMetricStatisticsResponse;
-import org.jclouds.cloudwatch.domain.Metric;
-import org.jclouds.cloudwatch.domain.MetricDatum;
-import org.jclouds.cloudwatch.functions.MetricsToPagedIterable;
-import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
-import org.jclouds.cloudwatch.options.ListMetricsOptions;
-import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandlerV2;
-import org.jclouds.cloudwatch.xml.ListMetricsResponseHandler;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.FormParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.Transform;
-import org.jclouds.rest.annotations.VirtualHost;
-import org.jclouds.rest.annotations.XMLResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides access to Amazon CloudWatch via the Query API
- * <p/>
- *
- * @see <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference" />
- * @author Jeremy Whitlock
- */
-@RequestFilters(FormSigner.class)
-@VirtualHost
-public interface MetricAsyncApi {
-
- /**
- * @see MetricApi#list()
- */
- @Named("ListMetrics")
- @POST
- @Path("/")
- @XMLResponseParser(ListMetricsResponseHandler.class)
- @Transform(MetricsToPagedIterable.class)
- @FormParams(keys = "Action", values = "ListMetrics")
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- ListenableFuture<? extends PagedIterable<Metric>> list();
-
- /**
- * @see MetricApi#list(ListMetricsOptions)
- */
- @Named("ListMetrics")
- @POST
- @Path("/")
- @XMLResponseParser(ListMetricsResponseHandler.class)
- @FormParams(keys = "Action", values = "ListMetrics")
- @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
- ListenableFuture<? extends IterableWithMarker<Metric>> list(ListMetricsOptions options);
-
- /**
- * @see MetricApi#getMetricStatistics(GetMetricStatistics)
- */
- @Named("GetMetricStatistics")
- @POST
- @Path("/")
- @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class)
- @FormParams(keys = "Action", values = "GetMetricStatistics")
- ListenableFuture<? extends GetMetricStatisticsResponse> getMetricStatistics(
- @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics);
-
- /**
- * @see MetricApi#getMetricStatistics(GetMetricStatistics, GetMetricStatisticsOptions)
- */
- @Named("GetMetricStatistics")
- @POST
- @Path("/")
- @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class)
- @FormParams(keys = "Action", values = "GetMetricStatistics")
- ListenableFuture<? extends GetMetricStatisticsResponse> getMetricStatistics(
- @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics,
- GetMetricStatisticsOptions options);
-
- /**
- * @see MetricApi#putMetricsInNamespace(Iterable, String)
- */
- @Named("PutMetricData")
- @POST
- @Path("/")
- @FormParams(keys = "Action", values = "PutMetricData")
- ListenableFuture<Void> putMetricsInNamespace(@BinderParam(MetricDataBinder.class) Iterable<MetricDatum> metrics,
- @FormParam("Namespace") String namespace);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java
index 7bfe24f..831110b 100644
--- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java
+++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java
@@ -17,7 +17,7 @@
package org.jclouds.cloudwatch;
import org.jclouds.View;
-import org.jclouds.rest.internal.BaseRestApiMetadataTest;
+import org.jclouds.rest.internal.BaseHttpApiMetadataTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@@ -28,7 +28,7 @@ import com.google.common.reflect.TypeToken;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
-public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest {
+public class CloudWatchApiMetadataTest extends BaseHttpApiMetadataTest {
// no monitoring abstraction, yet
public CloudWatchApiMetadataTest() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/91d6736c/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java
index a852d46..2c4e7e7 100644
--- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java
+++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java
@@ -22,11 +22,11 @@ import java.net.URI;
import java.util.Map;
import org.jclouds.aws.domain.Region;
-import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
+import org.jclouds.cloudwatch.config.CloudWatchHttpApiModule;
import org.jclouds.date.DateService;
import org.jclouds.location.config.LocationModule;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
-import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.internal.BaseRestApiExpectTest;
import org.jclouds.util.Suppliers2;
@@ -44,8 +44,8 @@ public class BaseCloudWatchExpectTest<T> extends BaseRestApiExpectTest<T> {
provider = "cloudwatch";
}
- @ConfiguresRestClient
- private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule {
+ @ConfiguresHttpApi
+ private static final class TestMonitoringHttpApiModule extends CloudWatchHttpApiModule {
@Override
protected void installLocations() {
@@ -71,6 +71,6 @@ public class BaseCloudWatchExpectTest<T> extends BaseRestApiExpectTest<T> {
@Override
protected Module createModule() {
- return new TestMonitoringRestClientModule();
+ return new TestMonitoringHttpApiModule();
}
}