com.jakewharton.pingdom
Class PingdomApiService

java.lang.Object
  extended by com.jakewharton.apibuilder.ApiService
      extended by com.jakewharton.pingdom.PingdomApiService
Direct Known Subclasses:
ActionsService, AnalysisService, CheckService, ContactService, ProbeService, ReferenceService, ReportsEmailService, ReportsPublicService, ReportsSharedService, ResultsService, ServerTimeService, SettingsService, SummaryAverageService, SummaryOutageService, SummaryPerformanceService, SummaryProbeService, TraceRouteService

public abstract class PingdomApiService
extends com.jakewharton.apibuilder.ApiService

Pingdom-specific API service extension which facilitates provides helper methods for performing remote method calls as well as deserializing the corresponding JSON responses.

Author:
Jake Wharton

Field Summary
 
Fields inherited from class com.jakewharton.apibuilder.ApiService
CONTENT_ENCODING
 
Constructor Summary
PingdomApiService()
          Create a new Pingdom service with our proper default values.
 
Method Summary
 com.google.gson.JsonObject delete(String url)
          Execute request using HTTP DELETE.
 com.google.gson.JsonObject get(String url)
          Execute request using HTTP GET.
 com.google.gson.JsonObject post(String url, Map<String,String> parameters)
          Execute request using HTTP POST.
 com.google.gson.JsonObject put(String url, Map<String,String> parameters)
          Execute request using HTTP PUT.
 void setApiVersion(double apiVersion)
          Set the API version.
 void setAppKey(String value)
          Set API key to use for client authentication by Pingdom.
 void setAuthentication(String email, String password)
          Set email and password to use for HTTP basic authentication.
protected  com.google.gson.JsonObject unmarshall(InputStream jsonContent)
          Read the entirety of an input stream and parse to a JSON object.
protected
<T> T
unmarshall(com.google.gson.reflect.TypeToken<T> typeToken, com.google.gson.JsonElement response)
          Use GSON to deserialize a JSON object to a native class representation.
 
Methods inherited from class com.jakewharton.apibuilder.ApiService
acceptGzip, addRequestHeader, closeConnection, closeStream, convertStreamToString, executeDelete, executeDelete, executeGet, executeGet, executeMethod, executePost, executePost, getConnectTimeout, getParametersString, getReadTimeout, getWrappedInputStream, removeRequestHeader, setConnectTimeout, setReadTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PingdomApiService

public PingdomApiService()
Create a new Pingdom service with our proper default values.

Method Detail

get

public com.google.gson.JsonObject get(String url)
Execute request using HTTP GET.

Parameters:
url - URL to request.
Returns:
JSON object.

post

public com.google.gson.JsonObject post(String url,
                                       Map<String,String> parameters)
Execute request using HTTP POST.

Parameters:
url - URL to request.
parameters - Parameters to place in the request body.
Returns:
JSON object.

delete

public com.google.gson.JsonObject delete(String url)
Execute request using HTTP DELETE.

Parameters:
url - URL to request.
Returns:
JSON object.

put

public com.google.gson.JsonObject put(String url,
                                      Map<String,String> parameters)
Execute request using HTTP PUT.

Parameters:
url - URL to request.
parameters - Parameters to place in request body.
Returns:
JSON object.

setAuthentication

public void setAuthentication(String email,
                              String password)
Set email and password to use for HTTP basic authentication.

Parameters:
email - Email.
password - Password.

setAppKey

public void setAppKey(String value)
Set API key to use for client authentication by Pingdom.

Parameters:
value - API key.

setApiVersion

public void setApiVersion(double apiVersion)
Set the API version.

Parameters:
apiVersion - API version.

unmarshall

protected <T> T unmarshall(com.google.gson.reflect.TypeToken<T> typeToken,
                           com.google.gson.JsonElement response)
Use GSON to deserialize a JSON object to a native class representation.

Type Parameters:
T - Native class type.
Parameters:
typeToken - Native class type wrapper.
response - Serialized JSON object.
Returns:
Deserialized native instance.

unmarshall

protected com.google.gson.JsonObject unmarshall(InputStream jsonContent)
Read the entirety of an input stream and parse to a JSON object.

Parameters:
jsonContent - JSON content input stream.
Returns:
Parsed JSON object.


Copyright © 2011 Jake Wharton. All Rights Reserved.