2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.sdnc.northbound.restadapter;
23 import org.springframework.web.util.UriComponentsBuilder;
26 * This class provides Near-RIC api to invoke the A1 interface
28 * @author lathishbabu.ganesan@est.tech
32 public class NearRicUrlProvider {
35 * Retrieve the base url of the Near-RIC
37 * @param nearRtRicUrl the near-rt-ric url
38 * @return the base url
40 public String getBaseUrl(final String nearRtRicUrl) {
41 String baseUrl = nearRtRicUrl + "/A1-P/v1";
42 return UriComponentsBuilder.fromUriString(baseUrl).build().toString();
46 * Retrieve the policytypes url
48 * @param nearRtRicUrl the near-rt-ric url
49 * @return the policytypes url
51 public String policyTypesUrl(final String nearRtRicUrl) {
52 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes").build().toString();
56 * Retrieve the policies url
58 * @param nearRtRicUrl the near-rt-ric url
59 * @return the policies url
61 public String policiesUrl(final String nearRtRicUrl) {
62 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies").build().toString();
66 * Retrieve the url of policy type
68 * @param nearRtRicUrl the near-rt-ric url
69 * @param policyTypeId Policy Type Id
70 * @return the policy type url
72 public String getPolicyTypeUrl(final String nearRtRicUrl, final String policyTypeId) {
73 return UriComponentsBuilder.fromUriString(policyTypesUrl(nearRtRicUrl)).pathSegment(policyTypeId).build()
78 * Retrieve the url of putPolicy
80 * @param nearRtRicUrl the near-rt-ric url
81 * @param policyId Policy Id
82 * @param policyTypeId Policy Type Id
83 * @return the putPolicy url
85 public String putPolicyUrl(final String nearRtRicUrl, final String policyId, final String policyTypeId) {
86 return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl))
87 .pathSegment(policyId + "?policyTypeId=" + policyTypeId).build().toString();
91 * Retrieve the url of deletePolicy
93 * @param nearRtRicUrl the near-rt-ric url
94 * @param policyId Policy Id
95 * @return the deletePolicy url
97 public String deletePolicyUrl(final String nearRtRicUrl, final String policyId) {
98 return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl)).pathSegment(policyId).build().toString();
101 public String getPolicyStatusUrl(String nearRtRicUrl, String policyId) {
102 return policiesUrl(nearRtRicUrl) + "/" + policyId + "/status";