This table attempts to document the annotations that can be used by jclouds developers to write cloud APIs. These annotations are used by the RestAnnotationProcessor to help produce the requests and consume the responses. There are many combinations and interactions between the annotations. Please document them as you discover them.  

 

Annotation

Target

Applies To

Purpose

Java Example

Output Example

@Consumes

Type

Request Headers

Add or replace the Accept header for every call in the Type with whatever value you specify.

@Consumes(MediaType.APPLICATION_JSON) 
public interface MyCloudApi extends Closeable

Accept: application/json

@MapBinder

Method

Request Body

Allows mapping @PayloadParams to a custom-structured construct of Map<> by using a binder class

@MapBinder(ComplexCreateSomethingRequestBinder.class)

A set of parameters to A complex request such as a large nested json structure

@ResponseParser

Method

Response Body

Specify a Function class that will be used to apply a JSON transform (for example) or another type or response parsing

@ResponseParser(ParsePasswordFromRootedInstance.class)

{ "user": { "name": "root", "password": "12345" }} to 12345

@SelectJson

Method

Response Body

Extracts the value for the specified key

@SelectJson("keyName")

{"keyName": {"name": "example.com"}} to {"name": "example.com"}

@Unwrap

Method

Response Body

Unwraps a value nested one level deep

@Unwrap

{ "foo": "bar" } to "bar"

@WrapWith

Method

Request Body

Wraps the payload in json nested one level deep

@WrapWith("domains") create(Iterable<CreateDomain> createDomains)

{ "domains": [ {"name": "example.com", ...}, {...} ] }

@WrapWith

Parameter

Request Body

Wraps the payload in json nested one level deep

create(@WrapWith("domains") Iterable<CreateDomain> createDomains)

{ "domains": [ {"name": "example.com", ...}, {...} ] }

  • No labels