<goal>generate</goal>
</goals>
<configuration>
- <inputSpec>https://forge.3gpp.org/rep/all/5G_APIs/-/raw/REL-18/TS28532_ProvMnS.yaml</inputSpec>
+ <inputSpec>https://forge.3gpp.org/rep/sa5/MnS/-/raw/Rel-18/OpenAPI/TS28532_ProvMnS.yaml</inputSpec>
<invokerPackage>org.onap.cps.ncmp.dmi.provmns.rest.controller</invokerPackage>
<modelPackage>org.onap.cps.ncmp.dmi.provmns.model</modelPackage>
<apiPackage>org.onap.cps.ncmp.dmi.provmns.api</apiPackage>
import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdPatchDefaultResponse;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseDefault;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseGet;
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem;
import org.onap.cps.ncmp.dmi.provmns.model.Resource;
import org.onap.cps.ncmp.dmi.provmns.model.Scope;
import org.springframework.http.ResponseEntity;
* and the patch document included in the request message body.
*
* @param httpServletRequest (required)
- * @param resource The request body describes changes to be made to the target resources.
+ * @param patchItems The request body describes changes to be made to the target resources.
* The following patch media types are available
* - "application/json-patch+json" (RFC 6902)
* - "application/3gpp-json-patch+json" (TS 32.158) (required)
@PatchMapping(
value = "v1/**",
produces = { "application/json" },
- consumes = {"application/json-patch+json", "application/3gpp-json-patch+json" }
+ consumes = { "application/json-patch+json", "application/3gpp-json-patch+json" }
)
- ResponseEntity<Resource> patchMoi(
+ ResponseEntity<Object> patchMoi(
HttpServletRequest httpServletRequest,
@Parameter(name = "Resource", description = "The request body describes changes to be made to the target "
+ "resources. The following patch media types are available "
+ "- \"application/json-patch+json\" (RFC 6902) "
+ "- \"application/3gpp-json-patch+json\" (TS 32.158)", required = true) @Valid @RequestBody
- Resource resource
+ List<PatchItem> patchItems
);
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter;
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem;
import org.onap.cps.ncmp.dmi.provmns.model.Resource;
import org.onap.cps.ncmp.dmi.provmns.model.Scope;
import org.springframework.http.HttpStatus;
}
@Override
- public ResponseEntity<Resource> patchMoi(final HttpServletRequest httpServletRequest, final Resource resource) {
+ public ResponseEntity<Object> patchMoi(final HttpServletRequest httpServletRequest,
+ final List<PatchItem> patchItems) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.dmi.config.WebSecurityConfig
import org.onap.cps.ncmp.dmi.provmns.api.ProvMnsController
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem
+import org.onap.cps.ncmp.dmi.provmns.model.PatchOperation
import org.onap.cps.ncmp.dmi.provmns.model.ResourceOneOf
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
given: 'resource data url'
def patchUrl = "$provMnSBasePath/v1/test=another"
and: 'an example resource json object'
- def jsonBody = objectMapper.writeValueAsString((new ResourceOneOf('test')))
+ def jsonBody = objectMapper.writeValueAsString(([new PatchItem(PatchOperation.ADD, "someType")]))
when: 'patch data resource request is performed'
def response = mvc.perform(patch(patchUrl)
.contentType(new MediaType('application', 'json-patch+json'))
import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdPatchDefaultResponse;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseDefault;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseGet;
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem;
import org.onap.cps.ncmp.dmi.provmns.model.Resource;
import org.onap.cps.ncmp.dmi.provmns.model.Scope;
import org.springframework.http.ResponseEntity;
* and the patch document included in the request message body.
*
* @param httpServletRequest (required)
- * @param resource The request body describes changes to be made to the target resources.
+ * @param patchItems The request body describes changes to be made to the target resources.
* The following patch media types are available
* - "application/json-patch+json" (RFC 6902)
* - "application/3gpp-json-patch+json" (TS 32.158) (required)
@PatchMapping(
value = "v1/**",
produces = { "application/json" },
- consumes = {"application/json-patch+json", "application/3gpp-json-patch+json" }
+ consumes = { "application/json-patch+json", "application/3gpp-json-patch+json" }
)
- ResponseEntity<Resource> patchMoi(
+ ResponseEntity<Object> patchMoi(
HttpServletRequest httpServletRequest,
@Parameter(name = "Resource", description = "The request body describes changes to be made to the target "
+ "resources. The following patch media types are available "
+ "- \"application/json-patch+json\" (RFC 6902) "
+ "- \"application/3gpp-json-patch+json\" (TS 32.158)", required = true) @Valid @RequestBody
- Resource resource
+ List<PatchItem> patchItems
);
import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdPatchDefaultResponse;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseDefault;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseGet;
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem;
import org.onap.cps.ncmp.dmi.provmns.model.Resource;
import org.onap.cps.ncmp.dmi.provmns.model.Scope;
import org.springframework.http.ResponseEntity;
* and the patch document included in the request message body.
*
* @param httpServletRequest (required)
- * @param resource The request body describes changes to be made to the target resources.
+ * @param patchItems The request body describes changes to be made to the target resources.
* The following patch media types are available
* - "application/json-patch+json" (RFC 6902)
* - "application/3gpp-json-patch+json" (TS 32.158) (required)
@PatchMapping(
value = "v1/**",
produces = { "application/json" },
- consumes = {"application/json-patch+json", "application/3gpp-json-patch+json" }
+ consumes = { "application/json-patch+json", "application/3gpp-json-patch+json" }
)
ResponseEntity<Object> patchMoi(
+ "resources. The following patch media types are available "
+ "- \"application/json-patch+json\" (RFC 6902) "
+ "- \"application/3gpp-json-patch+json\" (TS 32.158)", required = true) @Valid @RequestBody
- Resource resource
+ List<PatchItem> patchItems
);
package org.onap.cps.ncmp.dmi.rest.stub.controller;
+import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.List;
import org.onap.cps.ncmp.dmi.provmns.api.ProvMnS;
import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter;
import org.onap.cps.ncmp.dmi.provmns.model.ErrorResponseDefault;
+import org.onap.cps.ncmp.dmi.provmns.model.PatchItem;
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;
static final Pattern PATTERN_SLOW_RESPONSE = Pattern.compile("slowResponse_(\\d{1,3})");
private final Sleeper sleeper;
+ private final ObjectMapper objectMapper;
static {
dummyResource.setObjectClass("dummyClass");
@Override
public ResponseEntity<Object> putMoi(final HttpServletRequest httpServletRequest, final Resource resource) {
log.info("putMoi: {}", resource);
+ final ResourceOneOf stubResource = new ResourceOneOf("Id set by Stub");
+ stubResource.setObjectClass("ObjectClass set by Stub");
+ stubResource.setObjectInstance("ObjectInstance set by Stub");
+ stubResource.setAttributes("Attribute set by Stub");
final Optional<ResponseEntity<Object>> optionalResponseEntity = simulate(httpServletRequest);
- return optionalResponseEntity.orElseGet(() -> new ResponseEntity<>(resource, HttpStatus.OK));
+ return optionalResponseEntity.orElseGet(() -> new ResponseEntity<>(stubResource, HttpStatus.OK));
}
/**
* Patches (Create, Update or Delete) one or multiple resources.
*
* @param httpServletRequest URI request including path
- * @param resource Resource representation of the resource to be created or replaced
+ * @param patchItems A list of items to be created, updated or replaced
* @return {@code ResponseEntity} The updated resource representations are returned in the response message body.
*/
@Override
- public ResponseEntity<Object> patchMoi(final HttpServletRequest httpServletRequest, final Resource resource) {
- log.info("patchMoi: {}", resource);
+ public ResponseEntity<Object> patchMoi(final HttpServletRequest httpServletRequest,
+ final List<PatchItem> patchItems) {
+ log.info("patchMoi: {}", patchItems);
final Optional<ResponseEntity<Object>> optionalResponseEntity = simulate(httpServletRequest);
- return optionalResponseEntity.orElseGet(() -> new ResponseEntity<>(resource, HttpStatus.OK));
+ return optionalResponseEntity.orElseGet(() -> new ResponseEntity<>(patchItems, HttpStatus.OK));
}
/**
<goal>generate</goal>
</goals>
<configuration>
- <inputSpec>https://forge.3gpp.org/rep/all/5G_APIs/-/raw/REL-18/TS28532_ProvMnS.yaml</inputSpec>
+ <inputSpec>https://forge.3gpp.org/rep/sa5/MnS/-/raw/Rel-18/OpenAPI/TS28532_ProvMnS.yaml</inputSpec>
<invokerPackage>org.onap.cps.ncmp.dmi.rest.stub.provmns.controller</invokerPackage>
<modelPackage>org.onap.cps.ncmp.dmi.provmns.model</modelPackage>
<apiPackage>org.onap.cps.ncmp.dmi.provmns.rest.api</apiPackage>