Package com.google.api.client.googleapis.services (2.0.1)

Contains the basis for the generated service-specific libraries.

Classes

AbstractGoogleClient

Abstract thread-safe Google client.

AbstractGoogleClient.Builder

Builder for AbstractGoogleClient.

Implementation is not thread-safe.

AbstractGoogleClientRequest<T>

Abstract Google client request for a AbstractGoogleClient.

Implementation is not thread-safe.

CommonGoogleClientRequestInitializer

Google common client request initializer implementation for setting properties like key and userIp.

The simplest usage is to use it to set the key parameter:


 public static final GoogleClientRequestInitializer KEY_INITIALIZER =
        CommonGoogleClientRequestInitializer.newBuilder()
              .setKey(KEY)
              .build();
 

There is also a constructor to set both the key and userIp parameters:


 public static final GoogleClientRequestInitializer INITIALIZER =
 CommonGoogleClientRequestInitializer.newBuilder()
 .setKey(KEY)
 .setUserIp(USER_IP)
 .build();
 

If you want to implement custom logic, extend it like this:


 public static class MyRequestInitializer extends CommonGoogleClientRequestInitializer {

   {@literal @}Override
   public void initialize
       (AbstractGoogleClientRequest{@literal <}?{@literal>} request) throws IOException {
     // custom logic
   }
 }
 

Finally, to set the key and userIp parameters and insert custom logic, extend it like this:


 public static class MyRequestInitializer2 extends CommonGoogleClientRequestInitializer {

   public MyRequestInitializer2() {
     super(KEY, USER_IP);
   }

   {@literal @}Override
   public void initialize
       (AbstractGoogleClientRequest{@literal <}?{@literal>} request) throws IOException {
     super.initialize(request); // must be called to set the key and userIp parameters
     // insert some additional logic
   }
 }
 

Subclasses should be thread-safe.

CommonGoogleClientRequestInitializer.Builder

Builder for CommonGoogleClientRequestInitializer.

Interfaces

GoogleClientRequestInitializer

Google client request initializer.

For example, this might be used to set a key URL query parameter on all requests:


 public class KeyRequestInitializer implements GoogleClientRequestInitializer {
   public void initialize(GoogleClientRequest request) {
     request.put("key", KEY);
   }
 }
 

Implementations should be thread-safe.