GoogleApiClientUtilBase

public class GoogleApiClientUtilBase
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.gcs.GoogleApiClientUtilBase


Summary

Fields

public static final String APP_NAME

Public constructors

GoogleApiClientUtilBase()

Public methods

static HttpRequestInitializer configureRetryStrategy(HttpRequestInitializer initializer)

Setup a retry strategy for the provided HttpRequestInitializer.

static HttpRequestInitializer configureRetryStrategyAndTimeout(HttpRequestInitializer initializer, int connectTimeout, int readTimeout)

Setup a retry strategy for the provided HttpRequestInitializer.

static Credentials createCredential( scopes)

Try to create Google API credential with default credential.

static Credentials createCredentialFromJsonKeyFile(File file, scopes)

Create credential from json key file.

static HttpRequestInitializer setHttpTimeout(HttpRequestInitializer requestInitializer, int connectTimeout, int readTimeout)

Protected methods

Credentials doCreateCredentialFromJsonKeyFile(File file, scopes)
Credentials doCreateDefaultCredential( scopes)

Fields

APP_NAME

public static final String APP_NAME

Public constructors

GoogleApiClientUtilBase

public GoogleApiClientUtilBase ()

Public methods

configureRetryStrategy

public static HttpRequestInitializer configureRetryStrategy (HttpRequestInitializer initializer)

Setup a retry strategy for the provided HttpRequestInitializer. In case of server errors requests will be automatically retried with an exponential backoff.

Parameters
initializer HttpRequestInitializer: - an initializer which will setup a retry strategy.

Returns
HttpRequestInitializer an initializer that will retry failed requests automatically.

configureRetryStrategyAndTimeout

public static HttpRequestInitializer configureRetryStrategyAndTimeout (HttpRequestInitializer initializer, 
                int connectTimeout, 
                int readTimeout)

Setup a retry strategy for the provided HttpRequestInitializer. In case of server errors requests will be automatically retried with an exponential backoff.

Parameters
initializer HttpRequestInitializer: - an initializer which will setup a retry strategy.

connectTimeout int

readTimeout int

Returns
HttpRequestInitializer an initializer that will retry failed requests automatically.

createCredential

public static Credentials createCredential ( scopes)

Try to create Google API credential with default credential.

Only default credential is used.

Parameters
scopes : scopes for the credential.

Returns
Credentials a Credential

Throws
IOException
GeneralSecurityException

createCredentialFromJsonKeyFile

public static Credentials createCredentialFromJsonKeyFile (File file, 
                 scopes)

Create credential from json key file.

Parameters
file File: is the p12 key file

scopes : is the API's scope.

Returns
Credentials a Credential.

Throws
FileNotFoundException
IOException
GeneralSecurityException

setHttpTimeout

public static HttpRequestInitializer setHttpTimeout (HttpRequestInitializer requestInitializer, 
                int connectTimeout, 
                int readTimeout)

Parameters
requestInitializer HttpRequestInitializer: a HttpRequestInitializer, normally it's Credential.

connectTimeout int: connect timeout in milliseconds.

readTimeout int: read timeout in milliseconds.

Returns
HttpRequestInitializer a HttpRequestInitializer with timeout.

Protected methods

doCreateCredentialFromJsonKeyFile

protected Credentials doCreateCredentialFromJsonKeyFile (File file, 
                 scopes)

Parameters
file File

scopes

Returns
Credentials

doCreateDefaultCredential

protected Credentials doCreateDefaultCredential ( scopes)

Parameters
scopes

Returns
Credentials