2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 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 {
34 public NearRicUrlProvider() {
38 * Retrieve the base url of the Near-RIC
40 * @return the base url
42 public String getBaseUrl(final String nearRtRicUrl) {
43 String baseUrl = nearRtRicUrl + "/A1-P/v1";
44 return UriComponentsBuilder.fromUriString(baseUrl).build().toString();
48 * Retrieve the policy type ids url
50 * @return the policytype ids url
52 public String getPolicyTypeIdentitiesUrl(final String nearRtRicUrl) {
53 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes")
54 .pathSegment("identities").build().toString();
58 * Retrieve the url of the policy instances
60 * @param policyTypeId Policy Type Id
61 * @return the policy ids url
63 public String getPolicyIdentitiesUrl(final String nearRtRicUrl) {
64 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies")
65 .pathSegment("identities").build().toString();
69 * Retrieve the url of policy type
71 * @param policyTypeId Policy Type Id
72 * @return the policy type url
74 public String getPolicyTypeUrl(final String nearRtRicUrl, final String policyTypeId) {
75 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes")
76 .pathSegment(policyTypeId).build().toString();
80 * Retrieve the url of the policy instance id
82 * @param policyId Policy Id
83 * @return the policy id url
85 public String getPolicyUrl(final String nearRtRicUrl, final String policyId) {
86 return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies")
87 .pathSegment(policyId).build().toString();