RestApiHelper

public class RestApiHelper
extends Object implements IRestApiHelper

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


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

概要

定数

int DEFAULT_NUMBER_OF_RETRIES

String JSON_MIME

フィールド

protected static final JsonFactory JSON_FACTORY

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

RestApiHelper(HttpRequestFactory requestFactory, String baseUri)

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

パブリック メソッド

GenericUrl buildQueryUri(String[] uriParts, Map<String, Object> options)

指定された URI の部分とオプションを使用して、API 呼び出しの URI を作成します。

HttpResponse execute(String method, String[] uriParts, Map<String, Object> options, JSONObject data)

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

HttpRequestFactory getRequestFactory()

HttpRequestFactory を返します。

static RestApiHelper newInstanceWithGoogleCredential(String baseUri, File jsonKeyFile, Collection<String> scopes)

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

定数

DEFAULT_NUMBER_OF_RETRIES

protected static final int DEFAULT_NUMBER_OF_RETRIES

定数値: 2 (0x00000002)

JSON_MIME

protected static final String JSON_MIME

定数値: "application/json"

フィールド

JSON_FACTORY

protected static final JsonFactory JSON_FACTORY

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

RestApiHelper

public RestApiHelper (HttpRequestFactory requestFactory, 
                String baseUri)

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

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

baseUri String: API のベース URI

パブリック メソッド

buildQueryUri

public GenericUrl buildQueryUri (String[] uriParts, 
                Map<String, Object> options)

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

パラメータ
uriParts String

options Map

戻り値
GenericUrl

実行

public HttpResponse execute (String method, 
                String[] uriParts, 
                Map<String, Object> options, 
                JSONObject data)

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

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

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

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

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

戻り値
HttpResponse HttpResponse オブジェクト

例外
IOException

getRequestFactory

public HttpRequestFactory getRequestFactory ()

HttpRequestFactory を返します。

テスト用に公開されています。

戻り値
HttpRequestFactory

newInstanceWithGoogleCredential

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

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

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

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

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

戻り値
RestApiHelper

例外
java.io.IOException
java.security.GeneralSecurityException
GeneralSecurityException
IOException