2  * ============LICENSE_START=======================================================
 
   3  * ONAP Policy Decision Models
 
   4  * ================================================================================
 
   5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.xacml.pdp.application.monitoring;
 
  23 import com.att.research.xacml.std.annotations.XACMLAction;
 
  24 import com.att.research.xacml.std.annotations.XACMLRequest;
 
  25 import com.att.research.xacml.std.annotations.XACMLResource;
 
  26 import com.att.research.xacml.std.annotations.XACMLSubject;
 
  29 import java.util.Map.Entry;
 
  31 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 
  33 @XACMLRequest(ReturnPolicyIdList = true)
 
  34 public class MonitoringRequest {
 
  36     @XACMLSubject(includeInResults = true)
 
  37     String onapName = "DCAE";
 
  39     @XACMLResource(includeInResults = true)
 
  40     String resource = "onap.policies.Monitoring";
 
  43     String action = "configure";
 
  47      * Parses the DecisionRequest into a MonitoringRequest.
 
  49      * @param decisionRequest Input DecisionRequest
 
  50      * @return MonitoringRequest
 
  52     public static MonitoringRequest createInstance(DecisionRequest decisionRequest) {
 
  53         MonitoringRequest request = new MonitoringRequest();
 
  54         request.onapName = decisionRequest.getOnapName();
 
  55         request.action = decisionRequest.getAction();
 
  57         Map<String, Object> resources = decisionRequest.getResource();
 
  58         for (Entry<String, Object> entry : resources.entrySet()) {
 
  59             if ("policy-id".equals(entry.getKey())) {
 
  61                 // TODO handle lists of policies
 
  63                 request.resource = entry.getValue().toString();
 
  66             if ("policy-type".equals(entry.getKey())) {
 
  68                 // TODO handle lists of policies
 
  70                 request.resource = entry.getValue().toString();
 
  74         // TODO handle a bad incoming request. Do that here?