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,
지정된 URI 부분과 옵션으로 API 호출의 URI를 구성합니다. |
HttpResponse
|
execute(String method, String[] uriParts,
API 요청을 실행합니다. |
HttpRequestFactory
|
getRequestFactory()
HttpRequestFactory를 반환합니다. |
static
RestApiHelper
|
newInstanceWithGoogleCredential(String baseUri, File jsonKeyFile,
인증에 |
상수
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 |
|
IOException |