com.globo.dnsapi
Class AbstractAPI<T>

java.lang.Object
  extended by com.globo.dnsapi.AbstractAPI<T>
Direct Known Subclasses:
AuthAPI, DomainAPI, ExportAPI, RecordAPI

public abstract class AbstractAPI<T>
extends Object


Constructor Summary
protected AbstractAPI(DNSAPI dnsapi)
           
 
Method Summary
protected  com.google.api.client.http.HttpRequestFactory buildHttpRequestFactory()
          Customize HttpRequestFactory with authentication and error handling.
protected  com.google.api.client.http.GenericUrl buildUrl(String suffixUrl)
           
protected  DNSAPIRoot<T> delete(String suffixUrl, boolean returnsList)
           
protected  DNSAPIRoot<T> get(String suffixUrl, boolean returnsList)
           
protected  DNSAPI getDnsapi()
           
protected abstract  Type getListType()
           
protected abstract  Type getType()
           
protected  void handleExceptionIfNeeded(com.google.api.client.http.HttpResponse response)
          Exception treatment for generic calls
protected  void insertAuthenticationHeaders(com.google.api.client.http.HttpRequest request)
           
protected  void interceptRequest(com.google.api.client.http.HttpRequest request)
          Run before each request runs.
protected  void interceptResponse(com.google.api.client.http.HttpResponse response)
          Run after each request complete (with or without success).
protected
<E> DNSAPIRoot<E>
parse(com.google.api.client.http.HttpResponse response, Type type)
           
protected
<E> DNSAPIRoot<E>
parse(String responseAsString, Type type)
          Convert an HttpResponse object to DNSAPIRoot of E object.
protected  DNSAPIRoot<T> post(String suffixUrl, Object payload, boolean returnsList)
           
protected  DNSAPIRoot<T> put(String suffixUrl, Object payload, boolean returnsList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAPI

protected AbstractAPI(DNSAPI dnsapi)
Method Detail

getDnsapi

protected DNSAPI getDnsapi()

getType

protected abstract Type getType()

getListType

protected abstract Type getListType()

buildHttpRequestFactory

protected com.google.api.client.http.HttpRequestFactory buildHttpRequestFactory()
Customize HttpRequestFactory with authentication and error handling.

Returns:
new instance of HttpRequestFactory

interceptRequest

protected void interceptRequest(com.google.api.client.http.HttpRequest request)
Run before each request runs.

Parameters:
request -

insertAuthenticationHeaders

protected void insertAuthenticationHeaders(com.google.api.client.http.HttpRequest request)

interceptResponse

protected void interceptResponse(com.google.api.client.http.HttpResponse response)
                          throws DNSAPIException,
                                 IOException
Run after each request complete (with or without success).

Parameters:
response -
Throws:
DNSAPIException
IOException

handleExceptionIfNeeded

protected void handleExceptionIfNeeded(com.google.api.client.http.HttpResponse response)
                                throws DNSAPIException,
                                       IOException
Exception treatment for generic calls

Parameters:
statusCode -
responseAsString -
Throws:
IOException
NetworkAPIException
DNSAPIException

parse

protected <E> DNSAPIRoot<E> parse(String responseAsString,
                                  Type type)
                       throws DNSAPIException
Convert an HttpResponse object to DNSAPIRoot of E object.

Parameters:
response -
type -
Returns:
Throws:
DNSAPIException

parse

protected <E> DNSAPIRoot<E> parse(com.google.api.client.http.HttpResponse response,
                                  Type type)
                       throws DNSAPIException
Throws:
DNSAPIException

buildUrl

protected com.google.api.client.http.GenericUrl buildUrl(String suffixUrl)

get

protected DNSAPIRoot<T> get(String suffixUrl,
                            boolean returnsList)
                     throws DNSAPIException
Throws:
DNSAPIException

post

protected DNSAPIRoot<T> post(String suffixUrl,
                             Object payload,
                             boolean returnsList)
                      throws DNSAPIException
Throws:
DNSAPIException

put

protected DNSAPIRoot<T> put(String suffixUrl,
                            Object payload,
                            boolean returnsList)
                     throws DNSAPIException
Throws:
DNSAPIException

delete

protected DNSAPIRoot<T> delete(String suffixUrl,
                               boolean returnsList)
                        throws DNSAPIException
Throws:
DNSAPIException


Copyright © 2014. All rights reserved.