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 d48863bb14..14ef3d4368 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> CONTEXT_TOKEN = new TypeToken>() { - 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 { + public abstract static class Builder> extends BaseHttpApiMetadata.Builder { - 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 { @Override - protected Builder self() { + protected ConcreteBuilder self() { return this; } } 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 946280ac72..0000000000 --- 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 - *

- * - * @see - * @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 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); -} diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java similarity index 68% rename from apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java rename to apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java index 8c92594bea..500e7e7203 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchHttpApiModule.java @@ -17,18 +17,15 @@ package org.jclouds.cloudwatch.config; import com.google.common.collect.ImmutableMap; -import org.jclouds.aws.config.FormSigningRestClientModule; +import org.jclouds.aws.config.FormSigningHttpApiModule; 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 org.jclouds.rest.ConfiguresHttpApi; import java.util.Map; @@ -39,15 +36,10 @@ import static org.jclouds.reflect.Reflection2.typeToken; * * @author Adrian Cole */ -@ConfiguresRestClient -public class CloudWatchRestClientModule extends FormSigningRestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(MetricApi.class, MetricAsyncApi.class) - .put(AlarmApi.class, AlarmAsyncApi.class) - .build(); - - public CloudWatchRestClientModule() { - super(typeToken(CloudWatchApi.class), typeToken(CloudWatchAsyncApi.class), DELEGATE_MAP); +@ConfiguresHttpApi +public class CloudWatchHttpApiModule extends FormSigningHttpApiModule { + public CloudWatchHttpApiModule() { + super(CloudWatchApi.class); } @Override 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 be2265600b..25ab508a28 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 *

* - * @see AlarmAsyncApi * @see * @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 alarmNames); + @Named("DeleteAlarms") + @POST + @Path("/") + @FormParams(keys = "Action", values = "DeleteAlarms") + void delete(@BinderParam(AlarmNamesBinder.class) Iterable 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 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 listHistory(ListAlarmHistoryOptions options); /** @@ -70,13 +108,27 @@ public interface AlarmApi { * * @return the response object */ - IterableWithMarker listHistoryAt(String nextToken); + @Named("DescribeAlarmHistory") + @POST + @Path("/") + @XMLResponseParser(ListAlarmHistoryResponseHandler.class) + @FormParams(keys = "Action", values = "DescribeAlarmHistory") + @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) + IterableWithMarker 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 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 list(ListAlarmsOptions options); /** @@ -95,7 +154,13 @@ public interface AlarmApi { * * @return the response object */ - IterableWithMarker listAt(String nextToken); + @Named("DescribeAlarms") + @POST + @Path("/") + @XMLResponseParser(ListAlarmsResponseHandler.class) + @FormParams(keys = "Action", values = "DescribeAlarms") + @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) + IterableWithMarker 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 listForMetric(ListAlarmsForMetric options); /** @@ -111,20 +182,32 @@ public interface AlarmApi { * * @param alarmNames the list of alarms to disable */ - void disable(Iterable alarmNames); + @Named("DisableAlarmActions") + @POST + @Path("/") + @FormParams(keys = "Action", values = "DisableAlarmActions") + void disable(@BinderParam(AlarmNamesBinder.class) Iterable alarmNames); /** * Enables actions for the specified alarms. * * @param alarmNames the list of alarms to enable */ - void enable(Iterable alarmNames); + @Named("EnableAlarmActions") + @POST + @Path("/") + @FormParams(keys = "Action", values = "EnableAlarmActions") + void enable(@BinderParam(AlarmNamesBinder.class) Iterable 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); } 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 28a9255b27..0000000000 --- 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 - *

- * - * @see - * @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 delete(@BinderParam(AlarmNamesBinder.class) Iterable alarmNames); - - /** - * @see AlarmApi#listHistory() - */ - @Named("DescribeAlarmHistory") - @POST - @Path("/") - @XMLResponseParser(ListAlarmHistoryResponseHandler.class) - @FormParams(keys = "Action", values = "DescribeAlarmHistory") - @Transform(ListAlarmsToPagedIterable.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> 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> listHistory(ListAlarmHistoryOptions options); - - /** - * @see AlarmApi#listHistoryAt(String) - */ - @Named("DescribeAlarmHistory") - @POST - @Path("/") - @XMLResponseParser(ListAlarmHistoryResponseHandler.class) - @FormParams(keys = "Action", values = "DescribeAlarmHistory") - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> 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> 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> list(ListAlarmsOptions options); - - /** - * @see AlarmApi#listAt(String) - */ - @Named("DescribeAlarms") - @POST - @Path("/") - @XMLResponseParser(ListAlarmsResponseHandler.class) - @FormParams(keys = "Action", values = "DescribeAlarms") - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> 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> listForMetric(ListAlarmsForMetric options); - - /** - * @see AlarmApi#disable(Iterable) - */ - @Named("DisableAlarmActions") - @POST - @Path("/") - @FormParams(keys = "Action", values = "DisableAlarmActions") - ListenableFuture disable(@BinderParam(AlarmNamesBinder.class) Iterable alarmNames); - - /** - * @see AlarmApi#enable(Iterable) - */ - @Named("EnableAlarmActions") - @POST - @Path("/") - @FormParams(keys = "Action", values = "EnableAlarmActions") - ListenableFuture enable(@BinderParam(AlarmNamesBinder.class) Iterable alarmNames); - - /** - * @see AlarmApi#save(org.jclouds.cloudwatch.options.SaveAlarmOptions) - */ - @Named("PutMetricAlarm") - @POST - @Path("/") - @FormParams(keys = "Action", values = "PutMetricAlarm") - ListenableFuture 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 setState(@FormParam("AlarmName") String alarmName, - @FormParam("StateReason") String stateReason, - @FormParam("StateReasonData") @Nullable String stateReasonData, - @FormParam("StateValue") Alarm.State state); - -} 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 8ff707957b..9d47745186 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 *

* - * @see MetricAsyncApi * @see * @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 list(ListMetricsOptions options); + @Named("ListMetrics") + @POST + @Path("/") + @XMLResponseParser(ListMetricsResponseHandler.class) + @Transform(MetricsToPagedIterable.class) + @FormParams(keys = "Action", values = "ListMetrics") + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) PagedIterable 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 metrics, String namespace); + @Named("PutMetricData") + @POST + @Path("/") + @FormParams(keys = "Action", values = "PutMetricData") + void putMetricsInNamespace(@BinderParam(MetricDataBinder.class) Iterable metrics, + @FormParam("Namespace") String namespace); } 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 7a760ed885..0000000000 --- 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 - *

- * - * @see - * @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> list(); - - /** - * @see MetricApi#list(ListMetricsOptions) - */ - @Named("ListMetrics") - @POST - @Path("/") - @XMLResponseParser(ListMetricsResponseHandler.class) - @FormParams(keys = "Action", values = "ListMetrics") - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> list(ListMetricsOptions options); - - /** - * @see MetricApi#getMetricStatistics(GetMetricStatistics) - */ - @Named("GetMetricStatistics") - @POST - @Path("/") - @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class) - @FormParams(keys = "Action", values = "GetMetricStatistics") - ListenableFuture getMetricStatistics( - @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics); - - /** - * @see MetricApi#getMetricStatistics(GetMetricStatistics, GetMetricStatisticsOptions) - */ - @Named("GetMetricStatistics") - @POST - @Path("/") - @XMLResponseParser(GetMetricStatisticsResponseHandlerV2.class) - @FormParams(keys = "Action", values = "GetMetricStatistics") - ListenableFuture getMetricStatistics( - @BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics, - GetMetricStatisticsOptions options); - - /** - * @see MetricApi#putMetricsInNamespace(Iterable, String) - */ - @Named("PutMetricData") - @POST - @Path("/") - @FormParams(keys = "Action", values = "PutMetricData") - ListenableFuture putMetricsInNamespace(@BinderParam(MetricDataBinder.class) Iterable metrics, - @FormParam("Namespace") String namespace); - -} 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 7bfe24f208..831110b83f 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() { 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 a852d4672d..2c4e7e7ec3 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 extends BaseRestApiExpectTest { 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 extends BaseRestApiExpectTest { @Override protected Module createModule() { - return new TestMonitoringRestClientModule(); + return new TestMonitoringHttpApiModule(); } }