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, options) buildQueryUri (String[] uriParts, options) สร้าง URI สำหรับการเรียก API ด้วยส่วน URI และตัวเลือกที่กำหนด |
HttpResponse | execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data) ดำเนินการตามคำขอ API |
HttpRequestFactory | getRequestFactory () ส่งกลับ HttpRequestFactory |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) สร้างอินสแตนซ์ API ผู้ช่วยซึ่งใช้ |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) สร้างอินสแตนซ์ API ผู้ช่วยซึ่งใช้ |
ค่าคงที่
DEFAULT_NUMBER_OF_RETIES
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 s |
baseUri | String : ฐาน URI ของ API |
วิธีการสาธารณะ
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 : URL เข้ารหัสส่วน URI ที่จะใช้ในการสร้าง URI คำขอ |
options | |
data | JSONObject : ข้อมูลที่จะส่งไปพร้อมกับคำขอ |
คืนสินค้า | |
---|---|
HttpResponse | ออบเจ็กต์ HttpResponse |
getRequestFactory
public HttpRequestFactory getRequestFactory ()
ส่งกลับ HttpRequestFactory
เปิดเผยสำหรับการทดสอบ
คืนสินค้า | |
---|---|
HttpRequestFactory |
ใหม่InstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile,scopes)
สร้างอินสแตนซ์ API ผู้ช่วยซึ่งใช้ Credential
สำหรับการตรวจสอบ
พารามิเตอร์ | |
---|---|
baseUri | String : ฐาน URI ของ API ได้ |
jsonKeyFile | File : บัญชีบริการไฟล์คีย์ JSON |
scopes |
คืนสินค้า | |
---|---|
RestApiHelper |
ขว้าง | |
---|---|
| GeneralSecurityException |
ใหม่InstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile,scopes)
สร้างอินสแตนซ์ API ผู้ช่วยซึ่งใช้ Credential
สำหรับการตรวจสอบ
พารามิเตอร์ | |
---|---|
baseUri | String : ฐาน URI ของ API ได้ |
serviceAccount | String : ชื่อของบริการบัญชีกับการใช้งาน |
keyFile | File : บัญชีบริการไฟล์ที่สำคัญ |
scopes |
คืนสินค้า | |
---|---|
RestApiHelper |
ขว้าง | |
---|---|
| GeneralSecurityException |