From: PatrikBuhr Date: Mon, 16 Dec 2019 15:01:13 +0000 (+0100) Subject: Integrating A1 client with service supervision X-Git-Tag: 1.0.1~69 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=4a112834cf7ea69f230fde864856093ecadb9cfe;p=nonrtric.git Integrating A1 client with service supervision Introducing a "mock" mode. Added som test schemas that I forgot to add in the previous commit. Code formatting, Change-Id: Ide38969ae8513d0d86d798696306191b9bc2f5b4 Issue-ID: NONRTRIC-84 Signed-off-by: PatrikBuhr --- diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java index 8236de1d..a2b52384 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java @@ -112,7 +112,6 @@ public class PolicyAgentApiImpl implements PolicyAgentApi { result.add(p); } return result; - } @Override diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java index 4213488e..0736064a 100644 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java +++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java @@ -90,7 +90,6 @@ public class PolicyControllerMockConfiguration { result.addAll(inst); return result; } - } class Database { diff --git a/dashboard/webapp-frontend/src/app/footer/footer.component.scss b/dashboard/webapp-frontend/src/app/footer/footer.component.scss index c06dc010..fb87ba5f 100644 --- a/dashboard/webapp-frontend/src/app/footer/footer.component.scss +++ b/dashboard/webapp-frontend/src/app/footer/footer.component.scss @@ -21,6 +21,7 @@ color: gray; letter-spacing: 0.1rem; font-size: 10px; + margin-left: 10px; } .copyright__text-dark { diff --git a/policy-agent/src/main/java/org/oransc/policyagent/BeanFactory.java b/policy-agent/src/main/java/org/oransc/policyagent/BeanFactory.java index 637eac1f..06b66ca6 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/BeanFactory.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/BeanFactory.java @@ -20,6 +20,8 @@ package org.oransc.policyagent; +import org.oransc.policyagent.clients.A1Client; +import org.oransc.policyagent.clients.A1ClientImpl; import org.oransc.policyagent.configuration.ApplicationConfig; import org.oransc.policyagent.repository.Policies; import org.oransc.policyagent.repository.PolicyTypes; @@ -55,4 +57,9 @@ class BeanFactory { return new Services(); } + @Bean + A1Client getA1Client() { + return new A1ClientImpl(); + } + } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1Client.java index db048fb3..9ad5dd76 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1Client.java @@ -19,103 +19,19 @@ */ package org.oransc.policyagent.clients; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.List; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -public class A1Client { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); +public interface A1Client { - public String getBaseUrl(final String nearRtRicUrl) { - return nearRtRicUrl + "/A1-P/v1"; - } + public Flux getAllPolicyTypes(String nearRtRicUrl); - public Flux getAllPolicyTypes(String nearRtRicUrl) { - logger.debug("getAllPolicyTypes nearRtRicUrl = {}", nearRtRicUrl); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); - Mono response = client.get("/policytypes"); - return response.flatMapMany(this::createPolicyTypesFlux); - } + public Flux getPoliciesForType(String nearRtRicUrl, String policyTypeId); - public Flux getPoliciesForType(String nearRtRicUrl, String policyTypeId) { - logger.debug("getPoliciesForType nearRtRicUrl = {}, policyTypeId = {}", nearRtRicUrl, policyTypeId); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); - Mono response = client.get("/policies"); - return response.flatMapMany(policiesString -> createPoliciesFlux(policiesString, policyTypeId)); - } + public Mono getPolicy(String nearRtRicUrl, String policyId); - public Mono getPolicy(String nearRtRicUrl, String policyId) { - logger.debug("getPolicy nearRtRicUrl = {}, policyId = {}", nearRtRicUrl, policyId); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); - Mono response = client.get("/policies/" + policyId); - return response.flatMap(this::createPolicyMono); - } + public Mono putPolicy(String nearRtRicUrl, String policyId, String policyString); - public Mono putPolicy(String nearRtRicUrl, String policyId, String policyString) { - logger.debug("putPolicy nearRtRicUrl = {}, policyId = {}, policyString = {}", nearRtRicUrl, policyId, - policyString); - try { - new JSONObject(policyString); - } catch (JSONException ex) { // invalid json - return Mono.error(ex); - } - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); - Mono response = client.put("/policies/" + policyId, policyString); - return response.flatMap(this::createPolicyMono); - } + public Mono deletePolicy(String nearRtRicUrl, String policyId); - public Mono deletePolicy(String nearRtRicUrl, String policyId) { - logger.debug("deletePolicy nearRtRicUrl = {}, policyId = {}", nearRtRicUrl, policyId); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); - return client.delete("/policies/" + policyId); - } - - private Flux createPolicyTypesFlux(String policyTypesString) { - try { - List policyTypesList = new ArrayList<>(); - JSONArray policyTypesArray = new JSONArray(policyTypesString); - for (int i = 0; i < policyTypesArray.length(); i++) { - policyTypesList.add(policyTypesArray.getJSONObject(i).toString()); - } - logger.debug("A1 client: policyTypes = {}", policyTypesList); - return Flux.fromIterable(policyTypesList); - } catch (JSONException ex) { // invalid json - return Flux.error(ex); - } - } - - private Flux createPoliciesFlux(String policiesString, String policyTypeId) { - try { - List policiesList = new ArrayList<>(); - JSONArray policiesArray = new JSONArray(policiesString); - for (int i = 0; i < policiesArray.length(); i++) { - JSONObject policyObject = policiesArray.getJSONObject(i); - if (policyObject.get("policyTypeId").equals(policyTypeId)) { - policiesList.add(policyObject.toString()); - } - } - logger.debug("A1 client: policies = {}", policiesList); - return Flux.fromIterable(policiesList); - } catch (JSONException ex) { // invalid json - return Flux.error(ex); - } - } - - private Mono createPolicyMono(String policyString) { - try { - JSONObject policyObject = new JSONObject(policyString); - String policy = policyObject.toString(); - logger.debug("A1 client: policy = {}", policy); - return Mono.just(policy); - } catch (JSONException ex) { // invalid json - return Mono.error(ex); - } - } } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java new file mode 100644 index 00000000..4f7a9ddf --- /dev/null +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java @@ -0,0 +1,124 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 Nordix Foundation + * %% + * 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.oransc.policyagent.clients; + +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class A1ClientImpl implements A1Client { + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private static String getBaseUrl(final String nearRtRicUrl) { + return nearRtRicUrl + "/A1-P/v1"; + } + + @Override + public Flux getAllPolicyTypes(String nearRtRicUrl) { + logger.debug("getAllPolicyTypes nearRtRicUrl = {}", nearRtRicUrl); + AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + Mono response = client.get("/policytypes"); + return response.flatMapMany(this::createPolicyTypesFlux); + } + + @Override + public Flux getPoliciesForType(String nearRtRicUrl, String policyTypeId) { + logger.debug("getPoliciesForType nearRtRicUrl = {}, policyTypeId = {}", nearRtRicUrl, policyTypeId); + AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + return client.get("/policies") // + .flatMapMany(policiesString -> createPoliciesFlux(policiesString, policyTypeId)); + } + + @Override + public Mono getPolicy(String nearRtRicUrl, String policyId) { + logger.debug("getPolicy nearRtRicUrl = {}, policyId = {}", nearRtRicUrl, policyId); + AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + Mono response = client.get("/policies/" + policyId); + return response.flatMap(this::createPolicyMono); + } + + @Override + public Mono putPolicy(String nearRtRicUrl, String policyId, String policyString) { + logger.debug("putPolicy nearRtRicUrl = {}, policyId = {}, policyString = {}", nearRtRicUrl, policyId, + policyString); + AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + Mono response = client.put("/policies/" + policyId, policyString); + return response.flatMap(this::createPolicyMono); + } + + @Override + public Mono deletePolicy(String nearRtRicUrl, String policyId) { + logger.debug("deletePolicy nearRtRicUrl = {}, policyId = {}", nearRtRicUrl, policyId); + AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + return client.delete("/policies/" + policyId); + } + + private Flux createPolicyTypesFlux(String policyTypesString) { + try { + List policyTypesList = new ArrayList<>(); + JSONArray policyTypesArray = new JSONArray(policyTypesString); + for (int i = 0; i < policyTypesArray.length(); i++) { + policyTypesList.add(policyTypesArray.getJSONObject(i).toString()); + } + logger.debug("A1 client: policyTypes = {}", policyTypesList); + return Flux.fromIterable(policyTypesList); + } catch (JSONException ex) { // invalid json + return Flux.error(ex); + } + } + + private Flux createPoliciesFlux(String policiesString, String policyTypeId) { + try { + List policiesList = new ArrayList<>(); + JSONArray policiesArray = new JSONArray(policiesString); + for (int i = 0; i < policiesArray.length(); i++) { + JSONObject policyObject = policiesArray.getJSONObject(i); + if (policyObject.get("policyTypeId").equals(policyTypeId)) { + policiesList.add(policyObject.toString()); + } + } + logger.debug("A1 client: policies = {}", policiesList); + return Flux.fromIterable(policiesList); + } catch (JSONException ex) { // invalid json + return Flux.error(ex); + } + } + + private Mono createPolicyMono(String policyString) { + try { + JSONObject policyObject = new JSONObject(policyString); + String policy = policyObject.toString(); + logger.debug("A1 client: policy = {}", policy); + return Mono.just(policy); + } catch (JSONException ex) { // invalid json + return Mono.error(ex); + + } + } +} diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyInfo.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyInfo.java index eb54ba93..cd45f9ed 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyInfo.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyInfo.java @@ -19,7 +19,6 @@ */ package org.oransc.policyagent.controllers; - import org.immutables.gson.Gson; import org.immutables.value.Value; diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyTypeInfo.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyTypeInfo.java index efd749a4..ae93b5e1 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyTypeInfo.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyTypeInfo.java @@ -19,7 +19,6 @@ */ package org.oransc.policyagent.controllers; - import org.immutables.gson.Gson; import org.immutables.value.Value; diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicInfo.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicInfo.java index 11391514..bfb5b36e 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicInfo.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicInfo.java @@ -19,7 +19,6 @@ */ package org.oransc.policyagent.controllers; - import java.util.Vector; import org.immutables.gson.Gson; diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceRegistrationInfo.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceRegistrationInfo.java index fe920a92..6ffaebd3 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceRegistrationInfo.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceRegistrationInfo.java @@ -19,7 +19,6 @@ */ package org.oransc.policyagent.controllers; - import org.immutables.gson.Gson; import org.immutables.value.Value; diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java index 3caadaed..df612dc5 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Vector; import org.oransc.policyagent.configuration.RicConfig; -import org.oransc.policyagent.repository.Ric.RicState; /** * Represents the dynamic information about a NearRealtime-RIC. @@ -56,6 +55,10 @@ public class Ric { state = newState; } + public RicConfig getConfig() { + return this.ricConfig; + } + /** * Gets the nodes managed by this Ric. * diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java index acb546bc..f2de7cf1 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java @@ -20,6 +20,7 @@ package org.oransc.policyagent.tasks; +import org.oransc.policyagent.clients.A1Client; import org.oransc.policyagent.repository.Policies; import org.oransc.policyagent.repository.Policy; import org.oransc.policyagent.repository.Service; @@ -30,7 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; @Component @EnableScheduling @@ -38,11 +41,13 @@ public class ServiceSupervision { private static final Logger logger = LoggerFactory.getLogger(ServiceSupervision.class); private final Services services; private final Policies policies; + private A1Client a1Client; @Autowired - public ServiceSupervision(Services services, Policies policies) { + public ServiceSupervision(Services services, Policies policies, A1Client a1Client) { this.services = services; this.policies = policies; + this.a1Client = a1Client; } @Scheduled(fixedRate = 1000 * 60) @@ -63,16 +68,27 @@ public class ServiceSupervision { logger.debug("Checking services completed"); } - Flux createTask() { + private Flux createTask() { return Flux.fromIterable(services.getAll()) // .filter(service -> service.isExpired()) // .doOnNext(service -> logger.info("Service is expired:" + service.getName())) .flatMap(service -> getAllPolicies(service)) // - .doOnNext(policy -> this.policies.remove(policy)); + .doOnNext(policy -> this.policies.remove(policy)) // + .flatMap(policy -> deletePolicyInRic(policy)); } - Flux getAllPolicies(Service service) { + private Flux getAllPolicies(Service service) { return Flux.fromIterable(policies.getForService(service.getName())); } + private Mono deletePolicyInRic(Policy policy) { + return a1Client.deletePolicy(policy.ric().getConfig().baseUrl(), policy.id()) // + .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) // + .flatMap((nothing) -> Mono.just(policy)); + } + + private Mono handleDeleteFromRicFailure(Policy policy, Throwable e) { + logger.warn("Could not delete policy: {} from ric: {}", policy.id(), policy.ric().name(), e); + return Mono.empty(); + } } diff --git a/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java b/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java index d02522c5..b7ea7dd1 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java @@ -26,9 +26,11 @@ import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.Files; +import java.util.Vector; import org.junit.Test; import org.junit.runner.RunWith; +import org.oransc.policyagent.clients.A1Client; import org.oransc.policyagent.configuration.ApplicationConfig; import org.oransc.policyagent.repository.ImmutablePolicyType; import org.oransc.policyagent.repository.Policies; @@ -43,6 +45,9 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.test.context.junit4.SpringRunner; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) public class MockPolicyAgent { @@ -64,16 +69,85 @@ public class MockPolicyAgent { } } + static class A1ClientMock implements A1Client { + private final Policies policies; + private final PolicyTypes policyTypes; + + A1ClientMock(Policies policies, PolicyTypes policyTypes) { + this.policies = policies; + this.policyTypes = policyTypes; + } + + @Override + public Flux getAllPolicyTypes(String nearRtRicUrl) { + Vector result = new Vector<>(); + for (PolicyType p : this.policyTypes.getAll()) { + result.add(p.name()); + } + return Flux.fromIterable(result); + } + + @Override + public Flux getPoliciesForType(String nearRtRicUrl, String policyTypeId) { + return Flux.empty(); + } + + @Override + public Mono getPolicy(String nearRtRicUrl, String policyId) { + try { + return Mono.just(this.policies.get(policyId).json()); + } catch (Exception e) { + return Mono.error(e); + } + } + + @Override + public Mono putPolicy(String nearRtRicUrl, String policyId, String policyString) { + return Mono.just("OK"); + } + + @Override + public Mono deletePolicy(String nearRtRicUrl, String policyId) { + return Mono.error(new Exception("TODO We cannot use Void like this")); // TODO We cannot use Void like this + } + + } + /** * overrides the BeanFactory */ @TestConfiguration static class TestBeanFactory { + private final Rics rics = new Rics(); + private final Policies policies = new Policies(); + private final PolicyTypes policyTypes = new PolicyTypes(); + @Bean public ApplicationConfig getApplicationConfig() { return new MockApplicationConfig(); } + + @Bean + A1Client getA1Client() { + return new A1ClientMock(this.policies, this.policyTypes); + } + + @Bean + public Policies getPolicies() { + return this.policies; + } + + @Bean + public PolicyTypes getPolicyTypes() { + return this.policyTypes; + } + + @Bean + public Rics getRics() { + return this.rics; + } + } @LocalServerPort diff --git a/policy-agent/src/test/resources/policy_types/anr-policy-schema.json b/policy-agent/src/test/resources/policy_types/anr-policy-schema.json new file mode 100644 index 00000000..6e0263d0 --- /dev/null +++ b/policy-agent/src/test/resources/policy_types/anr-policy-schema.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ANR", + "description": "ANR Neighbour Cell Relation Policy", + "type": "object", + "properties": { + "servingCellNrcgi": { + "type": "string", + "description": "Serving Cell Identifier (NR CGI)" + }, + "neighborCellNrpci": { + "type": "string", + "description": "Neighbor Cell Identifier (NR PCI)" + }, + "neighborCellNrcgi": { + "type": "string", + "description": "Neighbor Cell Identifier (NR CGI)" + }, + "flagNoHo": { + "type": "boolean", + "description": "Flag for HANDOVER NOT ALLOWED" + }, + "flagNoXn": { + "type": "boolean", + "description": "Flag for Xn CONNECTION NOT ALLOWED" + }, + "flagNoRemove": { + "type": "boolean", + "description": "Flag for DELETION NOT ALLOWED" + } + }, + "required": [ + "servingCellNrcgi", + "neighborCellNrpci", + "neighborCellNrcgi", + "flagNoHo", + "flagNoXn", + "flagNoRemove" + ] +} \ No newline at end of file diff --git a/policy-agent/src/test/resources/policy_types/demo-policy-schema-1.json b/policy-agent/src/test/resources/policy_types/demo-policy-schema-1.json new file mode 100644 index 00000000..fa7410fb --- /dev/null +++ b/policy-agent/src/test/resources/policy_types/demo-policy-schema-1.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Example_QoSTarget_1.0.0", + "description": "Example QoS Target policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "qosId": { + "type": "string" + }, + "cellId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "qosId" + ] + }, + "statement": { + "type": "object", + "properties": { + "gfbr": { + "type": "number" + }, + "mfbr": { + "type": "number" + }, + "priorityLevel": { + "type": "number" + }, + "pdb": { + "type": "number" + } + }, + "minProperties": 1, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/policy-agent/src/test/resources/policy_types/demo-policy-schema-2.json b/policy-agent/src/test/resources/policy_types/demo-policy-schema-2.json new file mode 100644 index 00000000..f3eb28fb --- /dev/null +++ b/policy-agent/src/test/resources/policy_types/demo-policy-schema-2.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Example_QoETarget_1.0.0", + "description": "Example QoE Target policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "sliceId": { + "type": "string" + }, + "qosId": { + "type": "string" + }, + "cellId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "sliceId" + ] + }, + "statement": { + "type": "object", + "properties": { + "qoeScore": { + "type": "number" + }, + "initialBuffering": { + "type": "number" + }, + "reBuffFreq": { + "type": "number" + }, + "stallRatio": { + "type": "number" + } + }, + "minProperties": 1, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/policy-agent/src/test/resources/policy_types/demo-policy-schema-3.json b/policy-agent/src/test/resources/policy_types/demo-policy-schema-3.json new file mode 100644 index 00000000..695514cd --- /dev/null +++ b/policy-agent/src/test/resources/policy_types/demo-policy-schema-3.json @@ -0,0 +1,59 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Example_TrafficSteeringPreference_1.0.0", + "description": "Example QoE Target policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "sliceId": { + "type": "string" + }, + "qosId": { + "type": "string" + }, + "cellId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId" + ] + }, + "statement": { + "type": "object", + "properties": { + "cellIdList": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "preference": { + "type": "string", + "enum": [ + "SHALL", + "PREFER", + "AVOID", + "FORBID" + ] + }, + "primary": { + "type": "boolean" + } + }, + "required": [ + "cellIdList", + "preference" + ], + "additionalProperties": false + } + } +} \ No newline at end of file