2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
4 * Modifications Copyright (C) 2021 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.pdp.concepts;
24 import java.util.ArrayList;
25 import java.util.List;
27 import lombok.NoArgsConstructor;
28 import lombok.NonNull;
29 import org.onap.policy.common.parameters.BeanValidationResult;
30 import org.onap.policy.common.parameters.ValidationResult;
31 import org.onap.policy.models.base.PfUtils;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
35 * A deployment (i.e., set of policies) for all PDPs of the same pdp type running within a
40 public class DeploymentSubGroup {
43 POST, // all listed policies are to be added
44 DELETE, // all listed policies are to be deleted
45 PATCH // update the deployment so that the policies match exactly
48 private String pdpType;
49 private Action action;
50 private List<ToscaConceptIdentifier> policies;
53 * Constructs the object, making a deep copy from the source.
55 * @param source source from which to copy fields
57 public DeploymentSubGroup(@NonNull final DeploymentSubGroup source) {
58 this.pdpType = source.pdpType;
59 this.action = source.action;
60 this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0));
64 * Validates that appropriate fields are populated for an incoming call to the PAP
67 * @return the validation result
69 public ValidationResult validatePapRest() {
70 var result = new BeanValidationResult("group", this);
72 result.validateNotNull("pdpType", pdpType);
73 result.validateNotNull("action", action);
74 result.validateNotNullList("policies", policies, ToscaConceptIdentifier::validatePapRest);