RestApiHelper

public class RestApiHelper
extends Object implements IRestApiHelper

java.lang.Object
com.android.tradefed.util.RestApiHelper


REST API çağrılarını gerçekleştirmek için bir yardımcı sınıf.

Özet

Sabitler

int DEFAULT_NUMBER_OF_RETRIES

Alanlar

protected static final JsonFactory JSON_FACTORY

protected static final String JSON_MIME

Kamu inşaatçıları

RestApiHelper (HttpRequestFactory requestFactory, String baseUri)

Verilen bilgilerle bir API yardımcı örneği oluşturur.

Genel yöntemler

GenericUrl buildQueryUri (String[] uriParts, options) buildQueryUri (String[] uriParts, options)

Verilen URI parçaları ve seçenekleriyle bir API çağrısı için bir URI oluşturun.

HttpResponse execute (String method, String[] uriParts, options, JSONObject data) execute (String method, String[] uriParts, options, JSONObject data)

Bir API isteğini yürütür.

HttpRequestFactory getRequestFactory ()

HttpRequestFactory'yi döndürür.

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

Kimlik doğrulama için Credential kullanan bir API yardımcı örneği oluşturur.

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

Kimlik doğrulama için Credential kullanan bir API yardımcı örneği oluşturur.

Sabitler

DEFAULT_NUMBER_OF_RETRIES

protected static final int DEFAULT_NUMBER_OF_RETRIES

Sabit Değer: 2 (0x00000002)

Alanlar

JSON_FACTORY

protected static final JsonFactory JSON_FACTORY

JSON_MIME

protected static final String JSON_MIME

Kamu inşaatçıları

RestApiHelper

public RestApiHelper (HttpRequestFactory requestFactory, 
                String baseUri)

Verilen bilgilerle bir API yardımcı örneği oluşturur.

Parametreler
requestFactory HttpRequestFactory : HttpRequest oluştururken kullanılacak fabrika.

baseUri String : API'nin temel URI'si

Genel yöntemler

buildQueryUri

public GenericUrl buildQueryUri (String[] uriParts, 
                 options)

Verilen URI parçaları ve seçenekleriyle bir API çağrısı için bir URI oluşturun. uriParts zaten URL kodlu olmalı, seçenekler ise kodlanmamış Dizeler olmalıdır.

Parametreler
uriParts String

options

İadeler
GenericUrl

uygulamak

public HttpResponse execute (String method, 
                String[] uriParts, 
                 options, 
                JSONObject data)

Bir API isteğini yürütür.

Parametreler
method String : isteğin HTTP yöntemi

uriParts String : İstek URI'sini oluşturmak için kullanılacak URL kodlu URI parçaları.

options : sorgu dizesini oluşturmak için kullanılan kodlanmamış parametre adları ve değerleri

data JSONObject : istekle birlikte gönderilecek veriler

İadeler
HttpResponse bir HttpResponse nesnesi

getRequestFactory

public HttpRequestFactory getRequestFactory ()

HttpRequestFactory'yi döndürür.

Test için açığa çıkarıldı.

İadeler
HttpRequestFactory

newInstanceWithGoogleCredential

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

Kimlik doğrulama için Credential kullanan bir API yardımcı örneği oluşturur.

Parametreler
baseUri String : API'nin temel URI'si

jsonKeyFile File : hizmet hesabı json anahtar dosyası

scopes : hizmet hesabıyla kullanılacak OAuth kapsamlarının toplanması

İadeler
RestApiHelper

Atar
GenelGüvenlikİstisnası
IO İstisnası

newInstanceWithGoogleCredential

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

Kimlik doğrulama için Credential kullanan bir API yardımcı örneği oluşturur.

Parametreler
baseUri String : API'nin temel URI'si

serviceAccount String : kullanılacak hizmet hesabının adı

keyFile File : hizmet hesabı anahtar dosyası

scopes : hizmet hesabıyla kullanılacak OAuth kapsamlarının toplanması

İadeler
RestApiHelper

Atar
GenelGüvenlikİstisnası
IO İstisnası