diff options
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/main')
5 files changed, 188 insertions, 108 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java index eaf94552b..329921f34 100644..100755 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java @@ -42,6 +42,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -269,7 +270,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio } /** - * Get Data List. + * Get Instance Data List. * * @return the InternalDatas */ @@ -343,4 +344,32 @@ public class AutomationCompositionElementHandler implements AutomationCompositio unlock(automationCompositionId, element.getId()); } } + + /** + * Get Composition Data List. + * + * @return the InternalDatas + */ + public InternalDatas getCompositionDataList() { + var acElementsDefinitions = intermediaryApi.getAcElementsDefinitions(); + var internalDatas = new InternalDatas(); + for (var entry : acElementsDefinitions.entrySet()) { + for (var acElementsDefinition : entry.getValue().values()) { + var internalData = new InternalData(); + internalData.setCompositionId(entry.getKey()); + internalData.setCompositionDefinitionElementId(acElementsDefinition.getAcElementDefinitionId()); + internalData.setIntProperties( + acElementsDefinition.getAutomationCompositionElementToscaNodeTemplate().getProperties()); + internalData.setOutProperties(acElementsDefinition.getOutProperties()); + internalDatas.getList().add(internalData); + } + } + return internalDatas; + } + + public void setCompositionOutProperties(UUID compositionId, ToscaConceptIdentifier compositionDefinitionElementId, + Map<String, Object> outProperties) { + intermediaryApi.sendAcDefinitionInfo(compositionId, compositionDefinitionElementId, outProperties); + + } } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java index 14e53338d..5e40bf190 100644..100755 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java @@ -24,13 +24,16 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.UUID; import lombok.Data; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Data public class InternalData { - Map<String, Object> intProperties = new LinkedHashMap<>(); - Map<String, Object> outProperties = new LinkedHashMap<>(); - UUID automationCompositionId; - UUID automationCompositionElementId; - String useState; - String operationalState; + private Map<String, Object> intProperties = new LinkedHashMap<>(); + private Map<String, Object> outProperties = new LinkedHashMap<>(); + private UUID compositionId; + private ToscaConceptIdentifier compositionDefinitionElementId; + private UUID automationCompositionId; + private UUID automationCompositionElementId; + private String useState; + private String operationalState; } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java index ca7844657..f4c288d5d 100644..100755 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java @@ -27,5 +27,5 @@ import lombok.Data; @Data public class InternalDatas { - List<InternalData> list = new ArrayList<>(); + private List<InternalData> list = new ArrayList<>(); } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java index a12e5f70d..db828414d 100644..100755 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java @@ -65,7 +65,7 @@ public class SimulatorController implements SimulatorParticipantControllerApi { } /** - * Set Data. + * Set instance Data. * * @param body the Data * @return Void @@ -77,4 +77,16 @@ public class SimulatorController implements SimulatorParticipantControllerApi { body.getOutProperties()); return new ResponseEntity<>(HttpStatus.OK); } + + @Override + public ResponseEntity<InternalDatas> getCompositionDatas(UUID xonapRequestId) { + return new ResponseEntity<>(automationCompositionElementHandler.getCompositionDataList(), HttpStatus.OK); + } + + @Override + public ResponseEntity<Void> setCompositionData(UUID xonapRequestId, @Valid InternalData body) { + automationCompositionElementHandler.setCompositionOutProperties(body.getCompositionId(), + body.getCompositionDefinitionElementId(), body.getOutProperties()); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml index b95aa33cd..c3b02e412 100644..100755 --- a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml +++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml @@ -1,3 +1,20 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= openapi: 3.0.3 info: title: ACM Simulator Participant @@ -45,30 +62,14 @@ paths: description: OK, reutrns a serialised instance of [SimConfig](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java) headers: - api-version: - schema: - type: string X-LatestVersion: - schema: - type: string - description: Used only to communicate an API's latest version + $ref: '#/components/headers/X-LatestVersion' X-PatchVersion: - schema: - type: string - description: - Used only to communicate a PATCH version in a response for troubleshooting purposes only, - and will not be provided by the client on request + $ref: '#/components/headers/X-PatchVersion' X-MinorVersion: - schema: - type: string - description: - Used to request or communicate a MINOR version back from the client - to the server, and from the server back to the client + $ref: '#/components/headers/X-MinorVersion' X-onap-RequestId: - schema: - type: string - format: uuid - description: Used to track REST transactions for logging purposes + $ref: '#/components/headers/X-onap-RequestId' content: application/json: schema: @@ -111,30 +112,14 @@ paths: 200: description: OK, the parameters has been saved headers: - api-version: - schema: - type: string X-LatestVersion: - schema: - type: string - description: Used only to communicate an API's latest version + $ref: '#/components/headers/X-LatestVersion' X-PatchVersion: - schema: - type: string - description: - Used only to communicate a PATCH version in a response for troubleshooting purposes only, - and will not be provided by the client on request + $ref: '#/components/headers/X-PatchVersion' X-MinorVersion: - schema: - type: string - description: - Used to request or communicate a MINOR version back from the client - to the server, and from the server back to the client + $ref: '#/components/headers/X-MinorVersion' X-onap-RequestId: - schema: - type: string - format: uuid - description: Used to track REST transactions for logging purposes + $ref: '#/components/headers/X-onap-RequestId' 400: description: Bad Request 401: @@ -164,30 +149,14 @@ paths: [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java) containing a list of automation composition instances found headers: - api-version: - schema: - type: string X-LatestVersion: - schema: - type: string - description: Used only to communicate an API's latest version + $ref: '#/components/headers/X-LatestVersion' X-PatchVersion: - schema: - type: string - description: - Used only to communicate a PATCH version in a response for troubleshooting purposes only, - and will not be provided by the client on request + $ref: '#/components/headers/X-PatchVersion' X-MinorVersion: - schema: - type: string - description: - Used to request or communicate a MINOR version back from the client - to the server, and from the server back to the client + $ref: '#/components/headers/X-MinorVersion' X-onap-RequestId: - schema: - type: string - format: uuid - description: Used to track REST transactions for logging purposes + $ref: '#/components/headers/X-onap-RequestId' content: application/json: schema: @@ -220,30 +189,14 @@ paths: description: Serialised instance of [InternalDatas](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java) headers: - api-version: - schema: - type: string X-LatestVersion: - schema: - type: string - description: Used only to communicate an API's latest version + $ref: '#/components/headers/X-LatestVersion' X-PatchVersion: - schema: - type: string - description: - Used only to communicate a PATCH version in a response for troubleshooting purposes only, - and will not be provided by the client on request + $ref: '#/components/headers/X-PatchVersion' X-MinorVersion: - schema: - type: string - description: - Used to request or communicate a MINOR version back from the client - to the server, and from the server back to the client + $ref: '#/components/headers/X-MinorVersion' X-onap-RequestId: - schema: - type: string - format: uuid - description: Used to track REST transactions for logging purposes + $ref: '#/components/headers/X-onap-RequestId' content: application/json: schema: @@ -286,30 +239,99 @@ paths: 200: description: OK, the data has been saved headers: - api-version: - schema: - type: string X-LatestVersion: - schema: - type: string - description: Used only to communicate an API's latest version + $ref: '#/components/headers/X-LatestVersion' X-PatchVersion: - schema: - type: string - description: - Used only to communicate a PATCH version in a response for troubleshooting purposes only, - and will not be provided by the client on request + $ref: '#/components/headers/X-PatchVersion' X-MinorVersion: - schema: - type: string - description: - Used to request or communicate a MINOR version back from the client - to the server, and from the server back to the client + $ref: '#/components/headers/X-MinorVersion' X-onap-RequestId: + $ref: '#/components/headers/X-onap-RequestId' + 400: + description: Bad Request + 401: + description: Authorization Error + 500: + description: Internal Server Error + security: + - basicAuth: [] + /compositiondatas: + get: + tags: + - Simulator-participant-controller + summary: Query details of the requested internal composition datas + description: Query details of the requested internal composition datas + operationId: getCompositionDatas + parameters: + - name: X-onap-RequestId + in: header + description: RequestID for http transaction + schema: + type: string + format: uuid + responses: + 200: + description: Serialised instance of + [InternalDatas](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java) + headers: + X-LatestVersion: + $ref: '#/components/headers/X-LatestVersion' + X-PatchVersion: + $ref: '#/components/headers/X-PatchVersion' + X-MinorVersion: + $ref: '#/components/headers/X-MinorVersion' + X-onap-RequestId: + $ref: '#/components/headers/X-onap-RequestId' + content: + application/json: + schema: + $ref: '#/components/schemas/InternalDatas' + application/yaml: schema: - type: string - format: uuid - description: Used to track REST transactions for logging purposes + $ref: '#/components/schemas/InternalDatas' + 401: + description: Authorization Error + 500: + description: Internal Server Error + security: + - basicAuth: [] + put: + tags: + - Simulator-participant-controller + summary: change the parameters + description: >- + Change the data of the Simulator Participant + operationId: setCompositionData + parameters: + - name: X-ONAP-RequestID + in: header + description: RequestID for http transaction + required: false + schema: + type: string + format: uuid + requestBody: + description: The data in a serialised instance of + [InternalData](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java) + content: + application/json: + schema: + $ref: '#/components/schemas/InternalData' + application/yaml: + schema: + $ref: '#/components/schemas/InternalData' + responses: + 200: + description: OK, the data has been saved + headers: + X-LatestVersion: + $ref: '#/components/headers/X-LatestVersion' + X-PatchVersion: + $ref: '#/components/headers/X-PatchVersion' + X-MinorVersion: + $ref: '#/components/headers/X-MinorVersion' + X-onap-RequestId: + $ref: '#/components/headers/X-onap-RequestId' 400: description: Bad Request 401: @@ -337,3 +359,17 @@ components: InternalData: title: InternalData type: object + headers: + X-LatestVersion: + schema: + type: string + X-PatchVersion: + schema: + type: string + X-MinorVersion: + schema: + type: string + X-onap-RequestId: + schema: + type: string + format: uuid |