Class RestClient


  • public class RestClient
    extends Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete​(com.abiquo.model.transport.SingleResourceTransportDto dto)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      delete​(com.abiquo.model.transport.SingleResourceTransportDto dto, String accept, Class<T> returnClass)  
      void delete​(String uri)  
      void delete​(String uri, Map<String,​Object> queryParams)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      edit​(T dto)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(com.abiquo.model.rest.RESTLink link, Class<T> clazz)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(String uri, String accept, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(String uri, String accept, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(String uri, String accept, Class<T> returnClass, Map<String,​String> headers)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(String uri, Map<String,​Object> queryParams, String accept, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      get​(String uri, Map<String,​Object> queryParams, String accept, Class<T> returnClass)  
      String getAsString​(String uri, String accept)  
      Json json()
      Returns the Json instance used to serialize and deserialize the request and response bodies.
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(com.abiquo.model.rest.RESTLink link, Class<W> clazz)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(String uri, String accept, com.google.common.reflect.TypeToken<W> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(String uri, String accept, Class<W> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(String uri, String accept, Class<W> returnClass, Map<String,​String> headers)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(String uri, Map<String,​Object> queryParams, String accept, com.google.common.reflect.TypeToken<W> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>>
      Stream<T>
      list​(String uri, Map<String,​Object> queryParams, String accept, Class<W> returnClass)  
      com.squareup.okhttp.Response multipartPost​(String url, String bodyName, String body, String fileName, File file)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, Class<T> returnClass, Map<String,​String> headers)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, String accept, String contentType, String body, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, Map<String,​Object> queryParams, String accept, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      post​(String uri, Map<String,​Object> queryParams, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      put​(String uri, String accept, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      put​(String uri, String accept, Class<T> returnClass)  
      void put​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      put​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, com.google.common.reflect.TypeToken<T> returnType)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      put​(String uri, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, Class<T> returnClass)  
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      put​(String uri, Map<String,​Object> queryParams, String accept, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body, Class<T> returnClass)  
      void putAction​(String uri, String contentType, com.abiquo.model.transport.SingleResourceTransportDto body)  
      com.squareup.okhttp.OkHttpClient rawClient()
      Changes made to the returned client will affect all the subsequent requests.
      <T extends com.abiquo.model.transport.SingleResourceTransportDto>
      T
      refresh​(T dto)  
      com.abiquo.server.core.asynctask.AsyncTaskDto waitForAsyncTaskFinalization​(com.abiquo.server.core.asynctask.AsyncTaskDto taskDto, long pollInterval, long maxWait, TimeUnit timeUnit)
      Waits for task finalization
      com.abiquo.server.core.task.TaskDto waitForTask​(com.abiquo.model.transport.AcceptedRequestDto<?> acceptedRequest, int pollInterval, int maxWait, TimeUnit timeUnit)  
      com.abiquo.server.core.task.TaskDto waitForTask​(com.abiquo.server.core.task.TaskDto taskDto, int pollInterval, int maxWait, TimeUnit timeUnit)  
      com.abiquo.server.core.cloud.VirtualApplianceDto waitUntilUnlocked​(com.abiquo.server.core.cloud.VirtualApplianceDto vapp, int pollInterval, int maxWait, TimeUnit timeUnit)  
      com.abiquo.server.core.cloud.VirtualMachineDto waitUntilUnlocked​(com.abiquo.server.core.cloud.VirtualMachineDto vm, int pollInterval, int maxWait, TimeUnit timeUnit)  
    • Method Detail

      • rawClient

        public com.squareup.okhttp.OkHttpClient rawClient()
        Changes made to the returned client will affect all the subsequent requests.

        If you want to create a new client without affecting the existing one, use the OkHttpClient.clone() method on the returned client.

      • json

        public Json json()
        Returns the Json instance used to serialize and deserialize the request and response bodies.
      • edit

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T edit​(T dto)
      • delete

        public void delete​(com.abiquo.model.transport.SingleResourceTransportDto dto)
      • refresh

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T refresh​(T dto)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(com.abiquo.model.rest.RESTLink link,
                                                                                                                                                         Class<W> clazz)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(String uri,
                                                                                                                                                         String accept,
                                                                                                                                                         Class<W> returnClass)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(String uri,
                                                                                                                                                         String accept,
                                                                                                                                                         com.google.common.reflect.TypeToken<W> returnType)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(String uri,
                                                                                                                                                         Map<String,​Object> queryParams,
                                                                                                                                                         String accept,
                                                                                                                                                         Class<W> returnClass)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(String uri,
                                                                                                                                                         String accept,
                                                                                                                                                         Class<W> returnClass,
                                                                                                                                                         Map<String,​String> headers)
      • list

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto,​W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> list​(String uri,
                                                                                                                                                         Map<String,​Object> queryParams,
                                                                                                                                                         String accept,
                                                                                                                                                         com.google.common.reflect.TypeToken<W> returnType)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(com.abiquo.model.rest.RESTLink link,
                                                                                       Class<T> clazz)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(String uri,
                                                                                       String accept,
                                                                                       Class<T> returnClass)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(String uri,
                                                                                       String accept,
                                                                                       com.google.common.reflect.TypeToken<T> returnType)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(String uri,
                                                                                       String accept,
                                                                                       Class<T> returnClass,
                                                                                       Map<String,​String> headers)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(String uri,
                                                                                       Map<String,​Object> queryParams,
                                                                                       String accept,
                                                                                       Class<T> returnClass)
      • get

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T get​(String uri,
                                                                                       Map<String,​Object> queryParams,
                                                                                       String accept,
                                                                                       com.google.common.reflect.TypeToken<T> returnType)
      • delete

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T delete​(com.abiquo.model.transport.SingleResourceTransportDto dto,
                                                                                          String accept,
                                                                                          Class<T> returnClass)
      • delete

        public void delete​(String uri)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        Map<String,​Object> queryParams,
                                                                                        String accept,
                                                                                        String contentType,
                                                                                        com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                        Class<T> returnClass)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        String contentType,
                                                                                        com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                        Class<T> returnClass)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        String contentType,
                                                                                        com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                        Class<T> returnClass,
                                                                                        Map<String,​String> headers)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        String contentType,
                                                                                        com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                        com.google.common.reflect.TypeToken<T> returnType)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        Class<T> returnClass)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        String contentType,
                                                                                        String body,
                                                                                        Class<T> returnClass)
      • multipartPost

        public com.squareup.okhttp.Response multipartPost​(String url,
                                                          String bodyName,
                                                          String body,
                                                          String fileName,
                                                          File file)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        String accept,
                                                                                        com.google.common.reflect.TypeToken<T> returnType)
      • post

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T post​(String uri,
                                                                                        Map<String,​Object> queryParams,
                                                                                        String accept,
                                                                                        com.google.common.reflect.TypeToken<T> returnType)
      • put

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T put​(String uri,
                                                                                       Map<String,​Object> queryParams,
                                                                                       String accept,
                                                                                       String contentType,
                                                                                       com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                       Class<T> returnClass)
      • put

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T put​(String uri,
                                                                                       String accept,
                                                                                       String contentType,
                                                                                       com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                       Class<T> returnClass)
      • putAction

        public void putAction​(String uri,
                              String contentType,
                              com.abiquo.model.transport.SingleResourceTransportDto body)
      • put

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T put​(String uri,
                                                                                       String accept,
                                                                                       Class<T> returnClass)
      • put

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T put​(String uri,
                                                                                       String accept,
                                                                                       com.google.common.reflect.TypeToken<T> returnType)
      • put

        public <T extends com.abiquo.model.transport.SingleResourceTransportDto> T put​(String uri,
                                                                                       String accept,
                                                                                       String contentType,
                                                                                       com.abiquo.model.transport.SingleResourceTransportDto body,
                                                                                       com.google.common.reflect.TypeToken<T> returnType)
      • put

        public void put​(String uri,
                        String accept,
                        String contentType,
                        com.abiquo.model.transport.SingleResourceTransportDto body)
      • waitForTask

        public com.abiquo.server.core.task.TaskDto waitForTask​(com.abiquo.model.transport.AcceptedRequestDto<?> acceptedRequest,
                                                               int pollInterval,
                                                               int maxWait,
                                                               TimeUnit timeUnit)
      • waitForTask

        public com.abiquo.server.core.task.TaskDto waitForTask​(com.abiquo.server.core.task.TaskDto taskDto,
                                                               int pollInterval,
                                                               int maxWait,
                                                               TimeUnit timeUnit)
      • waitUntilUnlocked

        public com.abiquo.server.core.cloud.VirtualMachineDto waitUntilUnlocked​(com.abiquo.server.core.cloud.VirtualMachineDto vm,
                                                                                int pollInterval,
                                                                                int maxWait,
                                                                                TimeUnit timeUnit)
      • waitUntilUnlocked

        public com.abiquo.server.core.cloud.VirtualApplianceDto waitUntilUnlocked​(com.abiquo.server.core.cloud.VirtualApplianceDto vapp,
                                                                                  int pollInterval,
                                                                                  int maxWait,
                                                                                  TimeUnit timeUnit)
      • waitForAsyncTaskFinalization

        public com.abiquo.server.core.asynctask.AsyncTaskDto waitForAsyncTaskFinalization​(com.abiquo.server.core.asynctask.AsyncTaskDto taskDto,
                                                                                          long pollInterval,
                                                                                          long maxWait,
                                                                                          TimeUnit timeUnit)
                                                                                   throws TimeoutException
        Waits for task finalization
        Parameters:
        taskDto - task to wait for
        pollInterval - amount of time to sleep between task retrieve attempts
        maxWait - maximum amount of time to wait for task finalization
        timeUnit - time unit in which pollInterval and maxWait are expressed
        Returns:
        the finished task
        Throws:
        TimeoutException - if the specified maxWait time has been reached and task remains in progress