/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class NearRicUrlProvider {
- public NearRicUrlProvider() {
- }
-
/**
* Retrieve the base url of the Near-RIC
*
+ * @param nearRtRicUrl the near-rt-ric url
* @return the base url
*/
public String getBaseUrl(final String nearRtRicUrl) {
- String baseUrl = nearRtRicUrl + "/A1-P/v1";
- return UriComponentsBuilder.fromUriString(baseUrl).build().toString();
+ return nearRtRicUrl + "/A1-P/v1";
}
/**
- * Retrieve the policy type ids url
+ * Retrieve the policytypes url
*
- * @return the policytype ids url
+ * @param nearRtRicUrl the near-rt-ric url
+ * @return the policytypes url
*/
- public String getPolicyTypeIdentitiesUrl(final String nearRtRicUrl) {
- return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes")
- .pathSegment("identities").build().toString();
+ public String policyTypesUrl(final String nearRtRicUrl) {
+ return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes").build().toString();
}
/**
- * Retrieve the url of the policy instances
+ * Retrieve the policies url
*
- * @param policyTypeId Policy Type Id
- * @return the policy ids url
+ * @param nearRtRicUrl the near-rt-ric url
+ * @return the policies url
*/
- public String getPolicyIdentitiesUrl(final String nearRtRicUrl) {
- return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies")
- .pathSegment("identities").build().toString();
+ public String policiesUrl(final String nearRtRicUrl) {
+ return getBaseUrl(nearRtRicUrl) + "/policies";
}
/**
* Retrieve the url of policy type
*
+ * @param nearRtRicUrl the near-rt-ric url
* @param policyTypeId Policy Type Id
* @return the policy type url
*/
public String getPolicyTypeUrl(final String nearRtRicUrl, final String policyTypeId) {
- return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes")
- .pathSegment(policyTypeId).build().toString();
+ return UriComponentsBuilder.fromUriString(policyTypesUrl(nearRtRicUrl)).pathSegment(policyTypeId).build()
+ .toString();
+ }
+
+ /**
+ * Retrieve the url of putPolicy
+ *
+ * @param nearRtRicUrl the near-rt-ric url
+ * @param policyId Policy Id
+ * @param policyTypeId Policy Type Id
+ * @return the putPolicy url
+ */
+ public String putPolicyUrl(final String nearRtRicUrl, final String policyId, final String policyTypeId) {
+ UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl)).pathSegment(policyId);
+
+ if (!policyTypeId.isEmpty()) {
+ builder.queryParam("policyTypeId", policyTypeId);
+ }
+ return builder.build().toString();
}
/**
- * Retrieve the url of the policy instance id
+ * Retrieve the url of deletePolicy
*
- * @param policyId Policy Id
- * @return the policy id url
+ * @param nearRtRicUrl the near-rt-ric url
+ * @param policyId Policy Id
+ * @return the deletePolicy url
*/
- public String getPolicyUrl(final String nearRtRicUrl, final String policyId) {
- return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies")
- .pathSegment(policyId).build().toString();
+ public String deletePolicyUrl(final String nearRtRicUrl, final String policyId) {
+ return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl)).pathSegment(policyId).build().toString();
+ }
+
+ public String getPolicyStatusUrl(String nearRtRicUrl, String policyId) {
+ return policiesUrl(nearRtRicUrl) + "/" + policyId + "/status";
}
}