REST Proxies

The `juneau-rest-client` library can also be used to define interface proxies against 3rd-party REST interfaces.
This is an extremely powerful feature that allows you to quickly define easy-to-use interfaces against virtually any REST interface.

Remote resources are instantiated using one of the following methods:

- {@link oajrc.RestClient}
  - {@link oajrc.RestClient#getRemoteResource(Class) getRemoteResource(Class)}
  - {@link oajrc.RestClient#getRemoteResource(Class,Object) getRemoteResource(Class,Object)}
  - {@link oajrc.RestClient#getRemoteResource(Class,Object,Serializer,Parser) getRemoteResource(Class,Object,Serializer,Parser)}

Annotations are used on the interface and interface methods to specify how to convert input and output to HTTP headers, query parameters, form post parameters, or request/response bodies.

- {@link oajrc.remote}
  - {@link oajrc.remote.RemoteResource}
  - {@link oajrc.remote.RemoteMethod}
- {@link oaj.http.annotation}
  - {@link oaj.http.annotation.Body Body}
  - {@link oaj.http.annotation.Header Header}
  - {@link oaj.http.annotation.FormData FormData}
  - {@link oaj.http.annotation.Query Query}
  - {@link oaj.http.annotation.Path Path}
  - {@link oaj.http.annotation.Request Request}
  - {@link oaj.http.annotation.Response Response}

##### Example:

@RemoteResource(path="/petstore") public interface PetStore { @RemoteMethod(httpMethod=POST, path="/pets") String addPet( @Body CreatePet pet, @Header("E-Tag") UUID etag, @Query("debug") boolean debug ); }

// Use a RestClient with default Simple JSON support. try (RestClient client = RestClient. create().simpleJson().build()) { PetStore store = client.getRemoteResource(PetStore. class, "http://localhost:10000"); CreatePet pet = new CreatePet("Fluffy", 9.99); String response = store.createPet(pet, UUID. randomUUID(), true); }

The call above translates to the following REST call:

POST http://localhost:10000/petstore/pets?debug=true HTTP/1.1 Accept: application/json Content-Type: application/json E-Tag: 475588d4-0b27-4f56-9296-cc683251d314 { name: 'Fluffy', price: 9.99 }