summaryrefslogtreecommitdiffstats
path: root/models-pap/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-pap/src/main')
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifier.java62
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java37
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java14
3 files changed, 96 insertions, 17 deletions
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifier.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifier.java
new file mode 100644
index 000000000..7bd78a222
--- /dev/null
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifier.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Models
+ * ================================================================================
+ * Copyright (C) 2021 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.onap.policy.models.pap.concepts;
+
+import com.google.gson.annotations.SerializedName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.NonNull;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
+
+/**
+ * Policy identifier with an optional version; only the "name" is required.
+ *
+ * <p>Note that there are deliberately no setters or getters on this class, it is use purely for GSON serialization and
+ * deserializaiton
+ */
+public class PapPolicyIdentifier {
+ @NonNull
+ @ApiModelProperty(name = "policy-id")
+ @SerializedName("policy-id")
+ private String name;
+
+ @ApiModelProperty(name = "policy-version")
+ @SerializedName("policy-version")
+ private String version;
+
+ public PapPolicyIdentifier(final String name, final String version) {
+ this.name = name;
+ this.version = version;
+ }
+
+ public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifier identifier) {
+ this(identifier.getName(), identifier.getVersion());
+ }
+
+ public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifierOptVersion identifier) {
+ this(identifier.getName(), identifier.getVersion());
+ }
+
+ public ToscaConceptIdentifierOptVersion getGenericIdentifier() {
+ return name == null ? new ToscaConceptIdentifierOptVersion()
+ : new ToscaConceptIdentifierOptVersion(name, version);
+ }
+}
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java
index 7bc8892f2..6ab41ddf8 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java
@@ -1,8 +1,9 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,19 +22,35 @@
package org.onap.policy.models.pap.concepts;
import java.util.List;
-import lombok.Getter;
-import lombok.Setter;
+import java.util.stream.Collectors;
import lombok.ToString;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
/**
- * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment
- * REST API. Only the "name" and "version" fields of a Policy are used, and only the
- * "name" field is actually required.
+ * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment REST API. Only the "name" and
+ * "version" fields of a Policy are used, and only the "name" field is actually required.
*/
-@Getter
-@Setter
@ToString
public class PdpDeployPolicies {
- private List<ToscaPolicyIdentifierOptVersion> policies;
+ private List<PapPolicyIdentifier> policies;
+
+ /**
+ * Get the identifiers of the policies on the list.
+ *
+ * @return The list of identifiers
+ */
+ public List<ToscaConceptIdentifierOptVersion> getPolicies() {
+ return policies == null ? null
+ : policies.stream().map(PapPolicyIdentifier::getGenericIdentifier).collect(Collectors.toList());
+ }
+
+ /**
+ * Set the identifiers of the policies on the list.
+ *
+ * @param policies The list of identifiers
+ */
+ public void setPolicies(final List<ToscaConceptIdentifierOptVersion> policies) {
+ this.policies =
+ policies == null ? null : policies.stream().map(PapPolicyIdentifier::new).collect(Collectors.toList());
+ }
}
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java
index 427f168ea..b05af9204 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyStatus.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +22,7 @@ package org.onap.policy.models.pap.concepts;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Data
@NoArgsConstructor
@@ -66,18 +66,18 @@ public class PolicyStatus {
* @param policy policy identifier, from which the name and version are to be
* extracted
*/
- public PolicyStatus(ToscaPolicyTypeIdentifier policyType, ToscaPolicyIdentifier policy) {
+ public PolicyStatus(ToscaConceptIdentifier policyType, ToscaConceptIdentifier policy) {
this.policyTypeId = policyType.getName();
this.policyTypeVersion = policyType.getVersion();
this.policyId = policy.getName();
this.policyVersion = policy.getVersion();
}
- public ToscaPolicyTypeIdentifier getPolicyType() {
- return new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion);
+ public ToscaConceptIdentifier getPolicyType() {
+ return new ToscaConceptIdentifier(policyTypeId, policyTypeVersion);
}
- public ToscaPolicyIdentifier getPolicy() {
- return new ToscaPolicyIdentifier(policyId, policyVersion);
+ public ToscaConceptIdentifier getPolicy() {
+ return new ToscaConceptIdentifier(policyId, policyVersion);
}
}