aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Keeney <john.keeney@est.tech>2025-02-27 17:17:05 +0000
committerGerrit Code Review <gerrit@onap.org>2025-02-27 17:17:05 +0000
commitbf30f27ec60bb9c1b3793580e50209bcbd6f95d4 (patch)
tree84d2998e33d4110a1755483602c01f7078a47d6a
parent2aa0e284f3ee7123e2ec288de5b6c6b69f0a1b15 (diff)
parentdc216cdce55dfa85b4c24b6aeb6b1fda9f9a1920 (diff)
Merge "Controller behaviour fixes"
-rw-r--r--a1-policy-management/api/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html94
-rw-r--r--a1-policy-management/api/offeredapis/swagger/custom/a1pms-api-custom-v3.json19
-rw-r--r--a1-policy-management/api/offeredapis/swagger/pms-api-v3.json19
-rw-r--r--a1-policy-management/api/offeredapis/swagger/pms-api-v3.yaml19
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java12
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java55
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java15
-rw-r--r--a1-policy-management/src/main/resources/application_configuration_schema.json3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java4
-rw-r--r--docs/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html94
-rw-r--r--docs/offeredapis/swagger/custom/a1pms-api-custom-v3.json19
-rw-r--r--docs/offeredapis/swagger/pms-api-v3.json19
-rw-r--r--docs/offeredapis/swagger/pms-api-v3.yaml19
13 files changed, 172 insertions, 219 deletions
diff --git a/a1-policy-management/api/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html b/a1-policy-management/api/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
index da6b47d6..198ea9be 100644
--- a/a1-policy-management/api/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
+++ b/a1-policy-management/api/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
@@ -12284,10 +12284,10 @@ pub fn main() {
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
- <p class="marked">Either a Near-RT RIC identity or a Managed Element identity can be specified.&lt;br&gt;The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).</p>
+ <p class="marked">A ricId path parameter must be specified to retrieve associated ric infomation</p>
<p></p>
<br />
- <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/rics/ric</span></code></pre>
+ <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/rics/{ricId}</span></code></pre>
<p>
<h3>Usage and SDK Samples</h3>
</p>
@@ -12311,7 +12311,7 @@ pub fn main() {
<div class="tab-pane active" id="examples-NearRTRICRepository-getRic-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X GET \
-H "Accept: application/json,application/problem+json" \
- "https://example.com/a1-policy-management/v1/rics/ric?managedElementId=managedElementId_example&ricId=ricId_example"
+ "https://example.com/a1-policy-management/v1/rics/{ricId}"
</code></pre>
</div>
<div class="tab-pane" id="examples-NearRTRICRepository-getRic-0-java">
@@ -12328,12 +12328,11 @@ public class NearRTRICRepositoryApiExample {
// Create an instance of the API class
NearRTRICRepositoryApi apiInstance = new NearRTRICRepositoryApi();
- String managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
String ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
String accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling NearRTRICRepositoryApi#getRic");
@@ -12349,12 +12348,11 @@ public class NearRTRICRepositoryApiExample {
final api_instance = DefaultApi();
-final String managedElementId = new String(); // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
final String ricId = new String(); // String | The identity of a Near-RT RIC to get information for.
final String accept = new String(); // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- final result = await api_instance.getRic(managedElementId, ricId, accept);
+ final result = await api_instance.getRic(ricId, accept);
print(result);
} catch (e) {
print('Exception when calling DefaultApi->getRic: $e\n');
@@ -12369,12 +12367,11 @@ try {
public class NearRTRICRepositoryApiExample {
public static void main(String[] args) {
NearRTRICRepositoryApi apiInstance = new NearRTRICRepositoryApi();
- String managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
String ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
String accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling NearRTRICRepositoryApi#getRic");
@@ -12392,13 +12389,11 @@ public class NearRTRICRepositoryApiExample {
// Create an instance of the API class
NearRTRICRepositoryApi *apiInstance = [[NearRTRICRepositoryApi alloc] init];
-String *managedElementId = managedElementId_example; // The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
-String *ricId = ricId_example; // The identity of a Near-RT RIC to get information for. (optional) (default to null)
+String *ricId = ricId_example; // The identity of a Near-RT RIC to get information for. (default to null)
String *accept = application/json; // Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
// Returns info for one Near-RT RIC
-[apiInstance getRicWith:managedElementId
- ricId:ricId
+[apiInstance getRicWith:ricId
accept:accept
completionHandler: ^(RicInfo output, NSError* error) {
if (output) {
@@ -12416,9 +12411,8 @@ String *accept = application/json; // Specifies the content type that the client
// Create an instance of the API class
var api = new A1PolicyManagementApi.NearRTRICRepositoryApi()
+var ricId = ricId_example; // {String} The identity of a Near-RT RIC to get information for.
var opts = {
- 'managedElementId': managedElementId_example, // {String} The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
- 'ricId': ricId_example, // {String} The identity of a Near-RT RIC to get information for.
'accept': application/json // {String} Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
};
@@ -12429,7 +12423,7 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
-api.getRic(opts, callback);
+api.getRic(ricId, opts, callback);
</code></pre>
</div>
@@ -12452,13 +12446,12 @@ namespace Example
// Create an instance of the API class
var apiInstance = new NearRTRICRepositoryApi();
- var managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
- var ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for. (optional) (default to null)
+ var ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for. (default to null)
var accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
try {
// Returns info for one Near-RT RIC
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling NearRTRICRepositoryApi.getRic: " + e.Message );
@@ -12475,12 +12468,11 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\NearRTRICRepositoryApi();
-$managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
$ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
$accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- $result = $api_instance->getRic($managedElementId, $ricId, $accept);
+ $result = $api_instance->getRic($ricId, $accept);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling NearRTRICRepositoryApi->getRic: ', $e->getMessage(), PHP_EOL;
@@ -12495,12 +12487,11 @@ use WWW::OPenAPIClient::NearRTRICRepositoryApi;
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::NearRTRICRepositoryApi->new();
-my $managedElementId = managedElementId_example; # String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
my $ricId = ricId_example; # String | The identity of a Near-RT RIC to get information for.
my $accept = application/json; # String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
eval {
- my $result = $api_instance->getRic(managedElementId => $managedElementId, ricId => $ricId, accept => $accept);
+ my $result = $api_instance->getRic(ricId => $ricId, accept => $accept);
print Dumper($result);
};
if ($@) {
@@ -12517,13 +12508,12 @@ from pprint import pprint
# Create an instance of the API class
api_instance = openapi_client.NearRTRICRepositoryApi()
-managedElementId = managedElementId_example # String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
-ricId = ricId_example # String | The identity of a Near-RT RIC to get information for. (optional) (default to null)
+ricId = ricId_example # String | The identity of a Near-RT RIC to get information for. (default to null)
accept = application/json # String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
try:
# Returns info for one Near-RT RIC
- api_response = api_instance.get_ric(managedElementId=managedElementId, ricId=ricId, accept=accept)
+ api_response = api_instance.get_ric(ricId, accept=accept)
pprint(api_response)
except ApiException as e:
print("Exception when calling NearRTRICRepositoryApi->getRic: %s\n" % e)</code></pre>
@@ -12533,12 +12523,11 @@ except ApiException as e:
<pre class="prettyprint"><code class="language-rust">extern crate NearRTRICRepositoryApi;
pub fn main() {
- let managedElementId = managedElementId_example; // String
let ricId = ricId_example; // String
let accept = application/json; // String
let mut context = NearRTRICRepositoryApi::Context::default();
- let result = client.getRic(managedElementId, ricId, accept, &context).wait();
+ let result = client.getRic(ricId, accept, &context).wait();
println!("{:?}", result);
}
@@ -12553,18 +12542,17 @@ pub fn main() {
<h2>Parameters</h2>
-
- <div class="methodsubtabletitle">Header parameters</div>
+ <div class="methodsubtabletitle">Path parameters</div>
<table id="methodsubtable">
- <tr>
- <th width="150px">Name</th>
- <th>Description</th>
- </tr>
- <tr><td style="width:150px;">Accept</td>
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">ricId*</td>
<td>
- <div id="d2e199_getRic_accept">
+ <div id="d2e199_getRic_ricId">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
@@ -12572,9 +12560,12 @@ pub fn main() {
</span>
<div class="inner description marked">
-Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
+The identity of a Near-RT RIC to get information for.
</div>
</div>
+ <div class="inner required">
+ Required
+ </div>
</div>
</div>
</td>
@@ -12582,19 +12573,17 @@ Specifies the content type that the client expects to receive in response to the
</table>
-
-
- <div class="methodsubtabletitle">Query parameters</div>
+ <div class="methodsubtabletitle">Header parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
- <tr><td style="width:150px;">managedElementId</td>
+ <tr><td style="width:150px;">Accept</td>
<td>
- <div id="d2e199_getRic_managedElementId">
+ <div id="d2e199_getRic_accept">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
@@ -12602,7 +12591,7 @@ Specifies the content type that the client expects to receive in response to the
</span>
<div class="inner description marked">
-The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
+Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
</div>
</div>
</div>
@@ -12610,27 +12599,10 @@ The identity of a Managed Element. If given, the Near-RT RIC managing the ME is
</td>
</tr>
- <tr><td style="width:150px;">ricId</td>
-<td>
-
+ </table>
- <div id="d2e199_getRic_ricId">
- <div class="json-schema-view">
- <div class="primitive">
- <span class="type">
- String
- </span>
- <div class="inner description marked">
-The identity of a Near-RT RIC to get information for.
- </div>
- </div>
- </div>
- </div>
-</td>
-</tr>
- </table>
<h2>Responses</h2>
<h3 id="examples-NearRTRICRepository-getRic-title-200"></h3>
diff --git a/a1-policy-management/api/offeredapis/swagger/custom/a1pms-api-custom-v3.json b/a1-policy-management/api/offeredapis/swagger/custom/a1pms-api-custom-v3.json
index f923650c..9514db8d 100644
--- a/a1-policy-management/api/offeredapis/swagger/custom/a1pms-api-custom-v3.json
+++ b/a1-policy-management/api/offeredapis/swagger/custom/a1pms-api-custom-v3.json
@@ -65,27 +65,18 @@
"tags" : [ "Health Check" ]
}
},
- "/rics/ric" : {
+ "/rics/{ricId}" : {
"get" : {
- "description" : "Either a Near-RT RIC identity or a Managed Element identity can be specified.<br>The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).",
+ "description" : "A ricId path parameter must be specified to retrieve associated ric infomation",
"operationId" : "getRic",
"parameters" : [ {
- "description" : "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.",
- "explode" : true,
- "in" : "query",
- "name" : "managedElementId",
- "required" : false,
- "schema" : {
- "type" : "string"
- },
- "style" : "form"
- }, {
"description" : "The identity of a Near-RT RIC to get information for.",
"explode" : true,
- "in" : "query",
+ "in" : "path",
"name" : "ricId",
- "required" : false,
+ "required" : true,
"schema" : {
+ "nullable" : false,
"type" : "string"
},
"style" : "form"
diff --git a/a1-policy-management/api/offeredapis/swagger/pms-api-v3.json b/a1-policy-management/api/offeredapis/swagger/pms-api-v3.json
index f923650c..9514db8d 100644
--- a/a1-policy-management/api/offeredapis/swagger/pms-api-v3.json
+++ b/a1-policy-management/api/offeredapis/swagger/pms-api-v3.json
@@ -65,27 +65,18 @@
"tags" : [ "Health Check" ]
}
},
- "/rics/ric" : {
+ "/rics/{ricId}" : {
"get" : {
- "description" : "Either a Near-RT RIC identity or a Managed Element identity can be specified.<br>The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).",
+ "description" : "A ricId path parameter must be specified to retrieve associated ric infomation",
"operationId" : "getRic",
"parameters" : [ {
- "description" : "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.",
- "explode" : true,
- "in" : "query",
- "name" : "managedElementId",
- "required" : false,
- "schema" : {
- "type" : "string"
- },
- "style" : "form"
- }, {
"description" : "The identity of a Near-RT RIC to get information for.",
"explode" : true,
- "in" : "query",
+ "in" : "path",
"name" : "ricId",
- "required" : false,
+ "required" : true,
"schema" : {
+ "nullable" : false,
"type" : "string"
},
"style" : "form"
diff --git a/a1-policy-management/api/offeredapis/swagger/pms-api-v3.yaml b/a1-policy-management/api/offeredapis/swagger/pms-api-v3.yaml
index 1ea8b486..4df9d61a 100644
--- a/a1-policy-management/api/offeredapis/swagger/pms-api-v3.yaml
+++ b/a1-policy-management/api/offeredapis/swagger/pms-api-v3.yaml
@@ -89,28 +89,19 @@ paths:
description: Returns status and statistics of this service
tags:
- Health Check
- /rics/ric:
+ /rics/{ricId}:
get:
- description: Either a Near-RT RIC identity or a Managed Element identity can
- be specified.<br>The intention with Managed Element identity is the ID used
- in O1 for accessing the traffical element (such as the ID of CU).
+ description: A ricId path parameter must be specified to retrieve associated ric infomation
operationId: getRic
parameters:
- - description: "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned."
- explode: true
- in: query
- name: managedElementId
- required: false
- schema:
- type: string
- style: form
- description: The identity of a Near-RT RIC to get information for.
explode: true
- in: query
+ in: path
name: ricId
- required: false
+ required: true
schema:
type: string
+ nullable: false
style: form
- description: Specifies the content type that the client expects to receive in response to the request.
Only application/json is allowed.
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
index f7872a38..53abcd71 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
@@ -3,6 +3,7 @@
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.RicInfoList;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
+import org.onap.ccsdk.oran.a1policymanagementservice.util.v3.Helper;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -41,6 +43,7 @@ import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
@RestController("ricRepositoryControllerV2")
@RequiredArgsConstructor
@@ -63,12 +66,17 @@ public class RicRepositoryController implements NearRtRicRepositoryApi {
private static final String GET_RIC_DETAILS =
"Either a Near-RT RIC identity or a Managed Element identity can be specified.<br>" //
+ "The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
+ private final Helper helper;
+
@Override
public Mono<ResponseEntity<RicInfo>> getRic(
final String managedElementId, final String ricId, final ServerWebExchange exchange)
throws Exception {
+
+ helper.validateQueryParameters(exchange, Set.of("managed_element_id", "ric_id"));
+
if (managedElementId != null && ricId != null) {
- throw new InvalidRequestException("Give one query parameter");
+ throw new InvalidRequestException("Only one parameter allowed");
} else if (managedElementId != null) {
Ric ric = this.rics.lookupRicForManagedElement(managedElementId);
return Mono.just(new ResponseEntity<>(toRicInfo(ric), HttpStatus.OK));
@@ -76,7 +84,7 @@ public class RicRepositoryController implements NearRtRicRepositoryApi {
RicInfo info = toRicInfo(this.rics.getRic(ricId));
return Mono.just(new ResponseEntity<>(info, HttpStatus.OK));
} else {
- throw new InvalidRequestException("Give one query parameter");
+ throw new InvalidRequestException("Only one parameter allowed");
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
index 89d47d7f..ce2769e6 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
@@ -2,7 +2,7 @@
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,17 +24,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.NearRtRicRepositoryApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.InvalidRequestException;
import org.onap.ccsdk.oran.a1policymanagementservice.mappers.v3.RicRepositoryMapper;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.RicRepositoryController;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.RicInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.RicInfoList;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.ErrorHandlingService;
+import org.onap.ccsdk.oran.a1policymanagementservice.util.v3.Helper;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
+import java.util.List;
+import java.util.Set;
+
@RestController("ricRepositoryControllerV3")
@RequiredArgsConstructor
@Tag(
@@ -53,17 +61,50 @@ public class RicRepositoryControllerV3 implements NearRtRicRepositoryApi {
private final ErrorHandlingService errorHandlingService;
+ private final Rics rics;
+
+ private final Helper helper;
+
@Override
- public Mono<ResponseEntity<RicInfo>> getRic(String managedElementId, String ricId, String accept, ServerWebExchange exchange) throws Exception {
- return ricRepositoryController.getRic(managedElementId, ricId, exchange)
- .map(responseEntity -> new ResponseEntity<>(ricRepositoryMapper.toRicInfoV3(responseEntity.getBody()), responseEntity.getStatusCode()))
- .doOnError(errorHandlingService::handleError);
+ public Mono<ResponseEntity<RicInfo>> getRic(String ricId, String accept, ServerWebExchange exchange) throws Exception {
+
+ helper.validateQueryParameters(exchange, Set.of("ricId"));
+
+ if (ricId != null) {
+ RicInfo info = toRicInfo(this.rics.getRic(ricId));
+ return Mono.just(new ResponseEntity<>(info, HttpStatus.OK))
+ .map(responseEntity -> new ResponseEntity<>(
+ responseEntity.getBody(), responseEntity.getStatusCode()))
+ .doOnError(errorHandlingService::handleError);
+ } else {
+ throw new InvalidRequestException("Only one parameter allowed");
+ }
}
@Override
- public Mono<ResponseEntity<RicInfoList>> getRics(String policyTypeId, String accept, ServerWebExchange exchange) throws Exception {
+ public Mono<ResponseEntity<RicInfoList>> getRics(String policyTypeId, String accept,
+ ServerWebExchange exchange) throws Exception {
return ricRepositoryController.getRics(policyTypeId, exchange)
- .map(responseEntity -> new ResponseEntity<>(ricRepositoryMapper.toRicInfoListV3(responseEntity.getBody()), responseEntity.getStatusCode()))
+ .map(responseEntity ->
+ new ResponseEntity<>(
+ ricRepositoryMapper.toRicInfoListV3(responseEntity.getBody()),
+ responseEntity.getStatusCode()))
.doOnError(errorHandlingService::handleError);
}
+
+ private RicInfo toRicInfo(Ric ric) {
+ return new RicInfo().ricId(ric.id())
+ .managedElementIds((List<String>) ric.getManagedElementIds())
+ .policyTypeIds((List<String>) ric.getSupportedPolicyTypeNames())
+ .state(toRicState(ric.getState()));
+ }
+
+ private RicInfo.StateEnum toRicState(Ric.RicState state) {
+ return switch (state) {
+ case AVAILABLE -> RicInfo.StateEnum.AVAILABLE;
+ case CONSISTENCY_CHECK -> RicInfo.StateEnum.CONSISTENCY_CHECK;
+ case SYNCHRONIZING -> RicInfo.StateEnum.SYNCHRONIZING;
+ case UNAVAILABLE -> RicInfo.StateEnum.UNAVAILABLE;
+ };
+ }
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
index 1202c0ff..3199e9c3 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
@@ -26,6 +26,7 @@ import lombok.RequiredArgsConstructor;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.InvalidRequestException;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyInformation;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyObjectInformation;
@@ -46,6 +47,7 @@ import reactor.core.publisher.Mono;
import java.lang.invoke.MethodHandles;
import java.time.Instant;
import java.util.Collection;
+import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -201,4 +203,17 @@ public class Helper {
.map(type -> new PolicyTypeInformation(type.getId(), ric.getConfig().getRicId()))
.collect(Collectors.toList());
}
+
+
+ public void validateQueryParameters(ServerWebExchange exchange, Set<String> allowedParams) throws InvalidRequestException {
+ Set<String> receivedParams = exchange.getRequest().getQueryParams().keySet();
+
+ Set<String> extraParams = receivedParams.stream()
+ .filter(param -> !allowedParams.contains(param))
+ .collect(Collectors.toSet());
+
+ if (!extraParams.isEmpty()) {
+ throw new InvalidRequestException("Unexpected query parameters: " + extraParams);
+ }
+ }
}
diff --git a/a1-policy-management/src/main/resources/application_configuration_schema.json b/a1-policy-management/src/main/resources/application_configuration_schema.json
index 8476951c..3186dae6 100644
--- a/a1-policy-management/src/main/resources/application_configuration_schema.json
+++ b/a1-policy-management/src/main/resources/application_configuration_schema.json
@@ -72,8 +72,7 @@
},
"required": [
"name",
- "baseUrl",
- "managedElementIds"
+ "baseUrl"
],
"additionalProperties": false
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
index 455ea0cf..ece5d8c2 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3Test.java
@@ -2,7 +2,7 @@
* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,7 +105,7 @@ class RicRepositoryControllerV3Test {
@Test
void testGetRic() throws IOException {
testHelperTest.addPolicyType("1", "ricAdded");
- Mono<ResponseEntity<String>> responseEntityMono = testHelperTest.restClientV3().getForEntity("/rics/ric?ricId=ricAdded");
+ Mono<ResponseEntity<String>> responseEntityMono = testHelperTest.restClientV3().getForEntity("/rics/ricAdded");
testHelperTest.testSuccessResponse(responseEntityMono, HttpStatus.OK, responseBody -> responseBody
.contains("{\"ricId\":\"ricAdded\",\"managedElementIds\":[],\"state\":\"AVAILABLE\",\"policyTypeIds\":[\"1\"]}"));
}
diff --git a/docs/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html b/docs/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
index da6b47d6..198ea9be 100644
--- a/docs/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
+++ b/docs/offeredapis/openapitoolgen/offeredapis/pms-api/v3/index.html
@@ -12284,10 +12284,10 @@ pub fn main() {
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
- <p class="marked">Either a Near-RT RIC identity or a Managed Element identity can be specified.&lt;br&gt;The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).</p>
+ <p class="marked">A ricId path parameter must be specified to retrieve associated ric infomation</p>
<p></p>
<br />
- <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/rics/ric</span></code></pre>
+ <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/rics/{ricId}</span></code></pre>
<p>
<h3>Usage and SDK Samples</h3>
</p>
@@ -12311,7 +12311,7 @@ pub fn main() {
<div class="tab-pane active" id="examples-NearRTRICRepository-getRic-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X GET \
-H "Accept: application/json,application/problem+json" \
- "https://example.com/a1-policy-management/v1/rics/ric?managedElementId=managedElementId_example&ricId=ricId_example"
+ "https://example.com/a1-policy-management/v1/rics/{ricId}"
</code></pre>
</div>
<div class="tab-pane" id="examples-NearRTRICRepository-getRic-0-java">
@@ -12328,12 +12328,11 @@ public class NearRTRICRepositoryApiExample {
// Create an instance of the API class
NearRTRICRepositoryApi apiInstance = new NearRTRICRepositoryApi();
- String managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
String ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
String accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling NearRTRICRepositoryApi#getRic");
@@ -12349,12 +12348,11 @@ public class NearRTRICRepositoryApiExample {
final api_instance = DefaultApi();
-final String managedElementId = new String(); // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
final String ricId = new String(); // String | The identity of a Near-RT RIC to get information for.
final String accept = new String(); // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- final result = await api_instance.getRic(managedElementId, ricId, accept);
+ final result = await api_instance.getRic(ricId, accept);
print(result);
} catch (e) {
print('Exception when calling DefaultApi->getRic: $e\n');
@@ -12369,12 +12367,11 @@ try {
public class NearRTRICRepositoryApiExample {
public static void main(String[] args) {
NearRTRICRepositoryApi apiInstance = new NearRTRICRepositoryApi();
- String managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
String ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
String accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling NearRTRICRepositoryApi#getRic");
@@ -12392,13 +12389,11 @@ public class NearRTRICRepositoryApiExample {
// Create an instance of the API class
NearRTRICRepositoryApi *apiInstance = [[NearRTRICRepositoryApi alloc] init];
-String *managedElementId = managedElementId_example; // The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
-String *ricId = ricId_example; // The identity of a Near-RT RIC to get information for. (optional) (default to null)
+String *ricId = ricId_example; // The identity of a Near-RT RIC to get information for. (default to null)
String *accept = application/json; // Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
// Returns info for one Near-RT RIC
-[apiInstance getRicWith:managedElementId
- ricId:ricId
+[apiInstance getRicWith:ricId
accept:accept
completionHandler: ^(RicInfo output, NSError* error) {
if (output) {
@@ -12416,9 +12411,8 @@ String *accept = application/json; // Specifies the content type that the client
// Create an instance of the API class
var api = new A1PolicyManagementApi.NearRTRICRepositoryApi()
+var ricId = ricId_example; // {String} The identity of a Near-RT RIC to get information for.
var opts = {
- 'managedElementId': managedElementId_example, // {String} The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
- 'ricId': ricId_example, // {String} The identity of a Near-RT RIC to get information for.
'accept': application/json // {String} Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
};
@@ -12429,7 +12423,7 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
-api.getRic(opts, callback);
+api.getRic(ricId, opts, callback);
</code></pre>
</div>
@@ -12452,13 +12446,12 @@ namespace Example
// Create an instance of the API class
var apiInstance = new NearRTRICRepositoryApi();
- var managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
- var ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for. (optional) (default to null)
+ var ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for. (default to null)
var accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
try {
// Returns info for one Near-RT RIC
- RicInfo result = apiInstance.getRic(managedElementId, ricId, accept);
+ RicInfo result = apiInstance.getRic(ricId, accept);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling NearRTRICRepositoryApi.getRic: " + e.Message );
@@ -12475,12 +12468,11 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\NearRTRICRepositoryApi();
-$managedElementId = managedElementId_example; // String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
$ricId = ricId_example; // String | The identity of a Near-RT RIC to get information for.
$accept = application/json; // String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
try {
- $result = $api_instance->getRic($managedElementId, $ricId, $accept);
+ $result = $api_instance->getRic($ricId, $accept);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling NearRTRICRepositoryApi->getRic: ', $e->getMessage(), PHP_EOL;
@@ -12495,12 +12487,11 @@ use WWW::OPenAPIClient::NearRTRICRepositoryApi;
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::NearRTRICRepositoryApi->new();
-my $managedElementId = managedElementId_example; # String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
my $ricId = ricId_example; # String | The identity of a Near-RT RIC to get information for.
my $accept = application/json; # String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
eval {
- my $result = $api_instance->getRic(managedElementId => $managedElementId, ricId => $ricId, accept => $accept);
+ my $result = $api_instance->getRic(ricId => $ricId, accept => $accept);
print Dumper($result);
};
if ($@) {
@@ -12517,13 +12508,12 @@ from pprint import pprint
# Create an instance of the API class
api_instance = openapi_client.NearRTRICRepositoryApi()
-managedElementId = managedElementId_example # String | The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned. (optional) (default to null)
-ricId = ricId_example # String | The identity of a Near-RT RIC to get information for. (optional) (default to null)
+ricId = ricId_example # String | The identity of a Near-RT RIC to get information for. (default to null)
accept = application/json # String | Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed. (optional) (default to null)
try:
# Returns info for one Near-RT RIC
- api_response = api_instance.get_ric(managedElementId=managedElementId, ricId=ricId, accept=accept)
+ api_response = api_instance.get_ric(ricId, accept=accept)
pprint(api_response)
except ApiException as e:
print("Exception when calling NearRTRICRepositoryApi->getRic: %s\n" % e)</code></pre>
@@ -12533,12 +12523,11 @@ except ApiException as e:
<pre class="prettyprint"><code class="language-rust">extern crate NearRTRICRepositoryApi;
pub fn main() {
- let managedElementId = managedElementId_example; // String
let ricId = ricId_example; // String
let accept = application/json; // String
let mut context = NearRTRICRepositoryApi::Context::default();
- let result = client.getRic(managedElementId, ricId, accept, &context).wait();
+ let result = client.getRic(ricId, accept, &context).wait();
println!("{:?}", result);
}
@@ -12553,18 +12542,17 @@ pub fn main() {
<h2>Parameters</h2>
-
- <div class="methodsubtabletitle">Header parameters</div>
+ <div class="methodsubtabletitle">Path parameters</div>
<table id="methodsubtable">
- <tr>
- <th width="150px">Name</th>
- <th>Description</th>
- </tr>
- <tr><td style="width:150px;">Accept</td>
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">ricId*</td>
<td>
- <div id="d2e199_getRic_accept">
+ <div id="d2e199_getRic_ricId">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
@@ -12572,9 +12560,12 @@ pub fn main() {
</span>
<div class="inner description marked">
-Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
+The identity of a Near-RT RIC to get information for.
</div>
</div>
+ <div class="inner required">
+ Required
+ </div>
</div>
</div>
</td>
@@ -12582,19 +12573,17 @@ Specifies the content type that the client expects to receive in response to the
</table>
-
-
- <div class="methodsubtabletitle">Query parameters</div>
+ <div class="methodsubtabletitle">Header parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
- <tr><td style="width:150px;">managedElementId</td>
+ <tr><td style="width:150px;">Accept</td>
<td>
- <div id="d2e199_getRic_managedElementId">
+ <div id="d2e199_getRic_accept">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
@@ -12602,7 +12591,7 @@ Specifies the content type that the client expects to receive in response to the
</span>
<div class="inner description marked">
-The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.
+Specifies the content type that the client expects to receive in response to the request. Only application/json is allowed.
</div>
</div>
</div>
@@ -12610,27 +12599,10 @@ The identity of a Managed Element. If given, the Near-RT RIC managing the ME is
</td>
</tr>
- <tr><td style="width:150px;">ricId</td>
-<td>
-
+ </table>
- <div id="d2e199_getRic_ricId">
- <div class="json-schema-view">
- <div class="primitive">
- <span class="type">
- String
- </span>
- <div class="inner description marked">
-The identity of a Near-RT RIC to get information for.
- </div>
- </div>
- </div>
- </div>
-</td>
-</tr>
- </table>
<h2>Responses</h2>
<h3 id="examples-NearRTRICRepository-getRic-title-200"></h3>
diff --git a/docs/offeredapis/swagger/custom/a1pms-api-custom-v3.json b/docs/offeredapis/swagger/custom/a1pms-api-custom-v3.json
index f923650c..9514db8d 100644
--- a/docs/offeredapis/swagger/custom/a1pms-api-custom-v3.json
+++ b/docs/offeredapis/swagger/custom/a1pms-api-custom-v3.json
@@ -65,27 +65,18 @@
"tags" : [ "Health Check" ]
}
},
- "/rics/ric" : {
+ "/rics/{ricId}" : {
"get" : {
- "description" : "Either a Near-RT RIC identity or a Managed Element identity can be specified.<br>The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).",
+ "description" : "A ricId path parameter must be specified to retrieve associated ric infomation",
"operationId" : "getRic",
"parameters" : [ {
- "description" : "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.",
- "explode" : true,
- "in" : "query",
- "name" : "managedElementId",
- "required" : false,
- "schema" : {
- "type" : "string"
- },
- "style" : "form"
- }, {
"description" : "The identity of a Near-RT RIC to get information for.",
"explode" : true,
- "in" : "query",
+ "in" : "path",
"name" : "ricId",
- "required" : false,
+ "required" : true,
"schema" : {
+ "nullable" : false,
"type" : "string"
},
"style" : "form"
diff --git a/docs/offeredapis/swagger/pms-api-v3.json b/docs/offeredapis/swagger/pms-api-v3.json
index f923650c..9514db8d 100644
--- a/docs/offeredapis/swagger/pms-api-v3.json
+++ b/docs/offeredapis/swagger/pms-api-v3.json
@@ -65,27 +65,18 @@
"tags" : [ "Health Check" ]
}
},
- "/rics/ric" : {
+ "/rics/{ricId}" : {
"get" : {
- "description" : "Either a Near-RT RIC identity or a Managed Element identity can be specified.<br>The intention with Managed Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).",
+ "description" : "A ricId path parameter must be specified to retrieve associated ric infomation",
"operationId" : "getRic",
"parameters" : [ {
- "description" : "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.",
- "explode" : true,
- "in" : "query",
- "name" : "managedElementId",
- "required" : false,
- "schema" : {
- "type" : "string"
- },
- "style" : "form"
- }, {
"description" : "The identity of a Near-RT RIC to get information for.",
"explode" : true,
- "in" : "query",
+ "in" : "path",
"name" : "ricId",
- "required" : false,
+ "required" : true,
"schema" : {
+ "nullable" : false,
"type" : "string"
},
"style" : "form"
diff --git a/docs/offeredapis/swagger/pms-api-v3.yaml b/docs/offeredapis/swagger/pms-api-v3.yaml
index 6d61dfe3..c97336ed 100644
--- a/docs/offeredapis/swagger/pms-api-v3.yaml
+++ b/docs/offeredapis/swagger/pms-api-v3.yaml
@@ -87,28 +87,19 @@ paths:
description: Returns status and statistics of this service
tags:
- Health Check
- /rics/ric:
+ /rics/{ricId}:
get:
- description: Either a Near-RT RIC identity or a Managed Element identity can
- be specified.<br>The intention with Managed Element identity is the ID used
- in O1 for accessing the traffical element (such as the ID of CU).
+ description: A ricId path parameter must be specified to retrieve associated ric infomation
operationId: getRic
parameters:
- - description: "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned."
- explode: true
- in: query
- name: managedElementId
- required: false
- schema:
- type: string
- style: form
- description: The identity of a Near-RT RIC to get information for.
explode: true
- in: query
+ in: path
name: ricId
- required: false
+ required: true
schema:
type: string
+ nullable: false
style: form
- description: Specifies the content type that the client expects to receive in response to the request.
Only application/json is allowed.