2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.job.command
23 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
24 import org.onap.vid.job.Job
25 import org.onap.vid.job.JobAdapter
26 import org.onap.vid.job.JobCommand
27 import org.onap.vid.model.serviceInstantiation.InstanceGroup
28 import org.onap.vid.mso.RestMsoImplementation
29 import org.onap.vid.services.AsyncInstantiationBusinessLogic
30 import org.springframework.beans.factory.annotation.Autowired
31 import org.springframework.beans.factory.config.ConfigurableBeanFactory
32 import org.springframework.context.annotation.Scope
33 import org.springframework.http.HttpMethod
34 import org.springframework.stereotype.Component
38 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
39 class InstanceGroupCommand @Autowired constructor(
40 private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
41 restMso: RestMsoImplementation,
42 msoResultHandlerService: MsoResultHandlerService,
43 inProgressStatusService:InProgressStatusService,
44 watchChildrenJobsBL: WatchChildrenJobsBL
45 ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
48 private val LOGGER = EELFLoggerDelegate.getLogger(InstanceGroupCommand::class.java)
51 override fun createChildren(): Job.JobStatus {
52 return Job.JobStatus.COMPLETED_WITH_NO_ACTION
55 override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
56 val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
57 val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
59 val instantiatePath = asyncInstantiationBL.getInstanceGroupInstantiationPath()
61 val requestDetailsWrapper = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
62 request as InstanceGroup,
63 serviceModelInfo, serviceInstanceId,
67 val actionDescription = "create instance group in $serviceInstanceId"
69 return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
72 override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
73 val path = asyncInstantiationBL.getInstanceGroupDeletePath(getRequest().instanceId)
74 return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.empty(), Optional.of(userId),
75 "delete instance group with id ${getRequest().instanceId}")