RestApiHelper

public class RestApiHelper
extends Object implements IRestApiHelper

java.lang.Object
com.android.tradefed.util.RestApiHelper


REST API 呼び出しを実行するためのヘルパー クラス。

まとめ

定数

int DEFAULT_NUMBER_OF_RETRIES

田畑

protected static final JsonFactory JSON_FACTORY

protected static final String JSON_MIME

パブリック コンストラクター

RestApiHelper (HttpRequestFactory requestFactory, String baseUri)

指定された情報で API ヘルパー インスタンスを作成します。

公開メソッド

GenericUrl buildQueryUri (String[] uriParts, options) buildQueryUri (String[] uriParts, options)

指定された URI パーツとオプションを使用して、API 呼び出しの URI を構築します。

HttpResponse execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data)

API リクエストを実行します。

HttpRequestFactory getRequestFactory ()

HttpRequestFactory を返します。

static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes)

認証にCredentialを使用する API ヘルパー インスタンスを作成します。

static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes)

認証にCredentialを使用する API ヘルパー インスタンスを作成します。

定数

DEFAULT_NUMBER_OF_RETRIES

protected static final int DEFAULT_NUMBER_OF_RETRIES

定数値: 2 (0x00000002)

田畑

JSON_FACTORY

protected static final JsonFactory JSON_FACTORY

JSON_MIME

protected static final String JSON_MIME

パブリック コンストラクター

RestApiHelper

public RestApiHelper (HttpRequestFactory requestFactory, 
                String baseUri)

指定された情報で API ヘルパー インスタンスを作成します。

パラメーター
requestFactory HttpRequestFactory : HttpRequestの作成時に使用するファクトリ。

baseUri String : API のベース URI

公開メソッド

buildQueryUri

public GenericUrl buildQueryUri (String[] uriParts, 
                 options)

指定された URI パーツとオプションを使用して、API 呼び出しの URI を構築します。 uriParts は既に URL エンコードされている必要がありますが、オプションはエンコードされていない文字列である必要があります。

パラメーター
uriParts String

options

戻り値
GenericUrl

実行する

public HttpResponse execute (String method, 
                String[] uriParts, 
                 options, 
                JSONObject data)

API リクエストを実行します。

パラメーター
method String : リクエストの HTTP メソッド

uriParts String : リクエスト URI の構築に使用される URL エンコードされた URI パーツ。

options : クエリ文字列の作成に使用されるエンコードされていないパラメーター名と値

data JSONObject : リクエストとともに送信されるデータ

戻り値
HttpResponse HttpResponse オブジェクト

getRequestFactory

public HttpRequestFactory getRequestFactory ()

HttpRequestFactory を返します。

テストのために公開。

戻り値
HttpRequestFactory

newInstanceWithGoogleCredential

public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, 
                File jsonKeyFile, 
                 scopes)

認証にCredentialを使用する API ヘルパー インスタンスを作成します。

パラメーター
baseUri String : API のベース URI

jsonKeyFile File : サービス アカウントの json キー ファイル

scopes : サービス アカウントで使用する OAuth スコープのコレクション

戻り値
RestApiHelper

スロー
GeneralSecurityException
IO例外

newInstanceWithGoogleCredential

public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, 
                String serviceAccount, 
                File keyFile, 
                 scopes)

認証にCredentialを使用する API ヘルパー インスタンスを作成します。

パラメーター
baseUri String : API のベース URI

serviceAccount String : 使用するサービス アカウントの名前

keyFile File : サービス アカウント キー ファイル

scopes : サービス アカウントで使用する OAuth スコープのコレクション

戻り値
RestApiHelper

スロー
GeneralSecurityException
IO例外