RestApiHelper

public class RestApiHelper
extends Object implements IRestApiHelper

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


REST API कॉल करने के लिए, हेल्पर क्लास.

खास जानकारी

कॉन्स्टेंट

int DEFAULT_NUMBER_OF_RETRIES

String JSON_MIME

फ़ील्ड

protected static final JsonFactory JSON_FACTORY

पब्लिक कंस्ट्रक्टर

RestApiHelper(HttpRequestFactory requestFactory, String baseUri)

दी गई जानकारी के साथ, एपीआई हेल्पर इंस्टेंस बनाता है.

पब्लिक मेथड

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

दिए गए यूआरआई के हिस्सों और विकल्पों के साथ, एपीआई कॉल के लिए यूआरआई बनाता है.

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

एपीआई अनुरोध को लागू करता है.

HttpRequestFactory getRequestFactory()

HttpRequestFactory दिखाता है.

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

एपीआई हेल्पर इंस्टेंस बनाता है, जो पुष्टि के लिए Credential का इस्तेमाल करता है.

कॉन्स्टेंट

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

पब्लिक कंस्ट्रक्टर

RestApiHelper

public RestApiHelper (HttpRequestFactory requestFactory, 
                String baseUri)

दी गई जानकारी के साथ, एपीआई हेल्पर इंस्टेंस बनाता है.

पैरामीटर
requestFactory HttpRequestFactory: HttpRequest बनाते समय इस्तेमाल की जाने वाली फ़ैक्ट्री.

baseUri String: एपीआई का बेस यूआरआई

पब्लिक मेथड

buildQueryUri

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

दिए गए यूआरआई के हिस्सों और विकल्पों के साथ, एपीआई कॉल के लिए यूआरआई बनाता है. uriParts को पहले से ही यूआरएल-एनकोड किया जाना चाहिए, जबकि विकल्पों को अनएनकोड किया जाना चाहिए.

पैरामीटर
uriParts String

options Map

रिटर्न
GenericUrl

execute

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

एपीआई अनुरोध को लागू करता है.

पैरामीटर
method String: अनुरोध का एचटीटीपी तरीका

uriParts String: अनुरोध URI बनाने के लिए, यूआरएल एनकोड किए गए यूआरआई के हिस्से.

options Map: क्वेरी स्ट्रिंग बनाने के लिए, अनएनकोड किए गए पैरामीटर के नाम और वैल्यू

data JSONObject: अनुरोध के साथ भेजा जाने वाला डेटा

रिटर्न
HttpResponse HttpResponse ऑब्जेक्ट

अपवाद
IOException

getRequestFactory

public HttpRequestFactory getRequestFactory ()

HttpRequestFactory दिखाता है.

टेस्टिंग के लिए उपलब्ध कराया गया.

रिटर्न
HttpRequestFactory

newInstanceWithGoogleCredential

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

एपीआई हेल्पर इंस्टेंस बनाता है, जो पुष्टि के लिए Credential का इस्तेमाल करता है.

पैरामीटर
baseUri String: एपीआई का बेस यूआरआई

jsonKeyFile File: सेवा खाते की JSON कुंजी वाली फ़ाइल

scopes Collection: सेवा खाते के साथ इस्तेमाल किए जाने वाले OAuth के दायरों का कलेक्शन

रिटर्न
RestApiHelper

अपवाद
java.io.IOException
java.security.GeneralSecurityException
GeneralSecurityException
IOException