Class RequestHelper

    • Constructor Detail

      • RequestHelper

        public RequestHelper​(String baseURL,
                             int retries,
                             Integer timeout,
                             String tlsVersion,
                             X509Certificate trustedCaCert)
        Constructor of the request helper.
        Parameters:
        baseURL - The URL
        retries - Number of retries on 5xx errors
        timeout - Timeout for HTTP requests (milliseconds)
        tlsVersion - TLS Version.
        trustedCaCert - Trusted CA certificate
    • Method Detail

      • post

        public String post​(String path,
                           Object payload,
                           String token)
                    throws VaultConnectorException
        Execute HTTP request using POST method.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8 Added token parameter.
      • post

        public <T> T post​(String path,
                          Object payload,
                          String token,
                          Class<T> target)
                   throws VaultConnectorException
        Execute HTTP request using POST method and parse JSON result.
        Type Parameters:
        T - Target type.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        target - Target class.
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8
      • postWithoutResponse

        public void postWithoutResponse​(String path,
                                        Object payload,
                                        String token)
                                 throws VaultConnectorException
        Execute HTTP request using POST method and expect empty (204) response.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8
      • put

        public String put​(String path,
                          Map<String,​String> payload,
                          String token)
                   throws VaultConnectorException
        Execute HTTP request using PUT method.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8 Added token parameter.
      • put

        public <T> T put​(String path,
                         Map<String,​String> payload,
                         String token,
                         Class<T> target)
                  throws VaultConnectorException
        Execute HTTP request using PUT method and parse JSON result.
        Type Parameters:
        T - Target type.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        target - Target class.
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8
      • putWithoutResponse

        public void putWithoutResponse​(String path,
                                       Map<String,​String> payload,
                                       String token)
                                throws VaultConnectorException
        Execute HTTP request using PUT method and expect empty (204) response.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8
      • delete

        public String delete​(String path,
                             String token)
                      throws VaultConnectorException
        Execute HTTP request using DELETE method.
        Parameters:
        path - URL path (relative to base).
        token - Vault token (may be null).
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8 Added token parameter.
      • deleteWithoutResponse

        public void deleteWithoutResponse​(String path,
                                          String token)
                                   throws VaultConnectorException
        Execute HTTP request using DELETE method and expect empty (204) response.
        Parameters:
        path - URL path (relative to base).
        token - Vault token (may be null).
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8
      • get

        public String get​(String path,
                          Map<String,​String> payload,
                          String token)
                   throws VaultConnectorException
        Execute HTTP request using GET method.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8 Added token parameter.
      • get

        public <T> T get​(String path,
                         Map<String,​String> payload,
                         String token,
                         Class<T> target)
                  throws VaultConnectorException
        Execute HTTP request using GET method and parse JSON result to target class.
        Type Parameters:
        T - Target type.
        Parameters:
        path - URL path (relative to base).
        payload - Map of payload values (will be converted to JSON).
        token - Vault token (may be null).
        target - Target class.
        Returns:
        HTTP response
        Throws:
        VaultConnectorException - on connection error
        Since:
        0.8