From: seanbeirne Date: Tue, 22 Jul 2025 16:04:07 +0000 (+0100) Subject: Include ProvMnS interface on DMI-Stub X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0d05ec0fbc64ddc08d5eac3e37a7c201323ecede;p=cps%2Fncmp-dmi-plugin.git Include ProvMnS interface on DMI-Stub Issue-ID: CPS-2737 Change-Id: Ibf873bcbb7f0e47aeec0e528051910a6e7da7278 Signed-off-by: seanbeirne --- diff --git a/dmi-stub/.openapi-generator-ignore-provmns b/dmi-stub/.openapi-generator-ignore-provmns new file mode 100644 index 00000000..b69e17bd --- /dev/null +++ b/dmi-stub/.openapi-generator-ignore-provmns @@ -0,0 +1,16 @@ +# Ignore generation of all the models for ProvMns +target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/*.java + +# Allow generation of the below model for ProvMns +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdPatchDefaultResponse.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefault.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefaultOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGet.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGetOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatch.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatchOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchItem.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchOperation.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ResourceOneOf.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/Scope.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ScopeType.java \ No newline at end of file diff --git a/dmi-stub/dmi-stub-app/.openapi-generator-ignore-provmns b/dmi-stub/dmi-stub-app/.openapi-generator-ignore-provmns new file mode 100644 index 00000000..b69e17bd --- /dev/null +++ b/dmi-stub/dmi-stub-app/.openapi-generator-ignore-provmns @@ -0,0 +1,16 @@ +# Ignore generation of all the models for ProvMns +target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/*.java + +# Allow generation of the below model for ProvMns +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdPatchDefaultResponse.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefault.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefaultOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGet.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGetOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatch.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatchOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchItem.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchOperation.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ResourceOneOf.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/Scope.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ScopeType.java \ No newline at end of file diff --git a/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java b/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java new file mode 100644 index 00000000..56d10740 --- /dev/null +++ b/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2025 OpenInfra Foundation Europe + * ================================================================================ + * 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.cps.ncmp.dmi.provmns.model; + +import lombok.Getter; +import lombok.Setter; + +/** + * This class serves as a replacement for the generated ClassNameIdGetDataNodeSelector class which contains dependencies + * that cause code generation issues. + */ +@Getter +@Setter +public class ClassNameIdGetDataNodeSelectorParameter { + + private String dataNodeSelector; + +} diff --git a/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java b/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java new file mode 100644 index 00000000..470c7aeb --- /dev/null +++ b/dmi-stub/dmi-stub-app/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java @@ -0,0 +1,32 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2025 OpenInfra Foundation Europe + * ================================================================================ + * 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.cps.ncmp.dmi.provmns.model; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +/** + * This interface serves as a replacement for the generated Resource class, which has dependencies on the NRM-related + * models that we want to avoid for our implementation of Provisioning and Management Services (ProvMnS) API. + */ +@JsonSerialize(as = ResourceOneOf.class) +@JsonDeserialize(as = ResourceOneOf.class) +public interface Resource { } diff --git a/dmi-stub/dmi-stub-service/.openapi-generator-ignore-provmns b/dmi-stub/dmi-stub-service/.openapi-generator-ignore-provmns new file mode 100644 index 00000000..b69e17bd --- /dev/null +++ b/dmi-stub/dmi-stub-service/.openapi-generator-ignore-provmns @@ -0,0 +1,16 @@ +# Ignore generation of all the models for ProvMns +target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/*.java + +# Allow generation of the below model for ProvMns +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdPatchDefaultResponse.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefault.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefaultOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGet.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGetOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatch.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatchOtherProblemsInner.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchItem.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchOperation.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ResourceOneOf.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/Scope.java +!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ScopeType.java \ No newline at end of file diff --git a/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java new file mode 100644 index 00000000..56d10740 --- /dev/null +++ b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2025 OpenInfra Foundation Europe + * ================================================================================ + * 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.cps.ncmp.dmi.provmns.model; + +import lombok.Getter; +import lombok.Setter; + +/** + * This class serves as a replacement for the generated ClassNameIdGetDataNodeSelector class which contains dependencies + * that cause code generation issues. + */ +@Getter +@Setter +public class ClassNameIdGetDataNodeSelectorParameter { + + private String dataNodeSelector; + +} diff --git a/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java new file mode 100644 index 00000000..470c7aeb --- /dev/null +++ b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java @@ -0,0 +1,32 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2025 OpenInfra Foundation Europe + * ================================================================================ + * 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.cps.ncmp.dmi.provmns.model; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +/** + * This interface serves as a replacement for the generated Resource class, which has dependencies on the NRM-related + * models that we want to avoid for our implementation of Provisioning and Management Services (ProvMnS) API. + */ +@JsonSerialize(as = ResourceOneOf.class) +@JsonDeserialize(as = ResourceOneOf.class) +public interface Resource { } diff --git a/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/ProvMnsStubController.java b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/ProvMnsStubController.java new file mode 100644 index 00000000..a0380052 --- /dev/null +++ b/dmi-stub/dmi-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/ProvMnsStubController.java @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2025 OpenInfra Foundation Europe + * ================================================================================ + * 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.cps.ncmp.dmi.rest.stub.controller; + +import java.util.List; +import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter; +import org.onap.cps.ncmp.dmi.provmns.model.Resource; +import org.onap.cps.ncmp.dmi.provmns.model.ResourceOneOf; +import org.onap.cps.ncmp.dmi.provmns.model.Scope; +import org.onap.cps.ncmp.dmi.provmns.rest.api.DefaultApi; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +public class ProvMnsStubController implements DefaultApi { + + /** + * Replaces a complete single resource or creates it if it does not exist. + * + * @param className Class name of the targeted resource + * @param id Identifier of the targeted resource + * @param resource Resource representation of the resource to be created or replaced + * @return {@code ResponseEntity} The representation of the updated resource is returned in the response + * message body. + */ + @Override + public ResponseEntity classNameidPut(final String className, final String id, final Resource resource) { + return new ResponseEntity<>(resource, HttpStatus.OK); + } + + /** + * Reads one or multiple resources. + * + * @param className Class name of the targeted resource + * @param id Identifier of the targeted resource + * @param scope Extends the set of targeted resources beyond the base + * resource identified with the authority and path component of + * the URI. + * @param filter Reduces the targeted set of resources by applying a filter to + * the scoped set of resource representations. Only resources + * representations for which the filter construct evaluates to + * "true" are targeted. + * @param attributes Attributes of the scoped resources to be returned. The + * value is a comma-separated list of attribute names. + * @param fields Attribute fields of the scoped resources to be returned. The + * value is a comma-separated list of JSON pointers to the + * attribute fields. + * @param dataNodeSelector dataNodeSelector object + * @return {@code ResponseEntity} The resources identified in the request for retrieval are returned + * in the response message body. + */ + @Override + public ResponseEntity classNameidGet(final String className, final String id, final Scope scope, + final String filter, final List attributes, + final List fields, + final ClassNameIdGetDataNodeSelectorParameter dataNodeSelector) { + return new ResponseEntity<>(new ResourceOneOf("exampleResourceId"), HttpStatus.OK); + } + + /** + * Patches (Create, Update or Delete) one or multiple resources. + * + * @param className Class name of the targeted resource + * @param id Identifier of the targeted resource + * @param resource Resource representation of the resource to be created or replaced + * @return {@code ResponseEntity} The updated resource representations are returned in the response message body. + */ + @Override + public ResponseEntity classNameidPatch(final String className, final String id, final Resource resource) { + return new ResponseEntity<>(resource, HttpStatus.OK); + } + + /** + * Delete one or multiple resources. + * + * @param className Class name of the targeted resource + * @param id Identifier of the targeted resource + * @return {@code ResponseEntity} The response body is empty, HTTP status returned. + */ + @Override + public ResponseEntity classNameidDelete(final String className, final String id) { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/dmi-stub/dmi-stub-service/src/main/resources/application.yml b/dmi-stub/dmi-stub-service/src/main/resources/application.yml index f67d3546..e8a15ec1 100644 --- a/dmi-stub/dmi-stub-service/src/main/resources/application.yml +++ b/dmi-stub/dmi-stub-service/src/main/resources/application.yml @@ -21,6 +21,7 @@ server: rest: api: dmi-stub-base-path: /dmi + provmns-base-path: /ProvMnS spring: main: diff --git a/dmi-stub/pom.xml b/dmi-stub/pom.xml index 8bccd391..8053467a 100644 --- a/dmi-stub/pom.xml +++ b/dmi-stub/pom.xml @@ -83,6 +83,34 @@ + + dmi-code-gen-provmns + + generate + + + https://forge.3gpp.org/rep/all/5G_APIs/-/raw/REL-18/TS28532_ProvMnS.yaml + org.onap.cps.ncmp.dmi.rest.stub.provmns.controller + org.onap.cps.ncmp.dmi.provmns.model + org.onap.cps.ncmp.dmi.provmns.rest.api + spring + false + + src/gen/java + java11 + true + true + true + false + true + + + Resource=org.onap.cps.ncmp.dmi.provmns.model.Resource + ClassNameIdGetDataNodeSelectorParameter=org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter + + ${project.basedir}/.openapi-generator-ignore-provmns + +