レストアピヘルパー

public class RestApiHelper
extends Object implements IRestApiHelper

java.lang.オブジェクト
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

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

レストアピヘルパー

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

投げる
一般セキュリティ例外
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

投げる
一般セキュリティ例外
IO例外