RestApiTrợ giúp
public class RestApiHelper
extends Object
implements IRestApiHelper
java.lang.Object | |
↳ | com.android.tradefed.util.RestApiHelper |
Một lớp trợ giúp để thực hiện các cuộc gọi API REST.
Bản tóm tắt
hằng số | |
---|---|
int | DEFAULT_NUMBER_OF_RETRIES
|
Lĩnh vực | |
---|---|
protected static final JsonFactory | JSON_FACTORY |
protected static final String | JSON_MIME
|
nhà thầu công cộng | |
---|---|
RestApiHelper (HttpRequestFactory requestFactory, String baseUri) Tạo một phiên bản trình trợ giúp API với thông tin đã cho. |
Phương thức công khai | |
---|---|
GenericUrl | buildQueryUri (String[] uriParts, options) buildQueryUri (String[] uriParts, options) Tạo URI cho lệnh gọi API với các phần và tùy chọn URI đã cho. |
HttpResponse | execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data) Thực hiện một yêu cầu API. |
HttpRequestFactory | getRequestFactory () Trả về HttpRequestFactory. |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) Tạo một phiên bản trình trợ giúp API sử dụng |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) Tạo một phiên bản trình trợ giúp API sử dụng |
hằng số
DEFAULT_NUMBER_OF_RETRIES
protected static final int DEFAULT_NUMBER_OF_RETRIES
Giá trị không đổi: 2 (0x00000002)
Lĩnh vực
JSON_FACTORY
protected static final JsonFactory JSON_FACTORY
JSON_MIME
protected static final String JSON_MIME
nhà thầu công cộng
RestApiTrợ giúp
public RestApiHelper (HttpRequestFactory requestFactory, String baseUri)
Tạo một phiên bản trình trợ giúp API với thông tin đã cho.
Thông số | |
---|---|
requestFactory | HttpRequestFactory : nhà máy sẽ sử dụng khi tạo HttpRequest s. |
baseUri | String : URI cơ sở của API |
Phương thức công khai
buildQueryUri
public GenericUrl buildQueryUri (String[] uriParts,options)
Tạo URI cho lệnh gọi API với các phần và tùy chọn URI đã cho. uriParts phải được mã hóa URL, trong khi các tùy chọn phải là Chuỗi chưa được mã hóa.
Thông số | |
---|---|
uriParts | String |
options |
trả lại | |
---|---|
GenericUrl |
hành hình
public HttpResponse execute (String method, String[] uriParts,options, JSONObject data)
Thực hiện một yêu cầu API.
Thông số | |
---|---|
method | String : một phương thức HTTP của yêu cầu |
uriParts | String : Các phần URI được mã hóa URL sẽ được sử dụng để xây dựng URI yêu cầu. |
options | |
data | JSONObject : dữ liệu được gửi cùng với yêu cầu |
trả lại | |
---|---|
HttpResponse | một đối tượng HttpResponse |
getRequestFactory
public HttpRequestFactory getRequestFactory ()
Trả về HttpRequestFactory.
Tiếp xúc để thử nghiệm.
trả lại | |
---|---|
HttpRequestFactory |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile,scopes)
Tạo một phiên bản trình trợ giúp API sử dụng Credential
để xác thực.
Thông số | |
---|---|
baseUri | String : URI cơ sở của API |
jsonKeyFile | File : tệp khóa json của tài khoản dịch vụ |
scopes |
trả lại | |
---|---|
RestApiHelper |
ném | |
---|---|
| Bảo mật chungNgoại lệ |
| IOException |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile,scopes)
Tạo một phiên bản trình trợ giúp API sử dụng Credential
để xác thực.
Thông số | |
---|---|
baseUri | String : URI cơ sở của API |
serviceAccount | String : tên tài khoản dịch vụ sẽ sử dụng |
keyFile | File : tệp khóa tài khoản dịch vụ |
scopes |
trả lại | |
---|---|
RestApiHelper |
ném | |
---|---|
| Bảo mật chungNgoại lệ |
| IOException |