* ============LICENSE_START=======================================================
* rest
* ================================================================================
* ============LICENSE_START=======================================================
* rest
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
* @param password the password
* @param headers any headers
* @param contentType what the content type is
* @param password the password
* @param headers any headers
* @param contentType what the content type is
*/
public Pair<Integer, String> put(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
*/
public Pair<Integer, String> put(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
addHeaders(put, username, password, headers);
put.addHeader(CONTENT_TYPE, contentType);
try {
addHeaders(put, username, password, headers);
put.addHeader(CONTENT_TYPE, contentType);
try {
* @param password the password
* @param headers any headers
* @param contentType what the content type is
* @param password the password
* @param headers any headers
* @param contentType what the content type is
*/
public Pair<Integer, String> post(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
*/
public Pair<Integer, String> post(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
addHeaders(post, username, password, headers);
post.addHeader(CONTENT_TYPE, contentType);
try {
addHeaders(post, username, password, headers);
post.addHeader(CONTENT_TYPE, contentType);
try {
* @param password password
* @param headers any headers to add
* @return a Pair for the response status and the body
*/
public Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {
* @param password password
* @param headers any headers to add
* @return a Pair for the response status and the body
*/
public Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {
addHeaders(get, username, password, headers);
return sendRequest(get);
}
addHeaders(get, username, password, headers);
return sendRequest(get);
}
* @param password the password
* @param headers any headers
* @param contentType what the content type is
* @param password the password
* @param headers any headers
* @param contentType what the content type is
*/
public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
*/
public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers,
String contentType, String body) {
addHeaders(delete, username, password, headers);
if (body != null && !body.isEmpty()) {
delete.addHeader(CONTENT_TYPE, contentType);
try {
addHeaders(delete, username, password, headers);
if (body != null && !body.isEmpty()) {
delete.addHeader(CONTENT_TYPE, contentType);
try {
* @param password the password
* @param headers any headers
* @return the response status code and the body
*/
public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers) {
* @param password the password
* @param headers any headers
* @return the response status code and the body
*/
public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers) {
addHeaders(delete, username, password, headers);
return sendRequest(delete);
}
addHeaders(delete, username, password, headers);
return sendRequest(delete);
}
* @param password the password
* @param headers any headers
* @param body body to send
* @param password the password
* @param headers any headers
* @param body body to send
*/
public Pair<Integer, String> patch(String url, String username, String password, Map<String, String> headers,
String body) {
*/
public Pair<Integer, String> patch(String url, String username, String password, Map<String, String> headers,
String body) {
addHeaders(patch, username, password, headers);
patch.addHeader(CONTENT_TYPE, contentType);
try {
addHeaders(patch, username, password, headers);
patch.addHeader(CONTENT_TYPE, contentType);
try {
HttpClientBuilder.create().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
HttpResponse response = client.execute(request);
if (response != null) {
HttpClientBuilder.create().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
HttpResponse response = client.execute(request);
if (response != null) {
logger.debug("HTTP Response Status Code: {}", response.getStatusLine().getStatusCode());
logger.debug("HTTP Response Body:");
logger.debug(returnBody);
logger.debug("HTTP Response Status Code: {}", response.getStatusLine().getStatusCode());
logger.debug("HTTP Response Body:");
logger.debug(returnBody);