Phần còn lạiApiHelper
public class RestApiHelper
extends Object
implements IRestApiHelper
java.lang.Object | |
↳ | com.android.tradefed.util.RestApiHelper |
Lớp trợ giúp để thực hiện lệnh 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 xây dựng 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 pháp công khai | |
---|---|
GenericUrl | buildQueryUri (String[] uriParts, options) buildQueryUri (String[] uriParts, options) Xây dựng URI cho lệnh gọi API với các phần và tùy chọn URI nhất định. |
HttpResponse | execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data) Thực thi 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 xây dựng công cộng
Phần còn lạiApiHelper
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ử dụng khi tạo HttpRequest s. |
baseUri | String : URI cơ sở của API |
Phương pháp công khai
buildQueryUri
public GenericUrl buildQueryUri (String[] uriParts,options)
Xây dựng URI cho lệnh gọi API với các phần và tùy chọn URI nhất định. uriParts phải được mã hóa URL rồi, trong khi các tùy chọn phải là Chuỗi không đượ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 thi 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 | |
---|---|
| ChungAn ninhNgoại lệ |
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 | |
---|---|
| ChungAn ninhNgoại lệ |