RestApiHelper

public class RestApiHelper
extends Object implements IRestApiHelper

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


REST API çağrıları yapmak için yardımcı sınıf.

Özet

Sabitler

int DEFAULT_NUMBER_OF_RETRIES

String JSON_MIME

Alanlar

protected static final JsonFactory JSON_FACTORY

Herkese açık oluşturucular

RestApiHelper(HttpRequestFactory requestFactory, String baseUri)

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

Herkese açık yöntemler

GenericUrl buildQueryUri(String[] uriParts, Map<String, Object> options)

Belirli URI bölümleri ve seçenekleriyle bir API çağrısı için URI oluşturun.

HttpResponse execute(String method, String[] uriParts, Map<String, Object> 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, Collection<String> scopes)

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

Sabitler

DEFAULT_NUMBER_OF_RETRIES

protected static final int DEFAULT_NUMBER_OF_RETRIES

Sabit Değer: 2 (0x00000002)

JSON_MIME

protected static final String JSON_MIME

Sabit Değer: "application/json"

Alanlar

JSON_FACTORY

protected static final JsonFactory JSON_FACTORY

Herkese açık oluşturucular

RestApiHelper

public RestApiHelper (HttpRequestFactory requestFactory, 
                String baseUri)

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

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

baseUri String: API'nin temel URI'si

Herkese açık yöntemler

buildQueryUri

public GenericUrl buildQueryUri (String[] uriParts, 
                Map<String, Object> options)

Belirli URI bölümleri ve seçenekleriyle bir API çağrısı için URI oluşturun. uriParts zaten URL kodlamalı olmalıdır. Seçenekler ise kodlanmamış dizeler olmalıdır.

Parametreler
uriParts String

options Map

İadeler
GenericUrl

execute

public HttpResponse execute (String method, 
                String[] uriParts, 
                Map<String, Object> options, 
                JSONObject data)

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

Parametreler
method String: İsteğin HTTP yöntemi

uriParts String: İstek URI'sini oluşturmak için kullanılacak URL kodlu URI bölümleri.

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

data JSONObject: İstekle birlikte gönderilecek veriler

İadeler
HttpResponse HttpResponse nesnesi

Verdiği hatalar
IOException

getRequestFactory

public HttpRequestFactory getRequestFactory ()

HttpRequestFactory'yi döndürür.

Test için kullanıma sunulmuştur.

İadeler
HttpRequestFactory

newInstanceWithGoogleCredential

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

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

Parametreler
baseUri String: API'nin temel URI'si

jsonKeyFile File: Hizmet hesabı JSON anahtar dosyası

scopes Collection: Hizmet hesabıyla kullanılacak OAuth kapsamları koleksiyonu

İadeler
RestApiHelper

Verdiği hatalar
java.io.IOException
java.security.GeneralSecurityException
GeneralSecurityException
IOException