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, options)

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

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

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

HttpRequestFactory getRequestFactory()

HttpRequestFactory を返します。

static RestApiHelper newInstanceWithGoogleCredential(String baseUri, File jsonKeyFile, 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, 
                 options)

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

パラメータ
uriParts String

options

戻り値
GenericUrl

execute

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
IOException