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 ซึ่งใช้ Credential สำหรับการรับรองความถูกต้อง

static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes)

สร้างอินสแตนซ์ตัวช่วย API ซึ่งใช้ Credential สำหรับการรับรองความถูกต้อง

ค่าคงที่

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 : ส่วน URI ที่เข้ารหัส URL ที่จะใช้ในการสร้าง 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 : การรวบรวมขอบเขต OAuth เพื่อใช้กับบัญชีบริการ

ส่งคืน
RestApiHelper

พ่น
ข้อยกเว้นความปลอดภัยทั่วไป
IOข้อยกเว้น

ใหม่InstanceWithGoogleCredential

public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, 
                String serviceAccount, 
                File keyFile, 
                 scopes)

สร้างอินสแตนซ์ตัวช่วย API ซึ่งใช้ Credential สำหรับการรับรองความถูกต้อง

พารามิเตอร์
baseUri String : URI พื้นฐานของ API

serviceAccount String : ชื่อของบัญชีบริการที่จะใช้

keyFile File : ไฟล์คีย์บัญชีบริการ

scopes : การรวบรวมขอบเขต OAuth เพื่อใช้กับบัญชีบริการ

ส่งคืน
RestApiHelper

พ่น
ข้อยกเว้นความปลอดภัยทั่วไป
IOข้อยกเว้น