com.google.api.client.googleapis.services
Class GoogleClient

java.lang.Object
  extended by com.google.api.client.http.json.JsonHttpClient
      extended by com.google.api.client.googleapis.services.GoogleClient

public class GoogleClient
extends JsonHttpClient

Google API client.

Upgrade warning: prior to version 1.10 there was a builder method in GoogleClient, this has been removed in version 1.10. The Builder can now be instantiated with Builder#Builder(HttpTransport, JsonFactory, String, String, HttpRequestInitializer).

Since:
1.6
Author:
Ravi Mistry

Nested Class Summary
static class GoogleClient.Builder
          Builder for GoogleClient.
 
Constructor Summary
  GoogleClient(HttpTransport transport, JsonFactory jsonFactory, String baseUrl)
          Deprecated. (scheduled to be removed in 1.11) Use GoogleClient(HttpTransport, JsonFactory, String, String, HttpRequestInitializer).
  GoogleClient(HttpTransport transport, JsonFactory jsonFactory, String rootUrl, String servicePath, HttpRequestInitializer httpRequestInitializer)
          Constructor with required parameters.
protected GoogleClient(HttpTransport transport, JsonHttpRequestInitializer jsonHttpRequestInitializer, HttpRequestInitializer httpRequestInitializer, JsonFactory jsonFactory, JsonObjectParser jsonObjectParser, String baseUrl, String applicationName)
          Deprecated. (scheduled to be removed in 1.11) Use GoogleClient(HttpTransport, JsonHttpRequestInitializer, HttpRequestInitializer, JsonFactory, JsonObjectParser, String, String, String)
protected GoogleClient(HttpTransport transport, JsonHttpRequestInitializer jsonHttpRequestInitializer, HttpRequestInitializer httpRequestInitializer, JsonFactory jsonFactory, JsonObjectParser jsonObjectParser, String rootUrl, String servicePath, String applicationName)
          Construct the GoogleClient.
 
Method Summary
 BatchRequest batch()
          Create an BatchRequest object from this Google API client instance.
 BatchRequest batch(HttpRequestInitializer httpRequestInitializer)
          Create an BatchRequest object from this Google API client instance.
protected  HttpRequest buildHttpRequest(HttpMethod method, GenericUrl url, Object body)
          Create an HttpRequest suitable for use against this service.
protected  HttpResponse executeUnparsed(HttpMethod method, GenericUrl url, Object body)
           
protected  HttpResponse executeUnparsed(HttpRequest request)
           
 
Methods inherited from class com.google.api.client.http.json.JsonHttpClient
createParser, createSerializer, executeAsInputStream, getApplicationName, getBaseUrl, getJsonFactory, getJsonHttpParser, getJsonHttpRequestInitializer, getJsonObjectParser, getRequestFactory, getRootUrl, getServicePath, initialize, isBaseUrlUsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GoogleClient

@Deprecated
public GoogleClient(HttpTransport transport,
                               JsonFactory jsonFactory,
                               String baseUrl)
Deprecated. (scheduled to be removed in 1.11) Use GoogleClient(HttpTransport, JsonFactory, String, String, HttpRequestInitializer).

Constructor with required parameters.

Use GoogleClient.Builder if you need to specify any of the optional parameters.

Parameters:
transport - The transport to use for requests
jsonFactory - A factory for creating JSON parsers and serializers
baseUrl - The base URL of the service. Must end with a "/"

GoogleClient

public GoogleClient(HttpTransport transport,
                    JsonFactory jsonFactory,
                    String rootUrl,
                    String servicePath,
                    HttpRequestInitializer httpRequestInitializer)
Constructor with required parameters.

Use GoogleClient.Builder if you need to specify any of the optional parameters.

Parameters:
transport - The transport to use for requests
jsonFactory - A factory for creating JSON parsers and serializers
rootUrl - The root URL of the service. Must end with a "/"
servicePath - The service path of the service. Must end with a "/" and not begin with a "/". It is allowed to be an empty string ""
httpRequestInitializer - The HTTP request initializer or null for none
Since:
1.10

GoogleClient

@Deprecated
protected GoogleClient(HttpTransport transport,
                                  JsonHttpRequestInitializer jsonHttpRequestInitializer,
                                  HttpRequestInitializer httpRequestInitializer,
                                  JsonFactory jsonFactory,
                                  JsonObjectParser jsonObjectParser,
                                  String baseUrl,
                                  String applicationName)
Deprecated. (scheduled to be removed in 1.11) Use GoogleClient(HttpTransport, JsonHttpRequestInitializer, HttpRequestInitializer, JsonFactory, JsonObjectParser, String, String, String)

Construct the GoogleClient.

Parameters:
transport - The transport to use for requests
jsonHttpRequestInitializer - The initializer to use when creating an JsonHttpRequest or null for none
httpRequestInitializer - The initializer to use when creating an HttpRequest or null for none
jsonFactory - A factory for creating JSON parsers and serializers
jsonObjectParser - JSON parser to use or null if unused
baseUrl - The base URL of the service. Must end with a "/"
applicationName - The application name to be sent in the User-Agent header of requests or null for none

GoogleClient

protected GoogleClient(HttpTransport transport,
                       JsonHttpRequestInitializer jsonHttpRequestInitializer,
                       HttpRequestInitializer httpRequestInitializer,
                       JsonFactory jsonFactory,
                       JsonObjectParser jsonObjectParser,
                       String rootUrl,
                       String servicePath,
                       String applicationName)
Construct the GoogleClient.

Parameters:
transport - The transport to use for requests
jsonHttpRequestInitializer - The initializer to use when creating an JsonHttpRequest or null for none
httpRequestInitializer - The initializer to use when creating an HttpRequest or null for none
jsonFactory - A factory for creating JSON parsers and serializers
jsonObjectParser - JSON parser to use or null if unused
rootUrl - The root URL of the service. Must end with a "/"
servicePath - The service path of the service. Must end with a "/" and not begin with a "/". It is allowed to be an empty string ""
applicationName - The application name to be sent in the User-Agent header of requests or null for none
Since:
1.10
Method Detail

buildHttpRequest

protected HttpRequest buildHttpRequest(HttpMethod method,
                                       GenericUrl url,
                                       Object body)
                                throws IOException
Create an HttpRequest suitable for use against this service.

Overrides:
buildHttpRequest in class JsonHttpClient
Parameters:
method - HTTP Method type
url - The complete URL of the service where requests should be sent. It includes the base path along with the URI template
body - A POJO that can be serialized into JSON or null for none
Returns:
newly created HttpRequest
Throws:
IOException

batch

public BatchRequest batch()
Create an BatchRequest object from this Google API client instance.

Sample usage:

     client.batch()
         .queue(...)
         .queue(...)
         .execute();
 

Returns:
newly created Batch request

batch

public BatchRequest batch(HttpRequestInitializer httpRequestInitializer)
Create an BatchRequest object from this Google API client instance.

Sample usage:

     client.batch(httpRequestInitializer)
         .queue(...)
         .queue(...)
         .execute();
 

Parameters:
httpRequestInitializer - The initializer to use when creating the top-level batch HTTP request or null for none
Returns:
newly created Batch request

executeUnparsed

protected HttpResponse executeUnparsed(HttpMethod method,
                                       GenericUrl url,
                                       Object body)
                                throws IOException
Overrides:
executeUnparsed in class JsonHttpClient
Throws:
IOException

executeUnparsed

protected HttpResponse executeUnparsed(HttpRequest request)
                                throws IOException
Overrides:
executeUnparsed in class JsonHttpClient
Throws:
IOException


Copyright © 2010-2012 Google. All Rights Reserved.