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, Map<String, Object> options)
יוצרים URI לקריאה ל-API עם חלקים ואפשרויות נתונים של URI. |
HttpResponse
|
execute(String method, String[] uriParts, Map<String, Object> options, JSONObject data)
מבצע בקשת API. |
HttpRequestFactory
|
getRequestFactory()
מחזירה את HttpRequestFactory. |
static
RestApiHelper
|
newInstanceWithGoogleCredential(String baseUri, File jsonKeyFile, Collection<String> scopes)
יוצר מופע של 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,
Map<String, Object> options)יוצרים URI לקריאה ל-API עם חלקים ואפשרויות נתונים של URI. צריך לקודד את uriParts כבר בפורמט URL, ואילו options צריכים להיות מחרוזות לא מקודדות.
| פרמטרים | |
|---|---|
uriParts |
String |
options |
Map |
| החזרות | |
|---|---|
GenericUrl |
|
להריץ
public HttpResponse execute (String method,
String[] uriParts,
Map<String, Object> options,
JSONObject data)מבצע בקשת API.
| פרמטרים | |
|---|---|
method |
String: שיטת HTTP של הבקשה |
uriParts |
String: חלקים ב-URI שעברו קידוד URL, שמשמשים ליצירת ה-URI של הבקשה. |
options |
Map: שמות וערכים של פרמטרים לא מקודדים שמשמשים לבניית מחרוזת השאילתה |
data |
JSONObject: הנתונים שיישלחו עם הבקשה |
| החזרות | |
|---|---|
HttpResponse |
אובייקט HttpResponse |
| הקפצת הודעות שגיאה (throw) | |
|---|---|
IOException |
|
getRequestFactory
public HttpRequestFactory getRequestFactory ()
מחזירה את HttpRequestFactory.
חשוף לבדיקה.
| החזרות | |
|---|---|
HttpRequestFactory |
|
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, Collection<String> scopes)
יוצר מופע של API helper שמשתמש ב-Credential לאימות.
| פרמטרים | |
|---|---|
baseUri |
String: ה-URI הבסיסי של ה-API |
jsonKeyFile |
File: קובץ מפתח JSON של חשבון השירות |
scopes |
Collection: אוסף היקפי ההרשאות של OAuth לשימוש עם חשבון השירות |
| החזרות | |
|---|---|
RestApiHelper |
|
| הקפצת הודעות שגיאה (throw) | |
|---|---|
|
java.io.IOException |
|
java.security.GeneralSecurityException |
GeneralSecurityException |
|
IOException |
|