diff options
author | Jim Hahn <jrh3@att.com> | 2019-03-21 09:54:30 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-03-22 12:19:37 -0400 |
commit | a4b62b8f4da98eefe530e0fc11f6dafabe0019c2 (patch) | |
tree | 96f6acb9c49b9e4aa0d3c33dc805cf37b264f659 /models-pdp/src | |
parent | 834851e6c460ef8a28f356a64fe7b85d8bbf9a55 (diff) |
Add models-pdp to models repo
Also changed supportedPolicyTypes to PfConceptKey.
Updated licenses.
Removed trailing whitespace from pom.
Provide default request id.
Rebased to fix merge conflict.
Added SupportedPolicyType class.
Renamed SupportedPolicyType to PolicyTypeIdent, and moved it to
models-base. Also updated models-pap to use it.
Deleted models-pdp Policy and replaced it with ToscaPolicy.
Updated test method name.
Change-Id: Id65f769c2f308c6b56e79978bd50b84f2e0b3d02
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src')
12 files changed, 614 insertions, 0 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java new file mode 100644 index 000000000..b82af0225 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; + +/** + * Class to represent the PDP_HEALTH_CHECK message that PAP will send to either PDPGroup/Subgroup or a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpHealthCheck extends PdpMessage { + + private String name; + private String pdpGroup; + private String pdpSubgroup; + + /** + * Constructor for instantiating PdpHealthCheck class with message name. + * + */ + public PdpHealthCheck() { + super(PdpMessageType.PDP_HEALTH_CHECK); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java new file mode 100644 index 000000000..6160027ed --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.UUID; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; + +/** + * Class to represent the base class for various messages that will ve exchanged between PAP and PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpMessage { + + @Setter(AccessLevel.NONE) + private PdpMessageType messageName; + + private String requestId = UUID.randomUUID().toString(); + + /** + * Time-stamp, in milliseconds, when the message was created. Defaults to the current + * time. + */ + private long timestampMs = System.currentTimeMillis(); + + /** + * Constructor for instantiating PdpMessage class with message name. + * + * @param messageName the message name + */ + public PdpMessage(final PdpMessageType messageName) { + this.messageName = messageName; + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java new file mode 100644 index 000000000..c28d01a3e --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpResponseStatus; + +/** + * Class to represent PDP response details. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpResponseDetails { + + // The responseTo field should match the original request id in the request. + private String responseTo; + private PdpResponseStatus responseStatus; + private String responseMessage; +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java new file mode 100644 index 000000000..bca162e91 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * Class to represent the PDP_STATE_CHANGE message that PAP will send to either PDPGroup/Subgroup or a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStateChange extends PdpMessage { + + private String name; + private PdpState state; + private String pdpGroup; + private String pdpSubgroup; + + /** + * Constructor for instantiating PdpStateChange class with message name. + * + */ + public PdpStateChange() { + super(PdpMessageType.PDP_STATE_CHANGE); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java new file mode 100644 index 000000000..6f9b9c9d6 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent statistics of a running PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStatistics { + + private long policyDownloadCount; + private long policyDownloadSuccessCount; + private long policyDownloadFailCount; + private long policyExecutedCount; + private long policyExecutedSuccessCount; + private long policyExecutedFailCount; +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java new file mode 100644 index 000000000..f7b911fc4 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.base.keys.PolicyTypeIdent; +import org.onap.policy.models.pdp.enums.PdpHealthStatus; +import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.pdp.enums.PdpState; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; + +/** + * Class to represent the PDP_STATUS message that all the PDP's will send to PAP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStatus extends PdpMessage { + + private String name; + private String version; + private String pdpType; + private PdpState state; + private PdpHealthStatus healthy; + private String description; + private String pdpGroup; + private String pdpSubgroup; + private List<PolicyTypeIdent> supportedPolicyTypes; + private List<ToscaPolicy> policies; + private String instance; + private String deploymentInstanceInfo; + private String properties; + private PdpStatistics statistics; + private PdpResponseDetails response; + + /** + * Constructor for instantiating PdpStatus class with message name. + * + */ + public PdpStatus() { + super(PdpMessageType.PDP_STATUS); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java new file mode 100644 index 000000000..a048cde48 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.List; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; + +/** + * Class to represent the PDP_UPDATE message that PAP will send to a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpUpdate extends PdpMessage { + + private String name; + private String pdpType; + private String description; + private String pdpGroup; + private String pdpSubgroup; + private List<ToscaPolicy> policies; + + /** + * Constructor for instantiating PdpUpdate class with message name. + * + */ + public PdpUpdate() { + super(PdpMessageType.PDP_UPDATE); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java new file mode 100644 index 000000000..7d31c3344 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for health status of PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpHealthStatus { + + /** + * PDP is healthy and working fine. + */ + HEALTHY, + + /** + * PDP is not healthy. + */ + NOT_HEALTHY, + + /** + * PDP is currently under test state and performing tests. + */ + TEST_IN_PROGRESS, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java new file mode 100644 index 000000000..7ba4ad73e --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for the type of PDP messages. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpMessageType { + + /** + * Used by PDPs to report status to PAP. + */ + PDP_STATUS, + + /** + * Used by PAP to update the policies running on PDPs, triggers a PDP_STATUS message with the result of the + * PDP_UPDATE operation. + */ + PDP_UPDATE, + + /** + * Used by PAP to change the state of PDPs, triggers a PDP_STATUS message with the result of the PDP_STATE_CHANGE + * operation. + */ + PDP_STATE_CHANGE, + + /** + * Used by PAP to order a health check on PDPs, triggers a PDP_STATUS message with the result of the + * PDP_HEALTH_CHECK operation. + */ + PDP_HEALTH_CHECK, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java new file mode 100644 index 000000000..e6b94f446 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for PDP response status. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpResponseStatus { + + /** + * PDP operation was successful. + */ + SUCCESS, + + /** + * PDP operation failed. + */ + FAIL, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java new file mode 100644 index 000000000..a1b96ac17 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for state of PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpState { + + /** + * Policy execution is always rejected irrespective of PDP type. + */ + PASSIVE, + + /** + * Policy execution proceeds, but changes to domain state or context are not carried out. The PDP returns an + * indication that it is running in SAFE mode together with the action it would have performed if it was operating + * in ACTIVE mode. + */ + SAFE, + + /** + * Policy execution proceeds and changes to domain and state are carried out in a test environment. The PDP returns + * an indication that it is running in TEST mode together with the action it has performed on the test environment. + */ + TEST, + + /** + * Policy execution is executed in the live environment by the PDP. + */ + ACTIVE, + + /** + * Policy execution is terminated and not available. + */ + TERMINATED +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java new file mode 100644 index 000000000..39aee6f48 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +import org.junit.Test; +import org.onap.policy.common.utils.validation.ToStringTester; + +/** + * Class to perform unit testing of models. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class TestModels { + + @Test + public void testPapModels() { + final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) + .with(new GetterTester()).build(); + validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo()); + } +} |