All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.networknt.client.rest.RestClient Maven / Gradle / Ivy

Go to download

A client module that is used by API consumer to call an API or from an API calling another API.

There is a newer version: 2.1.37
Show newest version
/*
 * Copyright (c) 2016 Network New Technologies Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.networknt.client.rest;

import com.networknt.client.model.ServiceDef;

import java.util.Map;

public interface RestClient {



    /**
     * Retrieve a representation by doing a GET on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T get(String url, String path, Class responseType) throws RestClientException;

    /**
     * Retrieve a representation by doing a GET on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T get(ServiceDef serviceDef, String path, Class responseType) throws RestClientException;

    /**
     * Retrieve a representation by doing a GET on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param headerMap the map containing header setting map
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T get(ServiceDef serviceDef, String path, Class responseType, Map headerMap) throws RestClientException;

    /**
     * Retrieve a representation by doing a GET on the specified URL.
     * The response return with Json format string.
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @return the JSON format object
     * @throws RestClientException RestClientException
     */
    String get(String url, String path) throws RestClientException;

    /**
     * Retrieve a representation by doing a GET on the specified URL.
     * The response return with Json format string.
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @return the JSON format object
     * @throws RestClientException RestClientException
     */
    String get(ServiceDef serviceDef, String path) throws RestClientException;
    /**
     * Retrieve a representation by doing a GET on the URI template.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param url the URL
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param headerMap the map containing header setting map
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T get(String url,  String path, Class responseType, Map headerMap) throws RestClientException;

    /**
     * Retrieve a representation by doing a POST on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param requestBody REQUEST BODY
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T post(String url, String path, Class responseType, String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a POST on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param requestBody REQUEST BODY
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T post(ServiceDef serviceDef, String path, Class responseType, String requestBody) throws RestClientException;
    /**
     * Retrieve a representation by doing a POST on the specified URL.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param headerMap the map containing header setting map
     * @param requestBody REQUEST BODY
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T post(ServiceDef serviceDef, String path, Class responseType, Map headerMap, String requestBody) throws RestClientException;
    /**
     * Retrieve a representation by doing a POST on the specified URL.
     * The response return with Json format string.
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @param requestBody REQUEST BODY
     * @return the JSON format object
     * @throws RestClientException RestClientException
     */
    String post(String url, String path,  String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a POST on the specified URL.
     * The response return with Json format string.
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param requestBody REQUEST BODY
     * @return the JSON format object
     * @throws RestClientException RestClientException
     */
    String post(ServiceDef serviceDef, String path,  String requestBody) throws RestClientException;
    /**
     * Retrieve a representation by doing a POST on the URI template.
     * The response (if any) is converted and returned.
     * Use responseType as ClientResponse.class to get back the full response object
     * @param url the URL
     * @param path the path of the service call, for example: /v1/hello
     * @param responseType the type of the return value
     * @param headerMap the map containing header setting map
     * @param requestBody REQUEST BODY
     * @param  This is the type parameter
     * @return the converted object
     * @throws RestClientException RestClientException
     */
     T post(String url,  String path, Class responseType, Map headerMap,  String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a PUT on the specified URL.
     * The response return with Json format string.
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @param requestBody REQUEST BODY
     * @return the JSON format string
     * @throws RestClientException RestClientException
     */
    String put(String url, String path,  String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a PUT on the specified URL.
     * The response return with Json format string.
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param requestBody REQUEST BODY
     * @return the JSON format string
     * @throws RestClientException RestClientException
     */
    String put(ServiceDef serviceDef, String path,  String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a PUT on the specified URL.
     * The response return with Json format string.
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @param headerMap the map containing header setting map
     * @param requestBody REQUEST BODY
     * @return the JSON format string
     * @throws RestClientException RestClientException
     */
    String put(ServiceDef serviceDef, String path,  Map headerMap, String requestBody) throws RestClientException;
    /**
     * Retrieve a representation by doing a PUT on the URI template.
     * The response (if any) is converted and returned.
     * @param url the URL
     * @param path the path of the service call, for example: /v1/hello
     * @param headerMap the map containing header setting map
     * @param requestBody REQUEST BODY
     * @return the converted object
     * @throws RestClientException RestClientException
     */
   String put(String url,  String path,  Map headerMap,  String requestBody) throws RestClientException;

    /**
     * Retrieve a representation by doing a DELETE on the specified URL.
     * The response return with Json format string.
     * @param url the URL example: https://localhost:8443 ;  https://"com.networknt.hello-1
     * @param path the path of the service call, for example: /v1/hello
     * @return the JSON format string
     * @throws RestClientException RestClientException
     */
    String delete(String url, String path) throws RestClientException;

    /**
     * Retrieve a representation by doing a DELETE on the specified URL.
     * The response return with Json format string.
     * @param serviceDef the URL service definition
     * @param path the path of the service call, for example: /v1/hello
     * @return the JSON format string
     * @throws RestClientException RestClientException
     */
    String delete(ServiceDef serviceDef, String path) throws RestClientException;
    /**
     * Retrieve a representation by doing a PUT on the URI template.
     * The response (if any) is converted and returned.
     * @param url the URL
     * @param path the path of the service call, for example: /v1/hello
     * @param headerMap the map containing header setting map
     * @param requestBody the body of the request
     * @return the converted object
     * @throws RestClientException RestClientException
     */
    String delete(String url,  String path,  Map headerMap,  String requestBody) throws RestClientException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy