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_RETRIES

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

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

newInstanceWithGoogleCredential

public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, 
                File jsonKeyFile, 
                 scopes)

สร้างอินสแตนซ์ตัวช่วย API ซึ่งใช้ Credential ในการตรวจสอบสิทธิ์

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

jsonKeyFile File : ไฟล์คีย์ json ของบัญชีบริการ

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

การส่งคืน
RestApiHelper

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

newInstanceWithGoogleCredential

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ข้อยกเว้น