Commit 10 for Create Optimized Sched API 34/83234/1
authorJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 16:25:43 +0000 (12:25 -0400)
committerJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 17:03:31 +0000 (13:03 -0400)
Multiple commits required due to commit size limitation.

Change-Id: I437579d4fd86478955131191f0f2f930c440b34a
Issue-ID: OPTFRA-458
Signed-off-by: Jerry Flood <jflood@att.com>
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java [deleted file]
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java [deleted file]
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java [deleted file]
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java [deleted file]

diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java
deleted file mode 100644 (file)
index c0806d7..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- * 
- * 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.
- * 
- * 
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *         https://creativecommons.org/licenses/by/4.0/
- * 
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onap.optf.cmso.common.CMSRequestError;
-import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-@Api("CMSO Optimized Schedule API")
-@Path("/{apiVersion}")
-@Produces({MediaType.APPLICATION_JSON})
-public interface CMSOOptimizedScheduleService {
-
-    // ******************************************************************
-    @POST
-    @Path("/schedules/optimized/{scheduleId}")
-    @Produces({MediaType.APPLICATION_JSON})
-    @ApiOperation(value = "", notes = "Creates a request for an optimized schedule")
-    @ApiResponses(
-            value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."),
-                    @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.",
-                            response = CMSRequestError.class),
-                    @ApiResponse(code = 500, message = "Unexpected Runtime error")})
-    public Response createScheduleRequest(
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
-            @ApiParam(
-                    value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId,
-            @ApiParam(
-                    value = "Data for creating a schedule request for the given schedule id") OptimizedScheduleMessage scheduleMessage);
-
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java
deleted file mode 100644 (file)
index aa397ae..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- * 
- * 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.
- * 
- * 
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *         https://creativecommons.org/licenses/by/4.0/
- * 
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import org.onap.observations.Observation;
-import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
-import org.onap.optf.cmso.eventq.CMSQueueJob;
-import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleQueryDAO;
-import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
-import org.onap.optf.cmso.ticketmgt.TmClient;
-import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Controller;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-@Controller
-public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService {
-    private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
-
-    @Autowired
-    CMSQueueJob qJob;
-
-    @Autowired
-    Environment env;
-
-    @Autowired
-    ChangeManagementScheduleDAO cmScheduleDAO;
-
-    @Autowired
-    ChangeManagementGroupDAO cmGroupDAO;
-
-    @Autowired
-    ChangeManagementChangeWindowDAO cmChangeWindowDAO;
-
-    @Autowired
-    ChangeManagementDetailDAO cmDetailsDAO;
-
-    @Autowired
-    ScheduleQueryDAO scheduleQueryDAO;
-
-    @Autowired
-    ScheduleDAO scheduleDAO;
-
-    @Autowired
-    TmClient tmClient;
-
-    @Autowired
-    BuildCreateRequest buildCreateRequest;
-
-
-    @Context 
-    HttpServletRequest request;
-    
-    @Override
-    @Transactional
-    public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage) 
-    {
-        Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId,
-                scheduleMessage.toString());
-        Response response = null;
-        try {
-            response = Response.accepted().build();
-//        } catch (CMSException e) {
-//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-//             Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
-//            response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
-        } catch (Exception e) {
-               Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            response = Response.serverError().build();
-        }
-        Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId,
-                response.getStatusInfo().toString());
-        return response;
-    }
-
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
deleted file mode 100644 (file)
index 50d2ff2..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- * 
- * 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.
- * 
- * 
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *         https://creativecommons.org/licenses/by/4.0/
- * 
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.transaction.Transactional;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.ISODateTimeFormat;
-import org.onap.optf.cmso.common.CMSStatusEnum;
-import org.onap.optf.cmso.common.DomainsEnum;
-import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
-import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
-import org.onap.optf.cmso.model.ChangeManagementGroup;
-import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
-import org.onap.optf.cmso.optimizer.bean.CMSchedule;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Controller
-public class CMSOOptimizerCallbackImpl extends BaseSchedulerServiceImpl implements CMSOptimizerCallback {
-    private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOOptimizerCallbackImpl.class);
-    private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
-    private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
-    private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
-    private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
-
-    @Context 
-    UriInfo uri;
-    
-    @Context
-    HttpServletRequest request;
-    
-
-    @Autowired
-    ChangeManagementScheduleDAO cmScheduleDAO;
-
-    @Autowired
-    ChangeManagementGroupDAO cmGroupDAO;
-
-    @Autowired
-    ChangeManagementChangeWindowDAO cmChangeWindowDAO;
-
-    @Autowired
-    ChangeManagementDetailDAO cmDetailsDAO;
-
-    @Override
-    @Transactional
-    public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse) {
-        Response response = null;
-        log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), "");
-        log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(),
-                uri.getAbsolutePath().toString());
-        try {
-            // Note that transaction ID and schedule ID are currently the same value.
-
-            String transactionId = sniroResponse.getTransactionId();
-
-            // Synchronize this with transaction that scheduled the SNIRO optimization
-            // to ensure status updates are properly ordered.
-            // This is necessary only in the race condition where SNIRO callback comes
-            // before the SNIRO response is processed and the scheduling transaction is
-            // still in flight.
-            // Note that this may happen in loopback mode, but is not likely to happen with
-            // real SNIRO unless SNIRO changes to be synchronous and the callback comes before
-            // the response.
-            // If this lock times out, the schedule will remain in 'Optimization In
-            // Progress' and never complete.
-            Schedule schedule = scheduleDAO.lockOneByTransactionId(transactionId);
-
-            if (schedule == null) {
-                throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(),
-                        "(OptimizerTransactionID=" + transactionId + ")");
-
-            }
-            CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus());
-            debug.debug("Status at time of SNIRO callback is " + status.toString());
-            switch (status) {
-                // PendingSchedule may be a valid status in the cases where SNIRO async call
-                // returns before
-                // We have committed the OptimizationInProgress status
-                // The dispatch logic ensures that we only every dispatch once.
-                case OptimizationInProgress:
-                    processSniroResponse(sniroResponse, schedule);
-                    scheduleDAO.save(schedule);
-                    response = Response.ok().build();
-                    break;
-                default:
-                    throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR,
-                            CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString());
-            }
-        } catch (CMSException e) {
-            errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-            response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
-        } catch (Exception e) {
-            errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-            response = Response.serverError().entity(e.getMessage()).build();
-        } finally {
-        }
-        return response;
-    }
-
-    private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) {
-        try {
-            schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis());
-            schedule.setOptimizerStatus(sniroResponse.getRequestState());
-            schedule.setOptimizerMessage(sniroResponse.getDescription());
-            String scheduleId = sniroResponse.getScheduleId();
-            ObjectMapper om = new ObjectMapper();
-            CMSchedule[] scheduleArray = sniroResponse.getSchedule();
-            if (scheduleArray != null && scheduleArray.length > 0) {
-                String scheduleString = om.writeValueAsString(scheduleArray);
-                schedule.setSchedule(scheduleString);
-                log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString);
-                for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) {
-                    String groupId = sniroSchedule.getGroupId();
-                    DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime");
-                    DateTime latestInstanceStartTime =
-                            convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime");
-                    DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime");
-                    ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getUuid(), groupId);
-                    if (group == null) {
-                        throw new CMSException(Status.PRECONDITION_FAILED,
-                                LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId);
-                    }
-                    group.setStartTimeMillis(startTime.getMillis());
-                    group.setFinishTimeMillis(finishTime.getMillis());
-                    group.setLastInstanceStartTimeMillis(latestInstanceStartTime.getMillis());
-                    cmGroupDAO.save(group);
-                    long totalDuration =
-                            (group.getAdditionalDurationInSecs() + group.getNormalDurationInSecs()) * 1000l;
-                    Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
-                    makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(), group.getConcurrencyLimit(),
-                            totalDuration, sniroSchedule.getNode(), startAndFinishTimeMap);
-                    for (String node : sniroSchedule.getNode()) {
-                        processNode(schedule, group, node, startAndFinishTimeMap);
-                    }
-                }
-                schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
-            } else {
-                debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus());
-                schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
-            }
-        } catch (CMSException e) {
-            errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-            schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
-            schedule.setOptimizerStatus(e.getStatus().toString());
-            schedule.setOptimizerMessage(e.getLocalizedMessage());
-        } catch (Exception e) {
-            errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-            schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
-            schedule.setOptimizerStatus("Exception");
-            schedule.setOptimizerMessage(e.getLocalizedMessage());
-        }
-    }
-
-    public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
-            List<String> nodes, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
-        Long nextStartTime = null;
-        Long nextFinishTime = null;
-        for (int nodeNumber = 0; nodeNumber < nodes.size(); nodeNumber++) {
-            String node = nodes.get(nodeNumber);
-            if (nodeNumber % concurrencyLimit == 0) {
-                if (nodeNumber == 0)
-                    nextStartTime = startTime;
-                else
-                    nextStartTime = nextStartTime + totalDuration;
-                if (nextStartTime > latestInstanceStartTime) {
-                    throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
-                            startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
-                            String.valueOf(concurrencyLimit), String.valueOf(nodes.size()));
-                }
-                nextFinishTime = nextStartTime + totalDuration;
-            }
-            Map<String, Long> map = new HashMap<String, Long>();
-            map.put("startTime", nextStartTime);
-            map.put("finishTime", nextFinishTime);
-            startAndFinishTimeMap.put(node, map);
-        }
-
-    }
-
-    private void processNode(Schedule schedule, ChangeManagementGroup group, String node,
-            Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
-        Map<String, Long> map = startAndFinishTimeMap.get(node);
-        ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getUuid(), node);
-        if (detail == null) {
-            throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL,
-                    schedule.getScheduleId(), group.getGroupId(), node);
-        }
-        detail.setStartTimeMillis(map.get("startTime"));
-        detail.setFinishTimeMillis(map.get("finishTime"));
-        detail.setVnfId("");
-        detail.setStatus(CMSStatusEnum.PendingApproval.toString());
-        cmScheduleDAO.save(detail);
-    }
-
-    public static DateTime convertDate(String utcDate, String attrName) throws CMSException {
-        try {
-            DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate);
-            if (dateTime != null)
-                return dateTime;
-        } catch (Exception e) {
-            debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-        }
-        throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
-    }
-
-    public static DateTime convertISODate(String utcDate, String attrName) throws CMSException {
-        try {
-            DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
-            if (dateTime != null)
-                return dateTime;
-        } catch (Exception e) {
-            debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
-        }
-        throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
-    }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
deleted file mode 100644 (file)
index 6e99b0d..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.service.rs;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.DELETE;\r
-import javax.ws.rs.DefaultValue;\r
-import javax.ws.rs.GET;\r
-import javax.ws.rs.POST;\r
-import javax.ws.rs.Path;\r
-import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.QueryParam;\r
-import javax.ws.rs.core.Context;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
-import javax.ws.rs.core.UriInfo;\r
-import org.onap.optf.cmso.common.CMSRequestError;\r
-import org.onap.optf.cmso.model.Schedule;\r
-import org.onap.optf.cmso.service.rs.models.ApprovalMessage;\r
-import org.onap.optf.cmso.service.rs.models.CMSMessage;\r
-import org.onap.optf.cmso.service.rs.models.CmDetailsMessage;\r
-import io.swagger.annotations.Api;\r
-import io.swagger.annotations.ApiOperation;\r
-import io.swagger.annotations.ApiParam;\r
-import io.swagger.annotations.ApiResponse;\r
-import io.swagger.annotations.ApiResponses;\r
-\r
-@Api("CMSO Schedule API")\r
-@Path("/{apiVersion}")\r
-@Produces({MediaType.APPLICATION_JSON})\r
-public interface CMSOService {\r
-    // ******************************************************************\r
-    @GET\r
-    @Path("/schedules")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "", notes = "Returns a list of Scheduler Requests based upon the filter criteria.",\r
-            response = Schedule.class, responseContainer = "List")\r
-    @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
-    public Response searchScheduleRequests(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @DefaultValue(value = "false") @ApiParam(\r
-                    value = "Include details") @QueryParam("includeDetails") Boolean includeDetails,\r
-            @ApiParam(value = "Schedule identifier", allowMultiple = true) @QueryParam("scheduleId") String scheduleId,\r
-            @ApiParam(value = "Schedule name", allowMultiple = true) @QueryParam("scheduleName") String scheduleName,\r
-            @ApiParam(value = "SCheduler creator User id of ",\r
-                    allowMultiple = true) @QueryParam("userId") String userId,\r
-            @ApiParam(value = "Schedule status", allowMultiple = true) @QueryParam("status") String status,\r
-            @ApiParam(value = "Creation date and time (<low date>[,<hi date>])",\r
-                    allowMultiple = true) @QueryParam("createDateTime") String createDateTime,\r
-            @ApiParam(value = "Optimizer status",\r
-                    allowMultiple = true) @QueryParam("optimizerStatus") String optimizerStatus,\r
-            @ApiParam(value = "Workflow", allowMultiple = true) @QueryParam("WorkflowName") String workflowName,\r
-            @Context UriInfo uri, @Context HttpServletRequest request);\r
-\r
-    // ******************************************************************\r
-    @POST\r
-    @Path("/schedules/{scheduleId}")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "", notes = "Creates a schedule request for scheduleId")\r
-    @ApiResponses(\r
-            value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."),\r
-                    @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.",\r
-                            response = CMSRequestError.class),\r
-                    @ApiResponse(code = 500, message = "Unexpected Runtime error")})\r
-    public Response createScheduleRequest(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @ApiParam(\r
-                    value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId,\r
-            @ApiParam(\r
-                    value = "Data for creating a schedule request for the given schedule id") CMSMessage scheduleMessage,\r
-            @Context HttpServletRequest request);\r
-\r
-    // ******************************************************************\r
-    @DELETE\r
-    @Path("/schedules/{scheduleId}")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "", notes = "Cancels the schedule request for scheduleId")\r
-    @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"),\r
-            @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error")})\r
-    public Response deleteScheduleRequest(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @ApiParam(\r
-                    value = "Schedule id to uniquely identify the schedule request being deleted.") @PathParam("scheduleId") String scheduleId,\r
-            @Context HttpServletRequest request);\r
-\r
-    // ******************************************************************\r
-    @GET\r
-    @Path("/schedules/{scheduleId}")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "", notes = "Retrieve the schedule request for scheduleId", response = Schedule.class)\r
-    @ApiResponses(\r
-            value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "No record found"),\r
-                    @ApiResponse(code = 500, message = "Unexpected Runtime error")})\r
-    public Response getScheduleRequestInfo(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @ApiParam(\r
-                    value = "Schedule id to uniquely identify the schedule info being retrieved.") @PathParam("scheduleId") String scheduleId,\r
-            @Context HttpServletRequest request);\r
-\r
-    // ******************************************************************\r
-    @POST\r
-    @Path("/schedules/{scheduleId}/approvals")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "",\r
-            notes = "Adds an accept/reject approval status to the schedule request identified by scheduleId")\r
-    @ApiResponses(\r
-            value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "No record found"),\r
-                    @ApiResponse(code = 500, message = "Unexpected Runtime error")})\r
-    public Response approveScheduleRequest(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @ApiParam(\r
-                    value = "Schedule id to uniquely identify the schedule request being accepted or rejected.") @PathParam("scheduleId") String scheduleId,\r
-            @ApiParam(value = "Accept or reject approval message") ApprovalMessage approval,\r
-            @Context HttpServletRequest request);\r
-\r
-    // ******************************************************************\r
-    @GET\r
-    @Path("/schedules/scheduleDetails")\r
-    @Produces({MediaType.APPLICATION_JSON})\r
-    @ApiOperation(value = "", notes = "Returns a list of Schedule request details based upon the filter criteria.",\r
-            response = CmDetailsMessage.class, responseContainer = "List")\r
-    @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
-    public Response searchScheduleRequestDetails(\r
-            @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,\r
-            @ApiParam(value = "Schedule identifier",\r
-                    allowMultiple = true) @QueryParam("request.scheduleId") String scheduleId,\r
-            @ApiParam(value = "Schedule name",\r
-                    allowMultiple = true) @QueryParam("request.scheduleName") String scheduleName,\r
-            @ApiParam(value = "Scheduler creator User id of ",\r
-                    allowMultiple = true) @QueryParam("request.userId") String userId,\r
-            @ApiParam(value = "Schedule status", allowMultiple = true) @QueryParam("request.status") String status,\r
-            @ApiParam(value = "Creation date and time (<low date>[,<hi date>])",\r
-                    allowMultiple = true) @QueryParam("request.createDateTime") String createDateTime,\r
-            @ApiParam(value = "Optimizer status",\r
-                    allowMultiple = true) @QueryParam("request.optimizerStatus") String optimizerStatus,\r
-            @ApiParam(value = "Request Approval user id",\r
-                    allowMultiple = true) @QueryParam("request.approvalUserId") String requestApprovalUserId,\r
-            @ApiParam(value = "Request Approval status",\r
-                    allowMultiple = true) @QueryParam("request.approvalStatus") String requestApprovalStatus,\r
-            @ApiParam(value = "Request Approval type",\r
-                    allowMultiple = true) @QueryParam("request.approvalType") String requestApprovalType,\r
-            @ApiParam(value = "Workflow", allowMultiple = true) @QueryParam("WorkflowName") String workflowName,\r
-            @ApiParam(value = "VNF Name", allowMultiple = true) @QueryParam("vnfName") String vnfName,\r
-            @ApiParam(value = "VNF Id", allowMultiple = true) @QueryParam("vnfId") String vnfId,\r
-            @ApiParam(value = "VNF Status", allowMultiple = true) @QueryParam("vnfStatus") String vnfStatus,\r
-            // @ApiParam(value="VNF Schedule Id", allowMultiple=true) @QueryParam("vnfScheduleId")\r
-            // String\r
-            // vnfScheduleId,\r
-            @ApiParam(value = "Start time <low>,<high>",\r
-                    allowMultiple = true) @QueryParam("startTime") String startTime,\r
-            @ApiParam(value = "Finish time <low>,<high>",\r
-                    allowMultiple = true) @QueryParam("finishTime") String finishTime,\r
-            @ApiParam(value = "Last instance start time <low>,<high>",\r
-                    allowMultiple = true) @QueryParam("lastInstanceTime") String lastInstanceTime,\r
-            @ApiParam(value = "TM Change Ticket Change Id",\r
-                    allowMultiple = true) @QueryParam("tmChangeId") String tmChangeId,\r
-            // @ApiParam(value="Approval user id", allowMultiple=true) @QueryParam("approvalUserId")\r
-            // String approvalUserId,\r
-            // @ApiParam(value="Approval status", allowMultiple=true) @QueryParam("approvalStatus")\r
-            // String\r
-            // approvalStatus,\r
-            // @ApiParam(value="Approval type", allowMultiple=true) @QueryParam("approvalType")\r
-            // String\r
-            // approvalType,\r
-            @ApiParam(value = "Maximum number of schedules to return") @QueryParam("maxSchedules") Integer maxSchedules,\r
-            @ApiParam(value = "Return schedules > lastScheduleId") @QueryParam("lastScheduleId") String lastScheduleId,\r
-            @ApiParam(\r
-                    value = "Return concurrencyLimit") @QueryParam("request.concurrencyLimit") Integer concurrencyLimit,\r
-            @Context UriInfo uri, @Context HttpServletRequest request);\r
-\r
-}\r