Preload legacy operational policy type and guard policy types 80/87180/2
authorChenfei Gao <cgao@research.att.com>
Tue, 7 May 2019 18:46:22 +0000 (14:46 -0400)
committerChenfei Gao <cgao@research.att.com>
Wed, 8 May 2019 00:02:07 +0000 (20:02 -0400)
Includes:
a) Add legacy operational policy type and guard policy types into
preloading list.
b) Fix corresponding junit test failure.

Issue-ID: POLICY-1738
Change-Id: I071e898be31e62f47d427094f1e76069fafd0148
Signed-off-by: Chenfei Gao <cgao@research.att.com>
14 files changed:
main/src/main/java/org/onap/policy/api/main/startstop/ApiDatabaseInitializer.java
main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.Operational.json [new file with mode: 0644]
main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.Blacklist.json [new file with mode: 0644]
main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.FrequencyLimiter.json [new file with mode: 0644]
main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.MinMax.json [new file with mode: 0644]
main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
main/src/test/resources/policytypes/onap.policies.controlloop.Operational.json [new file with mode: 0644]
main/src/test/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.json [new file with mode: 0644]
main/src/test/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.json [moved from main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json with 100% similarity]
main/src/test/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml [moved from main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml with 100% similarity]

index 3973e62..27fc83a 100644 (file)
@@ -60,7 +60,11 @@ public class ApiDatabaseInitializer {
         "preloadedPolicyTypes/onap.policies.optimization.QueryPolicy.json",
         "preloadedPolicyTypes/onap.policies.optimization.SubscriberPolicy.json",
         "preloadedPolicyTypes/onap.policies.optimization.Vim_fit.json",
-        "preloadedPolicyTypes/onap.policies.optimization.VnfPolicy.json"
+        "preloadedPolicyTypes/onap.policies.optimization.VnfPolicy.json",
+        "preloadedPolicyTypes/onap.policies.controlloop.guard.Blacklist.json",
+        "preloadedPolicyTypes/onap.policies.controlloop.guard.FrequencyLimiter.json",
+        "preloadedPolicyTypes/onap.policies.controlloop.guard.MinMax.json",
+        "preloadedPolicyTypes/onap.policies.controlloop.Operational.json"
     };
 
     /**
diff --git a/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.Operational.json b/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.Operational.json
new file mode 100644 (file)
index 0000000..2d36a25
--- /dev/null
@@ -0,0 +1,12 @@
+{
+   "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Operational": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Operational Policy for Control Loops"
+         }
+      }
+   ]
+}
\ No newline at end of file
diff --git a/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.Blacklist.json b/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.Blacklist.json
new file mode 100644 (file)
index 0000000..9391496
--- /dev/null
@@ -0,0 +1,62 @@
+{
+   "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Guard": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Guard Policies for Control Loop Operational Policies"
+         }
+      },
+      {
+         "onap.policies.controlloop.guard.Blacklist": {
+            "derived_from": "onap.policies.controlloop.Guard",
+            "version": "1.0.0",
+            "description": "Supports blacklist of VNF's from performing control loop actions on.",
+            "properties": {
+               "blacklist_policy": {
+                  "type": "map",
+                  "description": null,
+                  "entry_schema": {
+                     "type": "onap.datatypes.guard.Blacklist"
+                  }
+               }
+            }
+         }
+      }
+   ],
+   "data_types": [
+      {
+         "onap.datatypes.guard.Blacklist": {
+            "derived_from": "tosca.datatypes.Root",
+            "properties": {
+               "actor": {
+                  "type": "string",
+                  "description": "Specifies the Actor",
+                  "required": true
+               },
+               "recipe": {
+                  "type": "string",
+                  "description": "Specified the Recipe",
+                  "required": true
+               },
+               "time_range": {
+                  "type": "tosca.datatypes.TimeInterval",
+                  "description": "An optional range of time during the day the blacklist is valid for.",
+                  "required": false
+               },
+               "controlLoopName": {
+                  "type": "string",
+                  "description": "An optional specific control loop to apply this guard to.",
+                  "required": false
+               },
+               "blacklist": {
+                  "type": "list",
+                  "description": "List of VNF's",
+                  "required": true
+               }
+            }
+         }
+      }
+   ]
+}
\ No newline at end of file
diff --git a/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.FrequencyLimiter.json b/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.FrequencyLimiter.json
new file mode 100644 (file)
index 0000000..598bd3c
--- /dev/null
@@ -0,0 +1,77 @@
+{
+   "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Guard": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Guard Policies for Control Loop Operational Policies"
+         }
+      },
+      {
+         "onap.policies.controlloop.guard.FrequencyLimiter": {
+            "derived_from": "onap.policies.controlloop.Guard",
+            "version": "1.0.0",
+            "description": "Supports limiting the frequency of actions being taken by a Actor.",
+            "properties": {
+               "frequency_policy": {
+                  "type": "map",
+                  "description": null,
+                  "entry_schema": {
+                     "type": "onap.datatypes.guard.FrequencyLimiter"
+                  }
+               }
+            }
+         }
+      }
+   ],
+   "data_types": [
+      {
+         "onap.datatypes.guard.FrequencyLimiter": {
+            "derived_from": "tosca.datatypes.Root",
+            "properties": {
+               "actor": {
+                  "type": "string",
+                  "description": "Specifies the Actor",
+                  "required": true
+               },
+               "recipe": {
+                  "type": "string",
+                  "description": "Specified the Recipe",
+                  "required": true
+               },
+               "time_window": {
+                  "type": "scalar-unit.time",
+                  "description": "The time window to count the actions against.",
+                  "required": true
+               },
+               "limit": {
+                  "type": "integer",
+                  "description": "The limit",
+                  "required": true,
+                  "constraints": [
+                     {
+                        "greater_than": 0
+                     }
+                  ]
+               },
+               "time_range": {
+                  "type": "tosca.datatypes.TimeInterval",
+                  "description": "An optional range of time during the day the frequency is valid for.",
+                  "required": false
+               },
+               "controlLoopName": {
+                  "type": "string",
+                  "description": "An optional specific control loop to apply this guard to.",
+                  "required": false
+               },
+               "target": {
+                  "type": "string",
+                  "description": "An optional specific VNF to apply this guard to.",
+                  "required": false
+               }
+            }
+         }
+      }
+   ]
+}
\ No newline at end of file
diff --git a/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.MinMax.json b/main/src/main/resources/preloadedPolicyTypes/onap.policies.controlloop.guard.MinMax.json
new file mode 100644 (file)
index 0000000..71658dd
--- /dev/null
@@ -0,0 +1,66 @@
+{
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Guard": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Guard Policies for Control Loop Operational Policies"
+         }
+      },
+      {
+         "onap.policies.controlloop.guard.MinMax": {
+            "derived_from": "onap.policies.controlloop.Guard",
+            "version": "1.0.0",
+            "description": "Supports Min/Max number of VF Modules",
+            "properties": {
+               "minmax_policy": {
+                  "type": "map",
+                  "description": null,
+                  "entry_schema": {
+                     "type": "onap.datatypes.guard.MinMax"
+                  }
+               }
+            }
+         }
+      }
+   ],
+   "data_types": [
+      {
+         "onap.datatypes.guard.MinMax": {
+            "derived_from": "tosca.datatypes.Root",
+            "properties": {
+               "actor": {
+                  "type": "string",
+                  "description": "Specifies the Actor",
+                  "required": true
+               },
+               "recipe": {
+                  "type": "string",
+                  "description": "Specified the Recipe",
+                  "required": true
+               },
+               "time_range": {
+                  "type": "tosca.datatypes.TimeInterval",
+                  "description": "An optional range of time during the day the Min/Max limit is valid for.",
+                  "required": false
+               },
+               "controlLoopName": {
+                  "type": "string",
+                  "description": "An optional specific control loop to apply this guard to.",
+                  "required": false
+               },
+               "min_vf_module_instances": {
+                  "type": "integer",
+                  "required": true,
+                  "description": "The minimum instances of this VF-Module"
+               },
+               "max_vf_module_instances": {
+                  "type": "integer",
+                  "required": false,
+                  "description": "The maximum instances of this VF-Module"
+               }
+            }
+         }
+      }
+   ]
+}
\ No newline at end of file
index 0d82054..6be9173 100644 (file)
@@ -144,7 +144,7 @@ public class TestApiRestServer {
     };
 
     private String[] toscaPolicyTypeResourceNames = {
-        "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json",
+        "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.json",
         "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.json"
     };
 
@@ -447,7 +447,7 @@ public class TestApiRestServer {
             main = startApiService(true);
             for (String resrcName : legacyGuardPolicyResourceNames) {
                 Response rawResponse = createGuardPolicy(GUARD_POLICIES, resrcName, true);
-                assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+                assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
             }
         }).doesNotThrowAnyException();
     }
@@ -459,7 +459,7 @@ public class TestApiRestServer {
             main = startApiService(true);
             for (String resrcName : legacyOperationalPolicyResourceNames) {
                 Response rawResponse = createOperationalPolicy(OPS_POLICIES, resrcName, true);
-                assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+                assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
             }
         }).doesNotThrowAnyException();
     }
@@ -601,7 +601,7 @@ public class TestApiRestServer {
             main = startApiService(false);
             for (String resrcName : legacyGuardPolicyResourceNames) {
                 Response rawResponse = createGuardPolicy(GUARD_POLICIES, resrcName, false);
-                assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+                assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
             }
         }).doesNotThrowAnyException();
     }
@@ -613,7 +613,7 @@ public class TestApiRestServer {
             main = startApiService(false);
             for (String resrcName : legacyOperationalPolicyResourceNames) {
                 Response rawResponse = createOperationalPolicy(OPS_POLICIES, resrcName, false);
-                assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+                assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
             }
         }).doesNotThrowAnyException();
     }
index 76641aa..fb7c21c 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
 
@@ -51,11 +52,16 @@ import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
 public class TestLegacyGuardPolicyProvider {
 
     private static LegacyGuardPolicyProvider guardPolicyProvider;
+    private static PolicyTypeProvider policyTypeProvider;
     private static PolicyModelsProviderParameters providerParams;
     private static ApiParameterGroup apiParamGroup;
     private static StandardCoder standardCoder;
 
     private static final String POLICY_RESOURCE = "policies/vDNS.policy.guard.frequency.input.json";
+    private static final String POLICY_TYPE_RESOURCE =
+            "policytypes/onap.policies.controlloop.guard.FrequencyLimiter.json";
+    private static final String POLICY_TYPE_ID = "onap.policies.controlloop.guard.FrequencyLimiter:1.0.0";
+    private static final String POLICY_ID = "guard.frequency.scaleout:1.0.0";
 
     /**
      * Initializes parameters.
@@ -75,6 +81,7 @@ public class TestLegacyGuardPolicyProvider {
         apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
         ParameterService.register(apiParamGroup, true);
         guardPolicyProvider = new LegacyGuardPolicyProvider();
+        policyTypeProvider = new PolicyTypeProvider();
     }
 
     /**
@@ -86,6 +93,7 @@ public class TestLegacyGuardPolicyProvider {
     public static void tearDown() throws PfModelException {
 
         guardPolicyProvider.close();
+        policyTypeProvider.close();
         ParameterService.deregister(apiParamGroup);
     }
 
@@ -105,6 +113,19 @@ public class TestLegacyGuardPolicyProvider {
     @Test
     public void testCreateGuardPolicy() {
 
+        assertThatThrownBy(() -> {
+            String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+            LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
+            guardPolicyProvider.createGuardPolicy(policyToCreate);
+        }).hasMessage("policy type " + POLICY_TYPE_ID + " for policy " + POLICY_ID + " does not exist");
+
+        assertThatCode(() -> {
+            String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+            ToscaServiceTemplate policyTypeServiceTemplate =
+                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+        }).doesNotThrowAnyException();
+
         assertThatCode(() -> {
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
@@ -129,6 +150,13 @@ public class TestLegacyGuardPolicyProvider {
             guardPolicyProvider.deleteGuardPolicy("dummy", "dummy");
         }).hasMessage("no policy found for policy ID: dummy");
 
+        assertThatCode(() -> {
+            String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+            ToscaServiceTemplate policyTypeServiceTemplate =
+                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+        }).doesNotThrowAnyException();
+
         assertThatCode(() -> {
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
@@ -151,5 +179,10 @@ public class TestLegacyGuardPolicyProvider {
         assertThatThrownBy(() -> {
             guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1.0.0");
         }).hasMessage("no policy found for policy ID: guard.frequency.scaleout");
+
+        assertThatCode(() -> {
+            policyTypeProvider.deletePolicyType("onap.policies.controlloop.guard.FrequencyLimiter", "1.0.0");
+        }).doesNotThrowAnyException();
+
     }
 }
index 8aa1979..b5bcbbd 100644 (file)
@@ -38,6 +38,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
 
 /**
@@ -48,11 +49,15 @@ import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
 public class TestLegacyOperationalPolicyProvider {
 
     private static LegacyOperationalPolicyProvider operationalPolicyProvider;
+    private static PolicyTypeProvider policyTypeProvider;
     private static PolicyModelsProviderParameters providerParams;
     private static ApiParameterGroup apiParamGroup;
     private static StandardCoder standardCoder;
 
     private static final String POLICY_RESOURCE = "policies/vCPE.policy.operational.input.json";
+    private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.controlloop.Operational.json";
+    private static final String POLICY_TYPE_ID = "onap.policies.controlloop.Operational:1.0.0";
+    private static final String POLICY_ID = "operational.restart:1.0.0";
 
     /**
      * Initializes parameters.
@@ -72,6 +77,7 @@ public class TestLegacyOperationalPolicyProvider {
         apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
         ParameterService.register(apiParamGroup, true);
         operationalPolicyProvider = new LegacyOperationalPolicyProvider();
+        policyTypeProvider = new PolicyTypeProvider();
     }
 
     /**
@@ -83,6 +89,7 @@ public class TestLegacyOperationalPolicyProvider {
     public static void tearDown() throws PfModelException {
 
         operationalPolicyProvider.close();
+        policyTypeProvider.close();
         ParameterService.deregister(apiParamGroup);
     }
 
@@ -101,6 +108,19 @@ public class TestLegacyOperationalPolicyProvider {
     @Test
     public void testCreateOperationalPolicy() {
 
+        assertThatThrownBy(() -> {
+            String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+            LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
+            operationalPolicyProvider.createOperationalPolicy(policyToCreate);
+        }).hasMessage("policy type " + POLICY_TYPE_ID + " for policy " + POLICY_ID + " does not exist");
+
+        assertThatCode(() -> {
+            String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+            ToscaServiceTemplate policyTypeServiceTemplate =
+                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+        }).doesNotThrowAnyException();
+
         assertThatCode(() -> {
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
@@ -123,6 +143,13 @@ public class TestLegacyOperationalPolicyProvider {
             operationalPolicyProvider.deleteOperationalPolicy("dummy", "dummy");
         }).hasMessage("no policy found for policy ID: dummy");
 
+        assertThatCode(() -> {
+            String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+            ToscaServiceTemplate policyTypeServiceTemplate =
+                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+        }).doesNotThrowAnyException();
+
         assertThatCode(() -> {
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
@@ -142,5 +169,9 @@ public class TestLegacyOperationalPolicyProvider {
         assertThatThrownBy(() -> {
             operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1.0.0");
         }).hasMessage("no policy found for policy ID: operational.restart");
+
+        assertThatCode(() -> {
+            policyTypeProvider.deletePolicyType("onap.policies.controlloop.Operational", "1.0.0");
+        }).doesNotThrowAnyException();
     }
 }
index 0ae718d..8b1be3d 100644 (file)
@@ -52,7 +52,7 @@ public class TestPolicyProvider {
     private static StandardCoder standardCoder;
 
     private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
-    private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json";
+    private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.json";
     private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_ID = "policies/vCPE.policy.bad.policytypeid.json";
     private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION =
             "policies/vCPE.policy.bad.policytypeversion.json";
index 03d4933..7865453 100644 (file)
@@ -52,7 +52,7 @@ public class TestPolicyTypeProvider {
     private static StandardCoder standardCoder;
 
     private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
-    private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json";
+    private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.json";
 
     /**
      * Initializes parameters.
diff --git a/main/src/test/resources/policytypes/onap.policies.controlloop.Operational.json b/main/src/test/resources/policytypes/onap.policies.controlloop.Operational.json
new file mode 100644 (file)
index 0000000..2d36a25
--- /dev/null
@@ -0,0 +1,12 @@
+{
+   "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Operational": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Operational Policy for Control Loops"
+         }
+      }
+   ]
+}
\ No newline at end of file
diff --git a/main/src/test/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.json b/main/src/test/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.json
new file mode 100644 (file)
index 0000000..598bd3c
--- /dev/null
@@ -0,0 +1,77 @@
+{
+   "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+   "policy_types": [
+      {
+         "onap.policies.controlloop.Guard": {
+            "derived_from": "tosca.policies.Root",
+            "version": "1.0.0",
+            "description": "Guard Policies for Control Loop Operational Policies"
+         }
+      },
+      {
+         "onap.policies.controlloop.guard.FrequencyLimiter": {
+            "derived_from": "onap.policies.controlloop.Guard",
+            "version": "1.0.0",
+            "description": "Supports limiting the frequency of actions being taken by a Actor.",
+            "properties": {
+               "frequency_policy": {
+                  "type": "map",
+                  "description": null,
+                  "entry_schema": {
+                     "type": "onap.datatypes.guard.FrequencyLimiter"
+                  }
+               }
+            }
+         }
+      }
+   ],
+   "data_types": [
+      {
+         "onap.datatypes.guard.FrequencyLimiter": {
+            "derived_from": "tosca.datatypes.Root",
+            "properties": {
+               "actor": {
+                  "type": "string",
+                  "description": "Specifies the Actor",
+                  "required": true
+               },
+               "recipe": {
+                  "type": "string",
+                  "description": "Specified the Recipe",
+                  "required": true
+               },
+               "time_window": {
+                  "type": "scalar-unit.time",
+                  "description": "The time window to count the actions against.",
+                  "required": true
+               },
+               "limit": {
+                  "type": "integer",
+                  "description": "The limit",
+                  "required": true,
+                  "constraints": [
+                     {
+                        "greater_than": 0
+                     }
+                  ]
+               },
+               "time_range": {
+                  "type": "tosca.datatypes.TimeInterval",
+                  "description": "An optional range of time during the day the frequency is valid for.",
+                  "required": false
+               },
+               "controlLoopName": {
+                  "type": "string",
+                  "description": "An optional specific control loop to apply this guard to.",
+                  "required": false
+               },
+               "target": {
+                  "type": "string",
+                  "description": "An optional specific VNF to apply this guard to.",
+                  "required": false
+               }
+            }
+         }
+      }
+   ]
+}
\ No newline at end of file