RestApiHelper
public class RestApiHelper
extends Object
implements IRestApiHelper
java.lang.Obiekt | |
↳ | com.android.tradefed.util.RestApiHelper |
Klasa pomocnicza do wykonywania wywołań API REST.
Streszczenie
Stałe | |
---|---|
int | DEFAULT_NUMBER_OF_RETRIES
|
Pola | |
---|---|
protected static final JsonFactory | JSON_FACTORY |
protected static final String | JSON_MIME
|
Konstruktory publiczne | |
---|---|
RestApiHelper (HttpRequestFactory requestFactory, String baseUri) Tworzy instancję pomocnika interfejsu API z podanymi informacjami. |
Metody publiczne | |
---|---|
GenericUrl | buildQueryUri (String[] uriParts, options) buildQueryUri (String[] uriParts, options) Skonstruuj URI dla wywołania API z podanymi częściami i opcjami URI. |
HttpResponse | execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data) Wykonuje żądanie API. |
HttpRequestFactory | getRequestFactory () Zwraca HttpRequestFactory. |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile, scopes) Tworzy instancję pomocnika interfejsu API, która używa |
static RestApiHelper | newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile, scopes) Tworzy instancję pomocnika interfejsu API, która używa |
Stałe
DEFAULT_NUMBER_OF_RETRIES
protected static final int DEFAULT_NUMBER_OF_RETRIES
Stała wartość: 2 (0x00000002)
Pola
JSON_FACTORY
protected static final JsonFactory JSON_FACTORY
JSON_MIME
protected static final String JSON_MIME
Konstruktory publiczne
RestApiHelper
public RestApiHelper (HttpRequestFactory requestFactory, String baseUri)
Tworzy instancję pomocnika interfejsu API z podanymi informacjami.
Parametry | |
---|---|
requestFactory | HttpRequestFactory : fabryka używana podczas tworzenia HttpRequest s. |
baseUri | String : podstawowy identyfikator URI interfejsu API |
Metody publiczne
buildQueryUri
public GenericUrl buildQueryUri (String[] uriParts,options)
Skonstruuj URI dla wywołania API z podanymi częściami i opcjami URI. uriParts powinny być już zakodowane w adresie URL, podczas gdy opcje powinny być niezakodowanymi ciągami znaków.
Parametry | |
---|---|
uriParts | String |
options |
Zwroty | |
---|---|
GenericUrl |
wykonać
public HttpResponse execute (String method, String[] uriParts,options, JSONObject data)
Wykonuje żądanie API.
Parametry | |
---|---|
method | String : metoda HTTP żądania |
uriParts | String : części URI zakodowane w adresie URL, które mają być użyte do skonstruowania identyfikatora URI żądania. |
options | |
data | JSONObject : dane do wysłania wraz z żądaniem |
Zwroty | |
---|---|
HttpResponse | obiekt HttpResponse |
getRequestFactory
public HttpRequestFactory getRequestFactory ()
Zwraca HttpRequestFactory.
Wystawiony do testów.
Zwroty | |
---|---|
HttpRequestFactory |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, File jsonKeyFile,scopes)
Tworzy instancję pomocnika interfejsu API, która używa Credential
do uwierzytelniania.
Parametry | |
---|---|
baseUri | String : podstawowy identyfikator URI interfejsu API |
jsonKeyFile | File : plik klucza json konta usługi |
scopes |
Zwroty | |
---|---|
RestApiHelper |
Rzuty | |
---|---|
| Wyjątek bezpieczeństwa ogólnego |
| IOException |
newInstanceWithGoogleCredential
public static RestApiHelper newInstanceWithGoogleCredential (String baseUri, String serviceAccount, File keyFile,scopes)
Tworzy instancję pomocnika interfejsu API, która używa Credential
do uwierzytelniania.
Parametry | |
---|---|
baseUri | String : podstawowy identyfikator URI interfejsu API |
serviceAccount | String : nazwa konta usługi do użycia |
keyFile | File : plik klucza konta usługi |
scopes |
Zwroty | |
---|---|
RestApiHelper |
Rzuty | |
---|---|
| Wyjątek bezpieczeństwa ogólnego |
| IOException |