diff options
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java')
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java | 156 |
1 files changed, 128 insertions, 28 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java index 72847b18..2e3b9afb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints + * ONAP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,36 +27,136 @@ import javax.ws.rs.core.Response; import org.onap.policy.common.capabilities.Startable; +/** + * Http Client interface. + */ public interface HttpClient extends Startable { - public static final HttpClientFactory factory = new IndexedHttpClientFactory(); - - public Response get(String path); - - public Response get(); - - public Response put(String path, Entity<?> entity, Map<String, Object> headers); - - public static <T> T getBody(Response response, Class<T> entityType) { + /** + * Factory. + */ + HttpClientFactory factory = new IndexedHttpClientFactory(); + + /** + * GET request. + * + * @param path context uri path. + * @return response + */ + Response get(String path); + + /** + * GET request. + * + * @return response + */ + Response get(); + + /** + * PUT request. + * + * @param path context uri path + * @param entity body + * @param headers headers + * + * @return response. + */ + Response put(String path, Entity<?> entity, Map<String, Object> headers); + + /** + * POST request. + * + * @param path context uri path + * @param entity body + * @param headers headers + * + * @return response. + */ + Response post(String path, Entity<?> entity, Map<String, Object> headers); + + /** + * DELETE request. + * + * @param path context uri path + * @param headers headers + * + * @return response. + */ + Response delete(String path, Map<String, Object> headers); + + /** + * Retrieve the body from the HTTP transaction. + * + * @param response response. + * @param entityType body type. + * @param <T> body class. + * + * @return response. + */ + static <T> T getBody(Response response, Class<T> entityType) { return response.readEntity(entityType); } - public String getName(); - - public boolean isHttps(); - - public boolean isSelfSignedCerts(); - - public String getHostname(); - - public int getPort(); - - public String getBasePath(); - - public String getUserName(); - - public String getPassword(); - - public String getBaseUrl(); + /** + * Get the client name. + * @return name + */ + String getName(); + + /** + * HTTPS support. + * + * @return if the client uses https + */ + boolean isHttps(); + + /** + * Self-signed certificates. + * + * @return if the self-signed certificates are allowed + */ + boolean isSelfSignedCerts(); + + /** + * Get the host name. + * + * @return host name + */ + String getHostname(); + + /** + * Get the port. + * + * @return port + */ + int getPort(); + + /** + * Get the base path. + * + * @return base path + */ + String getBasePath(); + + /** + * Get the user name. + * + * @return the user name + */ + String getUserName(); + + /** + * Get the password. + * + * @return the password + */ + String getPassword(); + + /** + * Get the base URL. + * + * @return the base URL + */ + String getBaseUrl(); } |