2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2018-2019 Nokia Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package onap.aai.util;
22 import com.github.kevinsawicki.http.HttpRequest;
24 public class AaiRequest {
26 private static final String AAI_BASE_URL = "https://localhost:8443/aai";
27 private static final String AAI_AUTH = "Basic QUFJOkFBSQ==";
28 private static final String SCHEMA_VERSION = "/v14";
30 public static HttpRequest get(String endpoint) {
31 return aaiRequest(HttpRequest.get(aaiEndpoint(endpoint)));
34 public static HttpRequest post(String endpoint) {
35 return aaiRequest(HttpRequest.post(aaiEndpoint(endpoint)));
38 public static HttpRequest put(String endpoint) {
39 return aaiRequest(HttpRequest.put(aaiEndpoint(endpoint)));
42 public static HttpRequest delete(String endpoint) {
43 return aaiRequest(HttpRequest.delete(aaiEndpoint(endpoint)));
46 public static String v14(String endpoint) {
47 return SCHEMA_VERSION + endpoint;
50 private static HttpRequest aaiRequest(HttpRequest httpRequest) {
52 .header("X-FromAppId", "dummy id")
53 .header("X-TransactionId", "1234")
54 .authorization(AAI_AUTH)
59 private static String aaiEndpoint(String endpoint) {
60 return AAI_BASE_URL + endpoint;