Improved generated swagger API.
Furter alignments to https://opensource.zalando.com/restful-api-guidelines/#118
Improved unitttest for faulty JSON in configuration.
Changed names: "NonRT-RIC" to "Non-RT RIC" and "NearRT-RIC" to "Near-RT RIC"
Change-Id: I4ca0d45605a770b5c33e34019671e088e3fe979d
Issue-ID: CCSDK-2498
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
parameters:
- name: id
in: query
- description: The ID of the policy type to get the definition for.
+ description: The identity of the policy type to get the definition for.
required: true
allowEmptyValue: false
schema:
parameters:
- name: id
in: query
- description: The ID of the policy.
+ description: The identity of the policy.
required: true
allowEmptyValue: false
schema:
parameters:
- name: managedElementId
in: query
- description: The ID of the Managed Element
+ description: The identity of the Managed Element
required: true
allowEmptyValue: false
schema:
swagger: '2.0'
info:
- description: |
- The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices.
- It provides support for:
- -Supervision of clients (R-APPs) to eliminate stray policies in case of failure
- -Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs
- -Consistency monitoring of NearRT-RIC capabilities (policy types)-Policy configuration.
- This includes:-One REST API towards all NearRT-RICs in the network
- -Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP),
- all policies of a type etc.
- -Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices.
+ description: |-
+ The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices.
+ It provides support for:<ul><li>A1 Policy creation and modification.</li><li>Maintaining a view of supported Near-RT RIC policy types </li><li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> <li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li></ul>
version: 1.1.0
title: A1 Policy management service
contact:
name: Ericsson Software Technology
email: nonrtric@est.tech
+ x-api-id: 60f9a0e7-343f-43bf-9194-d8d65688d465
+ x-audience: external-partner
host: 'localhost:8081'
basePath: /
tags:
- name: A1 Policy Management Version 1.0
description: Policy Controller
- name: A1 Policy Management Version 2.0 (in progress)
- description: Policy Controller
+ description: Policy management
paths:
/policies:
get:
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get policies for.
+ description: The name of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
type: string
deprecated: false
type: object
- name: ric
in: query
- description: The name of the NearRT-RIC where the policy will be created.
+ description: The name of the Near-RT RIC where the policy will be created.
required: true
type: string
allowEmptyValue: false
allowEmptyValue: false
- name: transient
in: query
- description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will be forgotten when the service needs to reconnect to the NearRT-RIC.
+ description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will be forgotten when the service needs to reconnect to the Near-RT RIC.
required: false
type: boolean
default: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC or policy type is not found
+ description: Near-RT RIC or policy type is not found
schema:
type: string
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
type: string
deprecated: false
schema:
type: string
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
type: string
deprecated: false
get:
tags:
- A1 Policy Management Version 1.0
- summary: 'Query policies, only IDs returned'
+ summary: 'Query policies, only policy identities returned'
operationId: getPolicyIdsUsingGET_1
produces:
- '*/*'
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get policies for.
+ description: The name of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
allowEmptyValue: false
responses:
'200':
- description: Policy ids
+ description: Policy identitiess
schema:
type: array
items:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
type: string
deprecated: false
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get the definitions for.
+ description: The name of the Near-RT RIC to get the definitions for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get types for.
+ description: The name of the Near-RT RIC to get types for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
allowEmptyValue: false
responses:
'200':
- description: NearRT-RIC is found
+ description: Near-RT RIC is found
schema:
type: string
'401':
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
get:
tags:
- A1 Policy Management Version 1.0
- summary: Query NearRT-RIC information
+ summary: Query Near-RT RIC information
operationId: getRicsUsingGET
produces:
- '*/*'
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Query policies
- description: 'If several query parameters are defined, the policies matching all conditions are returned'
+ summary: Query for existing A1 policies
+ description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.'
operationId: getPoliciesUsingGET
produces:
- application/json
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get policies for.
+ description: The identity of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: 'NearRT-RIC, policy type or service not found'
+ description: 'Near-RT RIC, policy type or service not found'
schema:
$ref: '#/definitions/error_information'
deprecated: false
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC where the policy will be created.
+ description: The identity of the Near-RT RIC where the policy will be created.
required: true
type: string
allowEmptyValue: false
allowEmptyValue: false
- name: transient
in: query
- description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will not be recreated in the NearRT-RIC when it has been lost (for instance due to a restart)
+ description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC when it has been lost (for instance due to a restart)
required: false
type: boolean
default: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC or policy type is not found
+ description: Near-RT RIC or policy type is not found
schema:
$ref: '#/definitions/error_information'
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
$ref: '#/definitions/error_information'
deprecated: false
schema:
$ref: '#/definitions/error_information'
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
$ref: '#/definitions/error_information'
deprecated: false
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: 'Query policies, only IDs returned'
+ summary: 'Query policies, only policy identities are returned'
+ description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.'
operationId: getPolicyIdsUsingGET
produces:
- application/json
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get policies for.
+ description: The identity of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
allowEmptyValue: false
responses:
'200':
- description: Policy ids
+ description: Policy identities
schema:
$ref: '#/definitions/policy_id_list_v2'
'401':
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get the definitions for.
+ description: The identity of the Near-RT RIC to get the definitions for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
parameters:
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get types for.
+ description: The identity of the Near-RT RIC to get types for.
required: false
type: string
allowEmptyValue: false
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Returns info for the NearRT-RIC with the given identity or managing one Mananged Element
+ summary: Returns info for a Near-RT RIC
+ description: Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).
operationId: getRicUsingGET_1
produces:
- application/json
parameters:
- name: managed_element_id
in: query
- description: 'The identity of a Managed Element. If given, the NearRT-RIC managing the ME is returned.'
+ description: 'The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.'
required: false
type: string
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of a NearRT-RIC to get information for.
+ description: The identity of a Near-RT RIC to get information for.
required: false
type: string
allowEmptyValue: false
responses:
'200':
- description: NearRT-RIC is found
+ description: Near-RT RIC is found
schema:
$ref: '#/definitions/ric_info_v2'
'401':
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Query NearRT-RIC information
+ summary: Query Near-RT RIC information
+ description: The call returns all Near-RT RICs that supports a given policy type identity
operationId: getRicsUsingGET_1
produces:
- application/json
parameters:
- name: policytype_id
in: query
- description: 'The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned'
+ description: 'The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned'
required: false
type: string
allowEmptyValue: false
tags:
- A1 Policy Management Version 2.0 (in progress)
summary: Returns service information
+ description: Either information about a registered service with given identity or all registered services are returned.
operationId: getServicesUsingGET
produces:
- application/json
tags:
- A1 Policy Management Version 2.0 (in progress)
summary: Register a service
+ description: 'Registering a service is needed to:<ul><li>Get callbacks.</li><li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li></ul>'
operationId: putServiceUsingPUT
consumes:
- application/json
delete:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Delete a service
+ summary: Unregister a service
operationId: deleteServiceUsingDELETE
produces:
- '*/*'
parameters:
- name: service_id
in: query
- description: The name of the service
+ description: The idenitity of the service
required: true
type: string
allowEmptyValue: false
'200':
description: Not used
'204':
- description: Service deleted
+ description: Service unregistered
schema:
type: object
'401':
json_object:
type: object
title: json_object
- description: A JSON object. The schema is defined by the Policy Type
+ description: A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.
policy_id_list_v2:
type: object
properties:
description: 'timestamp, last modification time'
ric:
type: string
- description: identity of the target NearRT-RIC
+ description: identity of the target Near-RT RIC
service:
type: string
description: the name of the service owning the policy
description: name of the policy type
ric_id:
type: string
- description: identity of the target NearRT-RIC
+ description: identity of the target Near-RT RIC
service_id:
type: string
description: the name of the service owning the policy
properties:
policy_schemas:
type: array
- description: Policy type json schemas
+ description: 'Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema'
items:
type: object
title: policy_schema_list_v2
properties:
rics:
type: array
- description: List of NearRT-RIC information
+ description: List of Near-RT RIC information
items:
$ref: '#/definitions/ric_info_v2'
title: ric_info_list_v2
- description: List of NearRT-RIC information
+ description: List of Near-RT RIC information
ric_info_v1:
type: object
properties:
type: string
ricName:
type: string
- description: identity of the NearRT-RIC
+ description: identity of the Near-RT RIC
state:
type: string
description: state info
type: string
ric_id:
type: string
- description: identity of the NearRT-RIC
+ description: identity of the Near-RT RIC
state:
type: string
description: |-
- State for the NearRT-RIC, values:
- UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent
+ State for the Near-RT RIC, values:
+ UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent
AVAILABLE: The normal state. Policies can be configured. +
- SYNCHRONIZING: The Policy Management Service is synchronizing the view of the NearRT-RIC. Policies cannot be configured.
- CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured.
+ SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured.
+ CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.
enum:
- UNAVAILABLE
- AVAILABLE
- SYNCHRONIZING
- CONSISTENCY_CHECK
title: ric_info_v2
- description: Information for a NearRT-RIC
+ description: Information for a Near-RT RIC
service_list_v2:
type: object
properties:
import com.google.common.base.Predicates;
+import java.util.ArrayList;
+import java.util.List;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
+import springfox.documentation.service.StringVendorExtension;
+import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
public class SwaggerConfig extends WebMvcConfigurationSupport {
static final String API_TITLE = "A1 Policy management service";
- static final String DESCRIPTION =
- "The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices. \n"
- + "It provides support for: \n"
- + "-Supervision of clients (R-APPs) to eliminate stray policies in case of failure \n"
- + "-Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs \n"
- + "-Consistency monitoring of NearRT-RIC capabilities (policy types)" + "-Policy configuration. \n"
- + "This includes:" + "-One REST API towards all NearRT-RICs in the network \n"
- + "-Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP), \n"
- + "all policies of a type etc. \n"
- + "-Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices.\n";
+ static final String DESCRIPTION = //
+ "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" //
+ + "It provides support for:" //
+ + "<ul>" //
+ + "<li>A1 Policy creation and modification.</li>" //
+ + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" //
+ + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " //
+ + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" //
+ + "</ul>"//
+ ;
static final String VERSION = "1.1.0";
@SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter.
static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
.description(DESCRIPTION) //
.version(VERSION) //
.contact(contact()) //
+ .extensions(vendorExtentions()) //
.build();
}
+ @SuppressWarnings("rawtypes") // VendorExtension is a raw type. References to generic type VendorExtension<T>
+ // should be parameterizedJava(16777788)
+ private static List<VendorExtension> vendorExtentions() {
+ final String URN = "60f9a0e7-343f-43bf-9194-d8d65688d465";
+ List<VendorExtension> extentions = new ArrayList<>();
+ extentions.add(new StringVendorExtension("x-api-id", URN));
+ extentions.add(new StringVendorExtension("x-audience", "external-partner"));
+ return extentions;
+ }
+
private static Contact contact() {
return new Contact("Ericsson Software Technology", "", "nonrtric@est.tech");
}
* means that after the first successful creation it won't have to try which
* protocol to use, but can create the client directly.
*
- * @param ric The NearRT-RIC to get a client for.
+ * @param ric The Near-RT RIC to get a client for.
* @return a client with the correct protocol, or a ServiceException if none of
- * the protocols are supported by the NearRT-RIC.
+ * the protocols are supported by the Near-RT RIC.
*/
public Mono<A1Client> createA1Client(Ric ric) {
return getProtocolVersion(ric) //
String controllerName = ric.getConfig().controllerName();
if (controllerName.isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
- throw new ServiceException("No controller configured for NearRT-RIC: " + ric.id());
+ throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id());
}
try {
return this.appConfig.getControllerConfig(controllerName);
.onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
.doOnNext(ric::setProtocolVersion)
.doOnNext(
- version -> logger.debug("Established protocol version:{} for NearRT-RIC: {}", version, ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from NearRT-RIC: {}", ric.id())) //
+ version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version, ric.id())) //
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
.onErrorResume(
notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
} else {
*
* @param protocolType the southbound protocol of the controller. Supported
* protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
- * @param ricConfig the configuration of the NearRT-RIC to communicate
+ * @param ricConfig the configuration of the Near-RT RIC to communicate
* with
* @param controllerConfig the configuration of the SDNC controller to use
*
*
* @param protocolType the southbound protocol of the controller. Supported
* protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
- * @param ricConfig the configuration of the NearRT-RIC to communicate
+ * @param ricConfig the configuration of the Near-RT RIC to communicate
* with
* @param controllerConfig the configuration of the SDNC controller to use
* @param restClient the REST client to use
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicySchemas( //
- @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get the definitions for.") //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") //
@RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
message = "Policy type names",
response = String.class,
responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicyTypes( //
- @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get types for.") //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") //
@RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Policy is not found", response = String.class),
- @ApiResponse(code = 423, message = "NearRT-RIC is not operational", response = String.class)})
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
@ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
@RequestParam(name = "id", required = true) String id) {
}
@PutMapping(path = "/policy")
- @ApiOperation(value = "Put a policy", response = String.class)
+ @ApiOperation(value = "Put a policy", response = VoidResponse.class)
@ApiResponses(
value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
- @ApiResponse(code = 423, message = "NearRT-RIC is not operational", response = String.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC or policy type is not found", response = String.class) //
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class), //
+ @ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found", response = String.class) //
})
public Mono<ResponseEntity<Object>> putPolicy( //
@ApiParam(name = "type", required = false, value = "The name of the policy type.") //
@RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
@ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
@RequestParam(name = "id", required = true) String instanceId, //
- @ApiParam(name = "ric", required = true, value = "The name of the NearRT-RIC where the policy will be " + //
+ @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + //
"created.") //
@RequestParam(name = "ric", required = true) String ricName, //
@ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") //
@RequestParam(name = "service", required = true) String service, //
@ApiParam(name = "transient", required = false, value = "If the policy is transient or not (boolean " + //
"defaulted to false). A policy is transient if it will be forgotten when the service needs to " + //
- "reconnect to the NearRT-RIC.") //
+ "reconnect to the Near-RT RIC.") //
@RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
@RequestBody Object jsonBody) {
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Policies", response = PolicyInfo.class, responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicies( //
@ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
@RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get policies for.") //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
@RequestParam(name = "ric", required = false) String ric, //
@ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
@RequestParam(name = "service", required = false) String service) //
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String filteredPolicies = policiesToJson(filter(type, ric, service));
}
@GetMapping("/policy_ids")
- @ApiOperation(value = "Query policies, only IDs returned")
+ @ApiOperation(value = "Query policies, only policy identities returned")
@ApiResponses(
- value = {@ApiResponse(code = 200, message = "Policy ids", response = String.class, responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)})
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "Policy identitiess",
+ response = String.class,
+ responseContainer = "List"),
+ @ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicyIds( //
@ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
@RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get policies for.") //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
@RequestParam(name = "ric", required = false) String ric, //
@ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
@RequestParam(name = "service", required = false) String service) //
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String policyIdsJson = toPolicyIdsJson(filter(type, ric, service));
@ApiModelProperty(value = "name of the policy type")
public String type;
- @ApiModelProperty(value = "identity of the target NearRT-RIC")
+ @ApiModelProperty(value = "identity of the target Near-RT RIC")
public String ric;
@ApiModelProperty(value = "the configuration of the policy")
@Gson.TypeAdapters
@ApiModel(value = "ric_info_v1")
class RicInfo {
- @ApiModelProperty(value = "identity of the NearRT-RIC")
+ @ApiModelProperty(value = "identity of the Near-RT RIC")
public final String ricName;
@ApiModelProperty(value = "O1 identities for managed entities")
@ApiOperation(value = "Returns the name of a RIC managing one Mananged Element")
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "NearRT-RIC is found", response = String.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class) //
+ @ApiResponse(code = 200, message = "Near-RT RIC is found", response = String.class), //
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class) //
})
public ResponseEntity<String> getRic( //
@ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") //
* @return a Json array of all RIC data Example: http://localhost:8081/ric
*/
@GetMapping("/rics")
- @ApiOperation(value = "Query NearRT-RIC information")
+ @ApiOperation(value = "Query Near-RT RIC information")
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfo.class, responseContainer = "List"), //
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "json_object", description = "A JSON object. The schema is defined by the Policy Type")
+@ApiModel(
+ value = "json_object",
+ description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
class JsonObject {
}
+++ /dev/null
-/*-
- * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-
-package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
-
-import io.swagger.annotations.ApiModel;
-
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
-@ApiModel(value = "json_schema", description = "A JSON schema following http://json-schema.org/draft-07/schema")
-class JsonSchema {
-}
import reactor.core.publisher.Mono;
@RestController("PolicyControllerV2")
-@Api(tags = Consts.V2_API_NAME)
+@Api(tags = {Consts.V2_API_NAME}, description = "Policy management")
public class PolicyController {
public static class RejectionException extends Exception {
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Policy schemas", response = PolicySchemaList.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicySchemas( //
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get the definitions for.") //
+ value = "The identity of the Near-RT RIC to get the definitions for.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId,
@ApiParam(
name = Consts.POLICY_TYPE_ID_PARAM,
@ApiOperation(value = "Query policy type identities", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyTypes( //
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get types for.") //
+ value = "The identity of the Near-RT RIC to get types for.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
if (ricId == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class),
@ApiResponse(
code = 423,
- message = "NearRT-RIC is not operational",
+ message = "Near-RT RIC is not operational",
response = ErrorResponse.ErrorInfo.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
@ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
@ApiResponse(
code = 423,
- message = "NearRT-RIC is not operational",
+ message = "Near-RT RIC is not operational",
response = ErrorResponse.ErrorInfo.class), //
@ApiResponse(
code = 404,
- message = "NearRT-RIC or policy type is not found",
+ message = "Near-RT RIC or policy type is not found",
response = ErrorResponse.ErrorInfo.class) //
})
public Mono<ResponseEntity<Object>> putPolicy( //
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = true,
- value = "The identity of the NearRT-RIC where the policy will be " + //
+ value = "The identity of the Near-RT RIC where the policy will be " + //
"created.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, //
@ApiParam(
name = Consts.TRANSIENT_PARAM,
required = false,
value = "If the policy is transient or not (boolean " + //
- "defaulted to false). A policy is transient if it will not be recreated in the NearRT-RIC " + //
+ "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC " + //
"when it has been lost (for instance due to a restart)") //
@RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, //
@RequestBody Object jsonBody) {
PolicyType type = policyTypes.get(policyTypeId);
keepServiceAlive(serviceId);
if (ric == null || type == null) {
- return ErrorResponse.createMono("NearRT-RIC or policy type not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.createMono("Near-RT RIC or policy type not found", HttpStatus.NOT_FOUND);
}
Policy policy = ImmutablePolicy.builder() //
.id(instanceId) //
}
}
+ static final String GET_POLICIES_QUERY_DETAILS =
+ "Returns a list of A1 policies matching given search criteria. <br>" //
+ + "If several query parameters are defined, the policies matching all conditions are returned.";
+
@GetMapping(path = Consts.V2_API_ROOT + "/policies", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(
- value = "Query policies",
- notes = "If several query parameters are defined, the policies matching all conditions are returned")
+ @ApiOperation(value = "Query for existing A1 policies", notes = GET_POLICIES_QUERY_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class),
@ApiResponse(
code = 404,
- message = "NearRT-RIC, policy type or service not found",
+ message = "Near-RT RIC, policy type or service not found",
response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicies( //
@ApiParam(
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get policies for.") //
+ value = "The identity of the Near-RT RIC to get policies for.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, //
@ApiParam(
name = Consts.SERVICE_ID_PARAM,
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String filteredPolicies = policiesToJson(filter(type, ric, service));
}
@GetMapping(path = Consts.V2_API_ROOT + "/policy-ids", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Query policies, only IDs returned")
+ @ApiOperation(value = "Query policies, only policy identities are returned", notes = GET_POLICIES_QUERY_DETAILS)
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "Policy ids", response = PolicyIdList.class),
+ @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class),
@ApiResponse(
code = 404,
- message = "NearRT-RIC or type not found",
+ message = "Near-RT RIC or type not found",
response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyIds( //
@ApiParam(
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get policies for.") //
+ value = "The identity of the Near-RT RIC to get policies for.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, //
@ApiParam(
name = Consts.SERVICE_ID_PARAM,
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ricId != null && this.rics.get(ricId) == null)) {
- return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String policyIdsJson = toPolicyIdsJson(filter(policyTypeId, ricId, serviceId));
@JsonProperty("policy_type_id")
public String policyTypeId;
- @ApiModelProperty(value = "identity of the target NearRT-RIC")
+ @ApiModelProperty(value = "identity of the target Near-RT RIC")
@SerializedName("ric_id")
@JsonProperty("ric_id")
public String ricId;
@ApiModel(value = "policy_schema_list_v2", description = "Policy type json schemas")
public class PolicySchemaList {
- @ApiModelProperty(value = "Policy type json schemas")
+ @ApiModelProperty(
+ value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema")
@SerializedName("policy_schemas")
@JsonProperty("policy_schemas")
public final Collection<Object> schemas;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "ric_info_v2", description = "Information for a NearRT-RIC")
+@ApiModel(value = "ric_info_v2", description = "Information for a Near-RT RIC")
public class RicInfo {
@Gson.TypeAdapters
- @ApiModel(value = "ric_state_v2", description = "Represents the states for a NearRT-RIC")
+ @ApiModel(value = "ric_state_v2", description = "Represents the states for a Near-RT RIC")
public enum RicState {
UNAVAILABLE, AVAILABLE, SYNCHRONIZING, CONSISTENCY_CHECK
}
- private static final String STATE_DESCRIPTION = "State for the NearRT-RIC, values: \n"
- + "UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent \n"
+ private static final String STATE_DESCRIPTION = "State for the Near-RT RIC, values: \n"
+ + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n"
+ "AVAILABLE: The normal state. Policies can be configured. +\n"
- + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the NearRT-RIC. Policies cannot be configured. \n"
- + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured.";
+ + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n"
+ + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.";
- @ApiModelProperty(value = "identity of the NearRT-RIC")
+ @ApiModelProperty(value = "identity of the Near-RT RIC")
@SerializedName("ric_id")
@JsonProperty("ric_id")
public final String ricId;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "ric_info_list_v2", description = "List of NearRT-RIC information")
+@ApiModel(value = "ric_info_list_v2", description = "List of Near-RT RIC information")
public class RicInfoList {
- @ApiModelProperty(value = "List of NearRT-RIC information")
+ @ApiModelProperty(value = "List of Near-RT RIC information")
@SerializedName("rics")
@JsonProperty("rics")
public final Collection<RicInfo> rics;
import org.springframework.web.bind.annotation.RestController;
@RestController("RicRepositoryControllerV2")
-@Api(tags = Consts.V2_API_NAME)
+@Api(tags = {Consts.V2_API_NAME})
public class RicRepositoryController {
@Autowired
.serializeNulls() //
.create(); //
+ private static final String GET_RIC_BRIEF = "Returns info for a Near-RT RIC";
+ private static final String GET_RIC_DETAILS =
+ "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" //
+ + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
+
/**
* Example: http://localhost:8081/v2/ric?managed_element_id=kista_1
*/
@GetMapping(path = Consts.V2_API_ROOT + "/ric", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Returns info for the NearRT-RIC with the given identity or managing one Mananged Element")
+ @ApiOperation(value = GET_RIC_BRIEF, notes = GET_RIC_DETAILS)
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "NearRT-RIC is found", response = RicInfo.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class) //
+ @ApiResponse(code = 200, message = "Near-RT RIC is found", response = RicInfo.class), //
+ @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class) //
})
public ResponseEntity<Object> getRic( //
@ApiParam(
name = Consts.MANAGED_ELEMENT_ID_PARAM,
required = false,
- value = "The identity of a Managed Element. If given, the NearRT-RIC managing the ME is returned.") //
+ value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") //
@RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId,
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of a NearRT-RIC to get information for.") //
+ value = "The identity of a Near-RT RIC to get information for.") //
@RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
try {
if (managedElementId != null && ricId != null) {
if (ric.isPresent()) {
return new ResponseEntity<>(gson.toJson(toRicInfo(ric.get())), HttpStatus.OK);
} else {
- return ErrorResponse.create("No NearRT-RIC managing the ME is found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("No Near-RT RIC managing the ME is found", HttpStatus.NOT_FOUND);
}
} else if (ricId != null) {
RicInfo info = toRicInfo(this.rics.getRic(ricId));
}
}
+ static final String QUERY_RIC_INFO_DETAILS =
+ "The call returns all Near-RT RICs that supports a given policy type identity";
+
/**
* @return a Json array of all RIC data Example: http://localhost:8081/v2/ric
*/
@GetMapping(path = Consts.V2_API_ROOT + "/rics", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Query NearRT-RIC information")
+ @ApiOperation(value = "Query Near-RT RIC information", notes = QUERY_RIC_INFO_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfoList.class), //
@ApiParam(
name = Consts.POLICY_TYPE_ID_PARAM,
required = false,
- value = "The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned") //
+ value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") //
@RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) {
if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
private RicInfo.RicState toRicState(Ric.RicState state) {
- if (state == Ric.RicState.AVAILABLE) {
- return RicInfo.RicState.AVAILABLE;
- } else if (state == Ric.RicState.CONSISTENCY_CHECK) {
- return RicInfo.RicState.CONSISTENCY_CHECK;
- } else if (state == Ric.RicState.SYNCHRONIZING) {
- return RicInfo.RicState.SYNCHRONIZING;
- } else if (state == Ric.RicState.UNAVAILABLE) {
- return RicInfo.RicState.UNAVAILABLE;
+ switch (state) {
+ case AVAILABLE:
+ return RicInfo.RicState.AVAILABLE;
+ case CONSISTENCY_CHECK:
+ return RicInfo.RicState.CONSISTENCY_CHECK;
+ case SYNCHRONIZING:
+ return RicInfo.RicState.SYNCHRONIZING;
+ case UNAVAILABLE:
+ return RicInfo.RicState.UNAVAILABLE;
+ default:
+ return RicInfo.RicState.UNAVAILABLE;
}
- return RicInfo.RicState.UNAVAILABLE;
}
private RicInfo toRicInfo(Ric ric) {
this.policies = policies;
}
+ private static final String GET_SERVICE_DETAILS =
+ "Either information about a registered service with given identity or all registered services are returned.";
+
@GetMapping(path = Consts.V2_API_ROOT + "/services", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Returns service information")
+ @ApiOperation(value = "Returns service information", notes = GET_SERVICE_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatusList.class), //
@ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") //
@RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) {
if (name != null && this.services.get(name) == null) {
- return ErrorResponse.create("Service type not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Service not found", HttpStatus.NOT_FOUND);
}
Collection<ServiceStatus> servicesStatus = new ArrayList<>();
}
}
- @ApiOperation(value = "Register a service")
+ private static final String REGISTER_SERVICE_DETAILS = "Registering a service is needed to:" //
+ + "<ul>" //
+ + "<li>Get callbacks.</li>" //
+ + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"//
+ + "</ul>" //
+ ;
+
+ @ApiOperation(value = "Register a service", notes = REGISTER_SERVICE_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Service updated"),
}
}
- @ApiOperation(value = "Delete a service")
+ @ApiOperation(value = "Unregister a service")
@ApiResponses(
value = { //
- @ApiResponse(code = 204, message = "Service deleted"),
+ @ApiResponse(code = 204, message = "Service unregistered"),
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)})
@DeleteMapping(Consts.V2_API_ROOT + "/services")
public ResponseEntity<Object> deleteService(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The name of the service") //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") //
@RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
try {
Service service = removeService(serviceName);
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
/**
- * Holds information about a NearRT-RIC.
+ * Holds information about a Near-RT RIC.
*/
public class Ric {
*/
public enum RicState {
/**
- * The Policy Management Service's view of the NearRT-RIC may be inconsistent.
+ * The Policy Management Service's view of the Near-RT RIC may be inconsistent.
*/
UNAVAILABLE,
/**
*/
AVAILABLE,
/**
- * The Policy Management Service is synchronizing the view of the NearRT-RIC.
+ * The Policy Management Service is synchronizing the view of the Near-RT RIC.
*/
SYNCHRONIZING,
/**
- * A consistency check between the Policy Management Service and the NearRT-RIC
+ * A consistency check between the Policy Management Service and the Near-RT RIC
* is done
*/
CONSISTENCY_CHECK
/**
* Regularly checks the existing rics towards the local repository to keep it
- * consistent. When the policy types or instances in the NearRT-RIC is not
+ * consistent. When the policy types or instances in the Near-RT RIC is not
* consistent, a synchronization is performed.
*/
@Component
import reactor.core.publisher.SignalType;
/**
- * Synchronizes the content of a NearRT-RIC with the content in the repository.
+ * Synchronizes the content of a Near-RT RIC with the content in the repository.
* This means:
* <p>
* load all policy types
* <p>
- * send all policy instances to the NearRT-RIC
+ * send all policy instances to the Near-RT RIC
* <p>
* if that fails remove all policy instances
* <p>
Policy policy2 = addPolicy("policyId2", "typeName", "service", ric1Name);
Ric ric2 = addRic("ric2");
- getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (NearRT-RIC)
+ getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (Near-RT RIC)
policies.remove(policy2); // Remove it from the repo -> should be deleted in the RIC
String policyId = "policyId";
assertThat(logAppender.list.get(0).getFormattedMessage()).isEqualTo("Configuration refresh terminated");
}
- @Test
- void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
- refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
- String errorMessage = "Error";
- doReturn(Flux.error(new Exception(errorMessage))).when(refreshTaskUnderTest).createRefreshTask();
-
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
-
- refreshTaskUnderTest.start();
-
- ILoggingEvent event = logAppender.list.get(0);
- assertThat(event.getFormattedMessage())
- .isEqualTo("Configuration refresh terminated due to exception java.lang.Exception: " + errorMessage);
- }
-
@Test
void stop_thenTaskIsDisposed() throws Exception {
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
// When
- doReturn(getIncorrectJson()).when(refreshTaskUnderTest).createInputStream(any());
+ final String JUNK_JSON = "{\"junk }";
+ doReturn(getJsonSteam(JUNK_JSON)).when(refreshTaskUnderTest).createInputStream(any());
doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(true);
+ JsonObject configAsJson = getJsonRootObject(getCorrectJson());
String newBaseUrl = "newBaseUrl";
modifyTheRicConfiguration(configAsJson, newBaseUrl);
when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(false);
- when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
+ JsonObject emptyJsonObject = new JsonObject();
+ when(cbsClient.get(any())).thenReturn(Mono.just(emptyJsonObject));
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
.addProperty("baseUrl", newBaseUrl);
}
- private JsonObject getJsonRootObject(boolean valid) throws JsonIOException, JsonSyntaxException, IOException {
- JsonObject rootObject = JsonParser
- .parseReader(new InputStreamReader(valid ? getCorrectJson() : getIncorrectJson())).getAsJsonObject();
+ private JsonObject getJsonRootObject(InputStream inStream)
+ throws JsonIOException, JsonSyntaxException, IOException {
+ JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject();
return rootObject;
}
return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
}
- private static InputStream getIncorrectJson() {
- String string = "{}"; //
- return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
+ private static InputStream getJsonSteam(String json) {
+ return new ByteArrayInputStream((json.getBytes(StandardCharsets.UTF_8)));
}
}