> +
> + @Override
> + public HttpRequest filter(HttpRequest request) throws HttpException {
> + utils.logRequest(signatureLog, request, ">>");
> + Credentials creds = this.creds.get();
> + Authorization auth = cache.getUnchecked(creds);
> +
> + // Replace fixed URL with API URL, except for unit tests tests
> + URI endpoint = request.getEndpoint();
> + if (!endpoint.getHost().equals("localhost")) {
> + endpoint = URI.create(auth.apiUrl() + endpoint.getPath() +
> (endpoint.getQuery() == null ? "" : "?" + endpoint.getQuery()));
> + }
> +
> + request = request.toBuilder()
> + .endpoint(endpoint)
> + // TODO: squirrel away accountId in bogus header so
> ReplacePayloadAccountId can use it
With a minor modification in jclouds core: yes.
Change the `RestAnnotationProcessor` to have the Credentials injected. Then,
add the following line after [these
ones](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java#L229-L230):
```java
tokenValues.put(Constants.PROPERTY_IDENTITY, credentials.identity);
```
With this change in place, you will be able to declare the methods like:
```java
@Named("b2_list_buckets")
@POST
@Path("/b2api/v1/b2_list_buckets")
@PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
@Consumes(APPLICATION_JSON)
BucketList listBuckets();
```
Removing the need for the filters and hacks, as jclouds will already substitute
the identity in the parameter value.
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/270/files/08f67d68c03760ce134ccf217c3b1ee4487ac318#r64120564