From dce0ecd8892a4fcf7c3c7ea65b40412e6bd57bf0 Mon Sep 17 00:00:00 2001 From: adriancole Date: Tue, 9 Apr 2013 14:02:23 -0700 Subject: [PATCH] migrated sts and route53 entirely off deprecated async interfaces --- .../java/org/jclouds/route53/Route53Api.java | 30 +++- .../jclouds/route53/Route53ApiMetadata.java | 31 ++-- .../org/jclouds/route53/Route53AsyncApi.java | 79 ---------- ...tModule.java => Route53HttpApiModule.java} | 24 +-- .../route53/features/HostedZoneApi.java | 75 +++++++++- .../route53/features/HostedZoneAsyncApi.java | 137 ------------------ .../features/ResourceRecordSetApi.java | 67 ++++++++- .../features/ResourceRecordSetAsyncApi.java | 126 ---------------- .../route53/Route53ApiMetadataTest.java | 6 +- .../internal/BaseRoute53ApiLiveTest.java | 3 +- .../internal/BaseRoute53ExpectTest.java | 10 +- .../jclouds/aws/config/AWSHttpApiModule.java | 73 ++++++++++ .../aws/config/FormSigningHttpApiModule.java | 59 ++++++++ .../aws/xml/SessionCredentialsHandler.java | 15 +- .../src/main/java/org/jclouds/sts/STSApi.java | 56 ++++++- .../java/org/jclouds/sts/STSApiMetadata.java | 31 ++-- .../java/org/jclouds/sts/STSAsyncApi.java | 118 --------------- ...lientModule.java => STSHttpApiModule.java} | 15 +- .../org/jclouds/sts/STSApiMetadataTest.java | 6 +- .../sts/internal/BaseSTSExpectTest.java | 10 +- 20 files changed, 393 insertions(+), 578 deletions(-) delete mode 100644 apis/route53/src/main/java/org/jclouds/route53/Route53AsyncApi.java rename apis/route53/src/main/java/org/jclouds/route53/config/{Route53RestClientModule.java => Route53HttpApiModule.java} (67%) delete mode 100644 apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneAsyncApi.java delete mode 100644 apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetAsyncApi.java create mode 100644 apis/sts/src/main/java/org/jclouds/aws/config/AWSHttpApiModule.java create mode 100644 apis/sts/src/main/java/org/jclouds/aws/config/FormSigningHttpApiModule.java delete mode 100644 apis/sts/src/main/java/org/jclouds/sts/STSAsyncApi.java rename apis/sts/src/main/java/org/jclouds/sts/config/{STSRestClientModule.java => STSHttpApiModule.java} (68%) diff --git a/apis/route53/src/main/java/org/jclouds/route53/Route53Api.java b/apis/route53/src/main/java/org/jclouds/route53/Route53Api.java index 4909226ea9..43d11db393 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/Route53Api.java +++ b/apis/route53/src/main/java/org/jclouds/route53/Route53Api.java @@ -20,22 +20,35 @@ package org.jclouds.route53; import java.io.Closeable; +import javax.inject.Named; +import javax.ws.rs.GET; +import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.route53.domain.Change; -import org.jclouds.route53.features.ResourceRecordSetApi; import org.jclouds.route53.features.HostedZoneApi; +import org.jclouds.route53.features.ResourceRecordSetApi; +import org.jclouds.route53.filters.RestAuthentication; +import org.jclouds.route53.xml.ChangeHandler; /** * Provides access to Amazon Route53 via the Query API *

* - * @see Route53AsyncApi * @see * @author Adrian Cole */ +@RequestFilters(RestAuthentication.class) +@VirtualHost +@Path("/{jclouds.api-version}") public interface Route53Api extends Closeable { /** @@ -45,17 +58,24 @@ public interface Route53Api extends Closeable { * The ID of the change batch request. * @return null, if not found */ - Change getChange(String changeID); + @Named("GetChange") + @GET + @Path("/change/{changeId}") + @XMLResponseParser(ChangeHandler.class) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Change getChange(@PathParam("changeId") String changeID); /** - * Provides synchronous access to Zone features. + * Provides access to Zone features. */ @Delegate HostedZoneApi getHostedZoneApi(); /** - * Provides synchronous access to record set features. + * Provides access to record set features. */ @Delegate + @Path("/hostedzone/{zoneId}") ResourceRecordSetApi getResourceRecordSetApiForHostedZone(@PathParam("zoneId") String zoneId); } diff --git a/apis/route53/src/main/java/org/jclouds/route53/Route53ApiMetadata.java b/apis/route53/src/main/java/org/jclouds/route53/Route53ApiMetadata.java index f64443c835..1785e22dfd 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/Route53ApiMetadata.java +++ b/apis/route53/src/main/java/org/jclouds/route53/Route53ApiMetadata.java @@ -25,35 +25,23 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.rest.internal.BaseRestApiMetadata; -import org.jclouds.route53.config.Route53RestClientModule; - -import com.google.common.reflect.TypeToken; +import org.jclouds.rest.internal.BaseHttpApiMetadata; +import org.jclouds.route53.config.Route53HttpApiModule; /** * Implementation of {@link ApiMetadata} for Amazon's Route53 api. * * @author Adrian Cole */ -public class Route53ApiMetadata extends BaseRestApiMetadata { - - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(Route53Api.class)} as - * {@link Route53AsyncApi} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; +public class Route53ApiMetadata extends BaseHttpApiMetadata { @Override public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + return new Builder().fromApiMetadata(this); } - @SuppressWarnings("deprecation") public Route53ApiMetadata() { - this(new Builder(Route53Api.class, Route53AsyncApi.class)); + this(new Builder()); } protected Route53ApiMetadata(Builder builder) { @@ -61,16 +49,15 @@ public class Route53ApiMetadata extends BaseRestApiMetadata { } 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 static class Builder extends BaseHttpApiMetadata.Builder { - protected Builder(Class api, Class asyncApi) { - super(api, asyncApi); + protected Builder() { id("route53") .name("Amazon Route 53 Api") .identityName("Access Key ID") @@ -79,7 +66,7 @@ public class Route53ApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://docs.aws.amazon.com/Route53/latest/APIReference/")) .defaultEndpoint("https://route53.amazonaws.com") .defaultProperties(Route53ApiMetadata.defaultProperties()) - .defaultModule(Route53RestClientModule.class); + .defaultModule(Route53HttpApiModule.class); } @Override diff --git a/apis/route53/src/main/java/org/jclouds/route53/Route53AsyncApi.java b/apis/route53/src/main/java/org/jclouds/route53/Route53AsyncApi.java deleted file mode 100644 index fac0d408f5..0000000000 --- a/apis/route53/src/main/java/org/jclouds/route53/Route53AsyncApi.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.route53; - -import java.io.Closeable; - -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.route53.domain.Change; -import org.jclouds.route53.features.ResourceRecordSetAsyncApi; -import org.jclouds.route53.features.HostedZoneAsyncApi; -import org.jclouds.route53.filters.RestAuthentication; -import org.jclouds.route53.xml.ChangeHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon Route53 via the Query API - *

- * - * @see - * @author Adrian Cole - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(Route53Api.class)} as - * {@link Route53AsyncApi} interface will be removed in jclouds 1.7. - */ -@Deprecated -@RequestFilters(RestAuthentication.class) -@VirtualHost -@Path("/{jclouds.api-version}") -public interface Route53AsyncApi extends Closeable { - - /** - * @see Route53Api#getChange() - */ - @Named("GetChange") - @GET - @Path("/change/{changeId}") - @XMLResponseParser(ChangeHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getChange(@PathParam("changeId") String changeID); - - /** - * Provides asynchronous access to Zone features. - */ - @Delegate - HostedZoneAsyncApi getHostedZoneApi(); - - /** - * Provides asynchronous access to record set features. - */ - @Delegate - ResourceRecordSetAsyncApi getResourceRecordSetApiForHostedZone(@PathParam("zoneId") String zoneId); -} diff --git a/apis/route53/src/main/java/org/jclouds/route53/config/Route53RestClientModule.java b/apis/route53/src/main/java/org/jclouds/route53/config/Route53HttpApiModule.java similarity index 67% rename from apis/route53/src/main/java/org/jclouds/route53/config/Route53RestClientModule.java rename to apis/route53/src/main/java/org/jclouds/route53/config/Route53HttpApiModule.java index 613bf54ed2..b7b930f9f9 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/config/Route53RestClientModule.java +++ b/apis/route53/src/main/java/org/jclouds/route53/config/Route53HttpApiModule.java @@ -18,32 +18,23 @@ */ package org.jclouds.route53.config; -import static org.jclouds.reflect.Reflection2.typeToken; - import java.util.Date; -import java.util.Map; import javax.inject.Singleton; -import org.jclouds.aws.config.AWSRestClientModule; +import org.jclouds.aws.config.AWSHttpApiModule; import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.RequestSigner; import org.jclouds.route53.Route53Api; -import org.jclouds.route53.Route53AsyncApi; -import org.jclouds.route53.features.ResourceRecordSetApi; -import org.jclouds.route53.features.ResourceRecordSetAsyncApi; -import org.jclouds.route53.features.HostedZoneApi; -import org.jclouds.route53.features.HostedZoneAsyncApi; import org.jclouds.route53.filters.RestAuthentication; import org.jclouds.route53.handlers.Route53ErrorHandler; -import com.google.common.collect.ImmutableMap; import com.google.inject.Provides; /** @@ -51,14 +42,9 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@ConfiguresRestClient -public class Route53RestClientModule extends AWSRestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(HostedZoneApi.class, HostedZoneAsyncApi.class) - .put(ResourceRecordSetApi.class, ResourceRecordSetAsyncApi.class).build(); - - public Route53RestClientModule() { - super(typeToken(Route53Api.class), typeToken(Route53AsyncApi.class), DELEGATE_MAP); +@ConfiguresHttpApi +public class Route53HttpApiModule extends AWSHttpApiModule { + public Route53HttpApiModule() { } @Provides diff --git a/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneApi.java b/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneApi.java index 36a01989ce..1cfc8ea9c4 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneApi.java +++ b/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneApi.java @@ -18,22 +18,48 @@ */ package org.jclouds.route53.features; +import static javax.ws.rs.core.MediaType.APPLICATION_XML; + +import javax.inject.Named; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +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 org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change.Status; import org.jclouds.route53.domain.HostedZone; import org.jclouds.route53.domain.HostedZoneAndNameServers; import org.jclouds.route53.domain.NewHostedZone; +import org.jclouds.route53.filters.RestAuthentication; +import org.jclouds.route53.functions.HostedZonesToPagedIterable; +import org.jclouds.route53.xml.ChangeHandler; +import org.jclouds.route53.xml.CreateHostedZoneResponseHandler; +import org.jclouds.route53.xml.GetHostedZoneResponseHandler; +import org.jclouds.route53.xml.ListHostedZonesResponseHandler; /** - * @see HostedZoneAsyncApi * @see * @author Adrian Cole */ +@RequestFilters(RestAuthentication.class) +@VirtualHost public interface HostedZoneApi { /** @@ -51,28 +77,55 @@ public interface HostedZoneApi { * retries. ex. {@code MyDNSMigration_01} * @return the new zone in progress, in {@link Status#PENDING}. */ - NewHostedZone createWithReference(String name, String callerReference); + @Named("CreateHostedZone") + @POST + @Produces(APPLICATION_XML) + @Path("/hostedzone") + @Payload("{name}{callerReference}") + @XMLResponseParser(CreateHostedZoneResponseHandler.class) + NewHostedZone createWithReference(@PayloadParam("name") String name, + @PayloadParam("callerReference") String callerReference); /** * like {@link #createWithReference(String, String)}, except you can specify * a comment. */ - NewHostedZone createWithReferenceAndComment(String name, String callerReference, String comment); + @Named("CreateHostedZone") + @POST + @Produces(APPLICATION_XML) + @Path("/hostedzone") + @Payload("{name}{callerReference}{comment}") + @XMLResponseParser(CreateHostedZoneResponseHandler.class) + NewHostedZone createWithReferenceAndComment(@PayloadParam("name") String name, + @PayloadParam("callerReference") String callerReference, @PayloadParam("comment") String comment); /** * returns all zones in order. */ + @Named("ListHostedZones") + @GET + @Path("/hostedzone") + @XMLResponseParser(ListHostedZonesResponseHandler.class) + @Transform(HostedZonesToPagedIterable.class) PagedIterable list(); /** * retrieves up to 100 zones in order. */ + @Named("ListHostedZones") + @GET + @Path("/hostedzone") + @XMLResponseParser(ListHostedZonesResponseHandler.class) IterableWithMarker listFirstPage(); /** * retrieves up to 100 zones in order, starting at {@code nextMarker} */ - IterableWithMarker listAt(String nextMarker); + @Named("ListHostedZones") + @GET + @Path("/hostedzone") + @XMLResponseParser(ListHostedZonesResponseHandler.class) + IterableWithMarker listAt(@QueryParam("marker") String nextMarker); /** * Retrieves information about the specified zone, including its nameserver @@ -83,8 +136,13 @@ public interface HostedZoneApi { * {@code Z1PA6795UKMFR9} * @return null if not found */ + @Named("GetHostedZone") + @GET + @Path("/hostedzone/{zoneId}") + @XMLResponseParser(GetHostedZoneResponseHandler.class) + @Fallback(NullOnNotFoundOr404.class) @Nullable - HostedZoneAndNameServers get(String id); + HostedZoneAndNameServers get(@PathParam("zoneId") String zoneId); /** * This action deletes a hosted zone. @@ -93,6 +151,11 @@ public interface HostedZoneApi { * id of the zone to delete. ex {@code Z1PA6795UKMFR9} * @return null if not found or the change in progress */ + @Named("DeleteHostedZone") + @DELETE + @Path("/hostedzone/{zoneId}") + @XMLResponseParser(ChangeHandler.class) + @Fallback(NullOnNotFoundOr404.class) @Nullable - Change delete(String id); + Change delete(@PathParam("zoneId") String zoneId); } diff --git a/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneAsyncApi.java b/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneAsyncApi.java deleted file mode 100644 index 490a79c4bc..0000000000 --- a/apis/route53/src/main/java/org/jclouds/route53/features/HostedZoneAsyncApi.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.route53.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -import javax.inject.Named; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -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 org.jclouds.route53.domain.Change; -import org.jclouds.route53.domain.HostedZone; -import org.jclouds.route53.domain.HostedZoneAndNameServers; -import org.jclouds.route53.domain.NewHostedZone; -import org.jclouds.route53.filters.RestAuthentication; -import org.jclouds.route53.functions.HostedZonesToPagedIterable; -import org.jclouds.route53.xml.ChangeHandler; -import org.jclouds.route53.xml.CreateHostedZoneResponseHandler; -import org.jclouds.route53.xml.GetHostedZoneResponseHandler; -import org.jclouds.route53.xml.ListHostedZonesResponseHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @see HostedZoneApi - * @see - * @author Adrian Cole - */ -@RequestFilters(RestAuthentication.class) -@VirtualHost -@Path("/{jclouds.api-version}") -public interface HostedZoneAsyncApi { - /** - * @see HostedZoneApi#createWithReference - */ - @Named("CreateHostedZone") - @POST - @Produces(APPLICATION_XML) - @Path("/hostedzone") - @Payload("{name}{callerReference}") - @XMLResponseParser(CreateHostedZoneResponseHandler.class) - ListenableFuture createWithReference(@PayloadParam("name") String name, - @PayloadParam("callerReference") String callerReference); - - /** - * @see HostedZoneApi#createWithReferenceAndComment - */ - @Named("CreateHostedZone") - @POST - @Produces(APPLICATION_XML) - @Path("/hostedzone") - @Payload("{name}{callerReference}{comment}") - @XMLResponseParser(CreateHostedZoneResponseHandler.class) - ListenableFuture createWithReferenceAndComment(@PayloadParam("name") String name, - @PayloadParam("callerReference") String callerReference, @PayloadParam("comment") String comment); - - /** - * @see HostedZoneApi#list() - */ - @Named("ListHostedZones") - @GET - @Path("/hostedzone") - @XMLResponseParser(ListHostedZonesResponseHandler.class) - @Transform(HostedZonesToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see HostedZoneApi#listFirstPage - */ - @Named("ListHostedZones") - @GET - @Path("/hostedzone") - @XMLResponseParser(ListHostedZonesResponseHandler.class) - ListenableFuture> listFirstPage(); - - /** - * @see HostedZoneApi#listAt(String) - */ - @Named("ListHostedZones") - @GET - @Path("/hostedzone") - @XMLResponseParser(ListHostedZonesResponseHandler.class) - ListenableFuture> listAt(@QueryParam("marker") String nextMarker); - - /** - * @see HostedZoneApi#get() - */ - @Named("GetHostedZone") - @GET - @Path("/hostedzone/{zoneId}") - @XMLResponseParser(GetHostedZoneResponseHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("zoneId") String zoneId); - - /** - * @see HostedZoneApi#delete() - */ - @Named("DeleteHostedZone") - @DELETE - @Path("/hostedzone/{zoneId}") - @XMLResponseParser(ChangeHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("zoneId") String zoneId); -} diff --git a/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetApi.java b/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetApi.java index 1eef42aa86..a3592e384d 100644 --- a/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetApi.java +++ b/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetApi.java @@ -18,48 +18,98 @@ */ package org.jclouds.route53.features; +import static javax.ws.rs.core.MediaType.APPLICATION_XML; + +import javax.inject.Named; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import org.jclouds.Fallbacks.NullOnNotFoundOr404; 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.ParamParser; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +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 org.jclouds.route53.binders.BindChangeBatch; +import org.jclouds.route53.binders.BindNextRecord; import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.ChangeBatch; import org.jclouds.route53.domain.ResourceRecordSet; import org.jclouds.route53.domain.ResourceRecordSetIterable; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord; +import org.jclouds.route53.filters.RestAuthentication; +import org.jclouds.route53.functions.ResourceRecordSetIterableToPagedIterable; +import org.jclouds.route53.functions.SerializeRRS; +import org.jclouds.route53.xml.ChangeHandler; +import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler; /** - * @see ResourceRecordSetAsyncApi * @see * @author Adrian Cole */ +@RequestFilters(RestAuthentication.class) +@VirtualHost public interface ResourceRecordSetApi { /** * schedules creation of the resource record set. */ - Change create(ResourceRecordSet rrs); + @Named("ChangeResourceRecordSets") + @POST + @Produces(APPLICATION_XML) + @Path("/rrset") + @Payload("CREATE{rrs}") + @XMLResponseParser(ChangeHandler.class) + Change create(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs); /** * applies a batch of changes atomically. */ - Change apply(ChangeBatch changes); + @Named("ChangeResourceRecordSets") + @POST + @Produces(APPLICATION_XML) + @Path("/rrset") + @XMLResponseParser(ChangeHandler.class) + Change apply(@BinderParam(BindChangeBatch.class) ChangeBatch changes); /** * returns all resource record sets in order. */ + @Named("ListResourceRecordSets") + @GET + @Path("/rrset") + @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) + @Transform(ResourceRecordSetIterableToPagedIterable.class) PagedIterable list(); /** * retrieves up to 100 resource record sets in order. */ + @Named("ListResourceRecordSets") + @GET + @Path("/rrset") + @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) ResourceRecordSetIterable listFirstPage(); /** * retrieves up to 100 resource record sets in order, starting at * {@code nextRecord} */ - ResourceRecordSetIterable listAt(NextRecord nextRecord); + @Named("ListResourceRecordSets") + @GET + @Path("/rrset") + @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) + ResourceRecordSetIterable listAt(@BinderParam(BindNextRecord.class) NextRecord nextRecord); /** * This action deletes a resource record set. @@ -68,6 +118,13 @@ public interface ResourceRecordSetApi { * the resource record set to delete * @return null if not found or the change in progress */ + @Named("ChangeResourceRecordSets") + @POST + @Produces(APPLICATION_XML) + @Path("/rrset") + @Payload("DELETE{rrs}") + @XMLResponseParser(ChangeHandler.class) + @Fallback(NullOnNotFoundOr404.class) @Nullable - Change delete(ResourceRecordSet rrs); + Change delete(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs); } diff --git a/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetAsyncApi.java b/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetAsyncApi.java deleted file mode 100644 index f008ae4d16..0000000000 --- a/apis/route53/src/main/java/org/jclouds/route53/features/ResourceRecordSetAsyncApi.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.route53.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.collect.PagedIterable; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -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 org.jclouds.route53.binders.BindChangeBatch; -import org.jclouds.route53.binders.BindNextRecord; -import org.jclouds.route53.domain.Change; -import org.jclouds.route53.domain.ChangeBatch; -import org.jclouds.route53.domain.ResourceRecordSet; -import org.jclouds.route53.domain.ResourceRecordSetIterable; -import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord; -import org.jclouds.route53.filters.RestAuthentication; -import org.jclouds.route53.functions.ResourceRecordSetIterableToPagedIterable; -import org.jclouds.route53.functions.SerializeRRS; -import org.jclouds.route53.xml.ChangeHandler; -import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @see ResourceRecordSetApi - * @see - * @author Adrian Cole - */ -@RequestFilters(RestAuthentication.class) -@VirtualHost -@Path("/{jclouds.api-version}/hostedzone/{zoneId}") -public interface ResourceRecordSetAsyncApi { - /** - * @see ResourceRecordSetApi#create - */ - @Named("ChangeResourceRecordSets") - @POST - @Produces(APPLICATION_XML) - @Path("/rrset") - @Payload("CREATE{rrs}") - @XMLResponseParser(ChangeHandler.class) - ListenableFuture create(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs); - - /** - * @see ResourceRecordSetApi#apply - */ - @Named("ChangeResourceRecordSets") - @POST - @Produces(APPLICATION_XML) - @Path("/rrset") - @XMLResponseParser(ChangeHandler.class) - ListenableFuture apply(@BinderParam(BindChangeBatch.class) ChangeBatch changes); - - /** - * @see ResourceRecordSetApi#list() - */ - @Named("ListResourceRecordSets") - @GET - @Path("/rrset") - @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) - @Transform(ResourceRecordSetIterableToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see ResourceRecordSetApi#listFirstPage - */ - @Named("ListResourceRecordSets") - @GET - @Path("/rrset") - @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) - ListenableFuture listFirstPage(); - - /** - * @see ResourceRecordSetApi#listAt(NextRecord) - */ - @Named("ListResourceRecordSets") - @GET - @Path("/rrset") - @XMLResponseParser(ListResourceRecordSetsResponseHandler.class) - ListenableFuture listAt(@BinderParam(BindNextRecord.class) NextRecord nextRecord); - - /** - * @see ResourceRecordSetApi#delete - */ - @Named("ChangeResourceRecordSets") - @POST - @Produces(APPLICATION_XML) - @Path("/rrset") - @Payload("DELETE{rrs}") - @XMLResponseParser(ChangeHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs); -} diff --git a/apis/route53/src/test/java/org/jclouds/route53/Route53ApiMetadataTest.java b/apis/route53/src/test/java/org/jclouds/route53/Route53ApiMetadataTest.java index 76ef1b3f53..13094b58f4 100644 --- a/apis/route53/src/test/java/org/jclouds/route53/Route53ApiMetadataTest.java +++ b/apis/route53/src/test/java/org/jclouds/route53/Route53ApiMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.route53; 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; @@ -30,9 +30,9 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole */ @Test(groups = "unit", testName = "Route53ApiMetadataTest") -public class Route53ApiMetadataTest extends BaseRestApiMetadataTest { +public class Route53ApiMetadataTest extends BaseHttpApiMetadataTest { - // no tenant abstraction, yet + // no dns abstraction, yet public Route53ApiMetadataTest() { super(new Route53ApiMetadata(), ImmutableSet.> of()); } diff --git a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ApiLiveTest.java b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ApiLiveTest.java index d26a64ae3d..d8684b4388 100644 --- a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ApiLiveTest.java +++ b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ApiLiveTest.java @@ -49,7 +49,8 @@ public class BaseRoute53ApiLiveTest extends BaseApiLiveTest { super.setup(); inSync = retry(new Predicate() { public boolean apply(Change input) { - return api.getChange(input.getId()).getStatus() == INSYNC; + Change change = api.getChange(input.getId()); + return change != null && change.getStatus() == INSYNC; } }, 600, 1, 5, SECONDS); } diff --git a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java index 3b0239982e..4edead3fd0 100644 --- a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java +++ b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java @@ -20,9 +20,9 @@ package org.jclouds.route53.internal; import org.jclouds.date.DateService; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.internal.BaseRestApiExpectTest; -import org.jclouds.route53.config.Route53RestClientModule; +import org.jclouds.route53.config.Route53HttpApiModule; import com.google.inject.Module; @@ -36,8 +36,8 @@ public class BaseRoute53ExpectTest extends BaseRestApiExpectTest { provider = "route53"; } - @ConfiguresRestClient - private static final class TestRoute53RestClientModule extends Route53RestClientModule { + @ConfiguresHttpApi + private static final class TestRoute53HttpApiModule extends Route53HttpApiModule { @Override protected String provideTimeStamp(final DateService dateService) { @@ -50,6 +50,6 @@ public class BaseRoute53ExpectTest extends BaseRestApiExpectTest { @Override protected Module createModule() { - return new TestRoute53RestClientModule(); + return new TestRoute53HttpApiModule(); } } diff --git a/apis/sts/src/main/java/org/jclouds/aws/config/AWSHttpApiModule.java b/apis/sts/src/main/java/org/jclouds/aws/config/AWSHttpApiModule.java new file mode 100644 index 0000000000..0b0437f096 --- /dev/null +++ b/apis/sts/src/main/java/org/jclouds/aws/config/AWSHttpApiModule.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.aws.config; + + +import java.util.Set; + +import javax.inject.Singleton; + +import org.jclouds.aws.handlers.AWSClientErrorRetryHandler; +import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.HttpRetryHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.http.annotation.Redirection; +import org.jclouds.http.annotation.ServerError; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.config.HttpApiModule; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Provides; + + +/** + * + * @author Adrian Cole + */ +@ConfiguresHttpApi +public abstract class AWSHttpApiModule extends HttpApiModule { + protected AWSHttpApiModule() { + + } + + protected AWSHttpApiModule(Class api) { + super(api); + } + + @Provides + @ClientError + @Singleton + protected Set provideRetryableCodes(){ + return ImmutableSet.of("RequestTimeout", "OperationAborted", "SignatureDoesNotMatch"); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAWSErrorFromXmlContent.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAWSErrorFromXmlContent.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAWSErrorFromXmlContent.class); + } + + @Override + protected void bindRetryHandlers() { + bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AWSClientErrorRetryHandler.class); + } + +} diff --git a/apis/sts/src/main/java/org/jclouds/aws/config/FormSigningHttpApiModule.java b/apis/sts/src/main/java/org/jclouds/aws/config/FormSigningHttpApiModule.java new file mode 100644 index 0000000000..8613bc3615 --- /dev/null +++ b/apis/sts/src/main/java/org/jclouds/aws/config/FormSigningHttpApiModule.java @@ -0,0 +1,59 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.aws.config; + +import java.util.Date; + +import javax.inject.Singleton; + +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.date.DateService; +import org.jclouds.date.TimeStamp; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.RequestSigner; + +import com.google.inject.Provides; + +/** + * + * @author Adrian Cole + */ +@ConfiguresHttpApi +public abstract class FormSigningHttpApiModule extends AWSHttpApiModule { + protected FormSigningHttpApiModule() { + + } + + protected FormSigningHttpApiModule(Class api) { + super(api); + } + + @Provides + @TimeStamp + protected String provideTimeStamp(DateService dateService) { + return dateService.iso8601DateFormat(new Date(System.currentTimeMillis())); + } + + @Provides + @Singleton + RequestSigner provideRequestSigner(FormSigner in) { + return in; + } + +} diff --git a/apis/sts/src/main/java/org/jclouds/aws/xml/SessionCredentialsHandler.java b/apis/sts/src/main/java/org/jclouds/aws/xml/SessionCredentialsHandler.java index c26f78ab4e..7e010a48ea 100644 --- a/apis/sts/src/main/java/org/jclouds/aws/xml/SessionCredentialsHandler.java +++ b/apis/sts/src/main/java/org/jclouds/aws/xml/SessionCredentialsHandler.java @@ -18,12 +18,13 @@ */ package org.jclouds.aws.xml; +import static org.jclouds.util.SaxUtils.currentOrNull; + import javax.inject.Inject; import org.jclouds.aws.domain.SessionCredentials; import org.jclouds.date.DateService; import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; /** * @see * - * @see STSAsyncApi * @see * @author Adrian Cole */ +@RequestFilters(FormSigner.class) +@VirtualHost public interface STSApi extends Closeable { /** * Returns a set of temporary credentials for an AWS account or IAM user, * with a default timeout */ + @Named("GetSessionToken") + @POST + @Path("/") + @XMLResponseParser(SessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "GetSessionToken") SessionCredentials createTemporaryCredentials(); /** * like {@link #createTemporaryCredentials()}, except you can modify the * timeout and other parameters. */ + @Named("GetSessionToken") + @POST + @Path("/") + @XMLResponseParser(SessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "GetSessionToken") SessionCredentials createTemporaryCredentials(SessionCredentialsOptions options); /** @@ -58,13 +81,25 @@ public interface STSApi extends Closeable { * The Amazon Resource Name (ARN) of the role that the caller is * assuming. */ - UserAndSessionCredentials assumeRole(String roleArn, String sessionName); + @Named("AssumeRole") + @POST + @Path("/") + @XMLResponseParser(UserAndSessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "AssumeRole") + UserAndSessionCredentials assumeRole(@FormParam("RoleArn") String roleArn, + @FormParam("RoleSessionName") String sessionName); /** * like {@link #assumeRole(String, String)}, except you can modify the * timeout and other parameters. */ - UserAndSessionCredentials assumeRole(String roleArn, String sessionName, AssumeRoleOptions options); + @Named("AssumeRole") + @POST + @Path("/") + @XMLResponseParser(UserAndSessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "AssumeRole") + UserAndSessionCredentials assumeRole(@FormParam("RoleArn") String roleArn, + @FormParam("RoleSessionName") String sessionName, AssumeRoleOptions options); /** * Returns a set of temporary credentials for a federated user with the user @@ -74,12 +109,21 @@ public interface STSApi extends Closeable { * The name of the federated user, included as part of * {@link User#getId}. */ - UserAndSessionCredentials createFederatedUser(String userName); + @Named("GetFederationToken") + @POST + @Path("/") + @XMLResponseParser(UserAndSessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "GetFederationToken") + UserAndSessionCredentials createFederatedUser(@FormParam("Name") String userName); /** * like {@link #createFederatedUser(String)}, except you can modify the * timeout and other parameters. */ - UserAndSessionCredentials createFederatedUser(String userName, FederatedUserOptions options); - + @Named("GetFederationToken") + @POST + @Path("/") + @XMLResponseParser(UserAndSessionCredentialsHandler.class) + @FormParams(keys = "Action", values = "GetFederationToken") + UserAndSessionCredentials createFederatedUser(@FormParam("Name") String userName, FederatedUserOptions options); } diff --git a/apis/sts/src/main/java/org/jclouds/sts/STSApiMetadata.java b/apis/sts/src/main/java/org/jclouds/sts/STSApiMetadata.java index 9fc653a480..e5e31f960b 100644 --- a/apis/sts/src/main/java/org/jclouds/sts/STSApiMetadata.java +++ b/apis/sts/src/main/java/org/jclouds/sts/STSApiMetadata.java @@ -25,35 +25,23 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.rest.internal.BaseRestApiMetadata; -import org.jclouds.sts.config.STSRestClientModule; - -import com.google.common.reflect.TypeToken; +import org.jclouds.rest.internal.BaseHttpApiMetadata; +import org.jclouds.sts.config.STSHttpApiModule; /** * Implementation of {@link ApiMetadata} for Amazon's STS api. * * @author Adrian Cole */ -public class STSApiMetadata extends BaseRestApiMetadata { - - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(STSApi.class)} as - * {@link STSAsyncApi} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; +public class STSApiMetadata extends BaseHttpApiMetadata { @Override public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + return new Builder().fromApiMetadata(this); } - @SuppressWarnings("deprecation") public STSApiMetadata() { - this(new Builder(STSApi.class, STSAsyncApi.class)); + this(new Builder()); } protected STSApiMetadata(Builder builder) { @@ -61,16 +49,15 @@ public class STSApiMetadata extends BaseRestApiMetadata { } 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 static class Builder extends BaseHttpApiMetadata.Builder { - protected Builder(Class api, Class asyncApi) { - super(api, asyncApi); + protected Builder() { id("sts") .name("Amazon STS Api") .identityName("Access Key ID") @@ -79,7 +66,7 @@ public class STSApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://docs.amazonwebservices.com/STS/latest/APIReference/")) .defaultEndpoint("https://sts.amazonaws.com") .defaultProperties(STSApiMetadata.defaultProperties()) - .defaultModule(STSRestClientModule.class); + .defaultModule(STSHttpApiModule.class); } @Override diff --git a/apis/sts/src/main/java/org/jclouds/sts/STSAsyncApi.java b/apis/sts/src/main/java/org/jclouds/sts/STSAsyncApi.java deleted file mode 100644 index fdeed7519e..0000000000 --- a/apis/sts/src/main/java/org/jclouds/sts/STSAsyncApi.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.sts; - -import java.io.Closeable; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.domain.SessionCredentials; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.aws.xml.SessionCredentialsHandler; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.sts.domain.UserAndSessionCredentials; -import org.jclouds.sts.options.AssumeRoleOptions; -import org.jclouds.sts.options.FederatedUserOptions; -import org.jclouds.sts.options.SessionCredentialsOptions; -import org.jclouds.sts.xml.UserAndSessionCredentialsHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon STS via the Query API - *

- * - * @see - * @author Adrian Cole - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(STSApi.class)} as - * {@link STSAsyncApi} interface will be removed in jclouds 1.7. - */ -@Deprecated -@RequestFilters(FormSigner.class) -@VirtualHost -public interface STSAsyncApi extends Closeable { - - /** - * @see STSApi#createTemporaryCredentials() - */ - @Named("GetSessionToken") - @POST - @Path("/") - @XMLResponseParser(SessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "GetSessionToken") - ListenableFuture createTemporaryCredentials(); - - /** - * @see STSApi#createTemporaryCredentials(SessionCredentialsOptions) - */ - @Named("GetSessionToken") - @POST - @Path("/") - @XMLResponseParser(SessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "GetSessionToken") - ListenableFuture createTemporaryCredentials(SessionCredentialsOptions options); - - /** - * @see STSApi#assumeRole(String, String) - */ - @Named("AssumeRole") - @POST - @Path("/") - @XMLResponseParser(UserAndSessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "AssumeRole") - ListenableFuture assumeRole(@FormParam("RoleArn") String roleArn, - @FormParam("RoleSessionName") String sessionName); - - /** - * @see STSApi#assumeRole(String, String, AssumeRoleOptions) - */ - @Named("AssumeRole") - @POST - @Path("/") - @XMLResponseParser(UserAndSessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "AssumeRole") - ListenableFuture assumeRole(@FormParam("RoleArn") String roleArn, - @FormParam("RoleSessionName") String sessionName, AssumeRoleOptions options); - - /** - * @see STSApi#createFederatedUser(String) - */ - @Named("GetFederationToken") - @POST - @Path("/") - @XMLResponseParser(UserAndSessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "GetFederationToken") - ListenableFuture createFederatedUser(@FormParam("Name") String userName); - - /** - * @see STSApi#createFederatedUser(FederatedUserOptions) - */ - @Named("GetFederationToken") - @POST - @Path("/") - @XMLResponseParser(UserAndSessionCredentialsHandler.class) - @FormParams(keys = "Action", values = "GetFederationToken") - ListenableFuture createFederatedUser(@FormParam("Name") String userName, FederatedUserOptions options); -} diff --git a/apis/sts/src/main/java/org/jclouds/sts/config/STSRestClientModule.java b/apis/sts/src/main/java/org/jclouds/sts/config/STSHttpApiModule.java similarity index 68% rename from apis/sts/src/main/java/org/jclouds/sts/config/STSRestClientModule.java rename to apis/sts/src/main/java/org/jclouds/sts/config/STSHttpApiModule.java index b912dbd8da..7ec9db4a02 100644 --- a/apis/sts/src/main/java/org/jclouds/sts/config/STSRestClientModule.java +++ b/apis/sts/src/main/java/org/jclouds/sts/config/STSHttpApiModule.java @@ -18,23 +18,16 @@ */ package org.jclouds.sts.config; -import static org.jclouds.reflect.Reflection2.typeToken; - -import org.jclouds.aws.config.FormSigningRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.aws.config.FormSigningHttpApiModule; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.sts.STSApi; -import org.jclouds.sts.STSAsyncApi; /** * Configures the STS connection. * * @author Adrian Cole */ -@ConfiguresRestClient -public class STSRestClientModule extends FormSigningRestClientModule { - - public STSRestClientModule() { - super(typeToken(STSApi.class), typeToken(STSAsyncApi.class)); - } +@ConfiguresHttpApi +public class STSHttpApiModule extends FormSigningHttpApiModule { } diff --git a/apis/sts/src/test/java/org/jclouds/sts/STSApiMetadataTest.java b/apis/sts/src/test/java/org/jclouds/sts/STSApiMetadataTest.java index 98c5431b44..cd9c5ff671 100644 --- a/apis/sts/src/test/java/org/jclouds/sts/STSApiMetadataTest.java +++ b/apis/sts/src/test/java/org/jclouds/sts/STSApiMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.sts; 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; @@ -30,9 +30,9 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole */ @Test(groups = "unit", testName = "STSApiMetadataTest") -public class STSApiMetadataTest extends BaseRestApiMetadataTest { +public class STSApiMetadataTest extends BaseHttpApiMetadataTest { - // no tenant abstraction, yet + // no token abstraction, yet public STSApiMetadataTest() { super(new STSApiMetadata(), ImmutableSet.> of()); } diff --git a/apis/sts/src/test/java/org/jclouds/sts/internal/BaseSTSExpectTest.java b/apis/sts/src/test/java/org/jclouds/sts/internal/BaseSTSExpectTest.java index b4004180e1..288d4cbb37 100644 --- a/apis/sts/src/test/java/org/jclouds/sts/internal/BaseSTSExpectTest.java +++ b/apis/sts/src/test/java/org/jclouds/sts/internal/BaseSTSExpectTest.java @@ -19,8 +19,8 @@ package org.jclouds.sts.internal; import org.jclouds.date.DateService; -import org.jclouds.sts.config.STSRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.sts.config.STSHttpApiModule; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.internal.BaseRestApiExpectTest; import com.google.inject.Module; @@ -35,8 +35,8 @@ public class BaseSTSExpectTest extends BaseRestApiExpectTest { provider = "sts"; } - @ConfiguresRestClient - private static final class TestSTSRestClientModule extends STSRestClientModule { + @ConfiguresHttpApi + private static final class TestSTSHttpApiModule extends STSHttpApiModule { @Override protected String provideTimeStamp(final DateService dateService) { @@ -46,6 +46,6 @@ public class BaseSTSExpectTest extends BaseRestApiExpectTest { @Override protected Module createModule() { - return new TestSTSRestClientModule(); + return new TestSTSHttpApiModule(); } }