RestApiHelper
public class RestApiHelper
extends Object
implements IRestApiHelper
java.lang.Object | |
↳ | com.android.tradefed.util.RestApiHelper |
Một lớp người trợ giúp để thực hiện các lệnh gọi API REST.
Tóm lược
Hằng số | |
---|---|
int | DEFAULT_NUMBER_OF_RETRIES
|
Lĩnh vực | |
---|---|
protected static final JsonFactory | JSON_FACTORY |
protected static final String | JSON_MIME
|
Các nhà 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 một URI cho một 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 thể hiện helper API trong đó sử dụng một |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) Tạo một thể hiện helper API trong đó sử dụng một |
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
Các nhà xây dựng công cộng
RestApiHelper
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 một 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, 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 |
Lợi nhuận | |
---|---|
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 yêu cầu |
uriParts | String : URL mã hóa phần URI được sử dụng để xây dựng các yêu cầu URI. |
options | |
data | JSONObject : dữ liệu được gửi với yêu cầu |
Lợi nhuận | |
---|---|
HttpResponse | một đối tượng HttpResponse |
getRequestFactory
public HttpRequestFactory getRequestFactory ()
Trả về HttpRequestFactory.
Phơi để thử nghiệm.
Lợi nhuận | |
---|---|
HttpRequestFactory |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile,scopes)
Tạo một thể hiện helper API trong đó sử dụng một Credential
để xác thực.
Thông số | |
---|---|
baseUri | String : URI cơ sở của API |
jsonKeyFile | File : tài khoản dịch vụ key file json |
scopes |
Lợi nhuận | |
---|---|
RestApiHelper |
Ném | |
---|---|
| GeneralSecurityException |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile,scopes)
Tạo một thể hiện helper API trong đó sử dụng một Credential
để xác thực.
Thông số | |
---|---|
baseUri | String : URI cơ sở của API |
serviceAccount | String : tên của dịch vụ tài khoản để sử dụng |
keyFile | File : dịch vụ tài khoản tập tin quan trọng |
scopes |
Lợi nhuận | |
---|---|
RestApiHelper |
Ném | |
---|---|
| GeneralSecurityException |