RestApiHelper
public
class
RestApiHelper
extends Object
implements
IRestApiHelper
| java.lang.Object | |
| ↳ | com.android.tradefed.util.RestApiHelper |
מחלקת עזר לביצוע קריאות ל-API ל-REST.
סיכום
ערכים קבועים | |
|---|---|
int |
DEFAULT_NUMBER_OF_RETRIES
|
String |
JSON_MIME
|
שדות | |
|---|---|
protected
static
final
JsonFactory |
JSON_FACTORY
|
Constructors ציבוריים | |
|---|---|
RestApiHelper(HttpRequestFactory requestFactory, String baseUri)
יוצר מופע של כלי עזר ל-API עם המידע שצוין. |
|
methods ציבוריים | |
|---|---|
GenericUrl
|
buildQueryUri(String[] uriParts,
יוצרים URI לקריאה ל-API עם חלקים ואפשרויות נתונים של URI. |
HttpResponse
|
execute(String method, String[] uriParts,
מבצע בקשת API. |
HttpRequestFactory
|
getRequestFactory()
מחזירה את HttpRequestFactory. |
static
RestApiHelper
|
newInstanceWithGoogleCredential(String baseUri, File jsonKeyFile,
יוצר מופע של API helper שמשתמש ב- |
ערכים קבועים
DEFAULT_NUMBER_OF_RETRIES
protected static final int DEFAULT_NUMBER_OF_RETRIES
ערך קבוע: 2 (0x00000002)
JSON_MIME
protected static final String JSON_MIME
ערך קבוע: "application/json"
שדות
JSON_FACTORY
protected static final JsonFactory JSON_FACTORY
Constructors ציבוריים
RestApiHelper
public RestApiHelper (HttpRequestFactory requestFactory,
String baseUri)יוצר מופע של כלי עזר ל-API עם המידע שצוין.
| פרמטרים | |
|---|---|
requestFactory |
HttpRequestFactory: המפעל שבו משתמשים כשיוצרים HttpRequests. |
baseUri |
String: ה-URI הבסיסי של ה-API |
methods ציבוריים
buildQueryUri
public GenericUrl buildQueryUri (String[] uriParts,
options) יוצרים URI לקריאה ל-API עם חלקים ואפשרויות נתונים של URI. צריך לקודד את uriParts באמצעות קידוד URL, ואת options צריך להשאיר כמחרוזות לא מקודדות.
| פרמטרים | |
|---|---|
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 helper שמשתמש ב-Credential לאימות.
| פרמטרים | |
|---|---|
baseUri |
String: ה-URI הבסיסי של ה-API |
jsonKeyFile |
File: קובץ מפתח JSON של חשבון השירות |
scopes |
: אוסף היקפי ההרשאות של OAuth לשימוש עם חשבון השירות |
| החזרות | |
|---|---|
RestApiHelper |
|
| זריקות | |
|---|---|
|
GeneralSecurityException |
|
IOException |