summaryrefslogtreecommitdiffstats
path: root/cmso-service
diff options
context:
space:
mode:
Diffstat (limited to 'cmso-service')
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java74
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java122
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java269
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java206
4 files changed, 0 insertions, 671 deletions
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
index c0806d7..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java
+++ /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
index aa397ae..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java
+++ /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
index 50d2ff2..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
+++ /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
index 6e99b0d..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
+++ /dev/null
@@ -1,206 +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.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import org.onap.optf.cmso.common.CMSRequestError;
-import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.service.rs.models.ApprovalMessage;
-import org.onap.optf.cmso.service.rs.models.CMSMessage;
-import org.onap.optf.cmso.service.rs.models.CmDetailsMessage;
-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 Schedule API")
-@Path("/{apiVersion}")
-@Produces({MediaType.APPLICATION_JSON})
-public interface CMSOService {
- // ******************************************************************
- @GET
- @Path("/schedules")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "", notes = "Returns a list of Scheduler Requests based upon the filter criteria.",
- response = Schedule.class, responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class),
- @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
- public Response searchScheduleRequests(
- @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @DefaultValue(value = "false") @ApiParam(
- value = "Include details") @QueryParam("includeDetails") Boolean includeDetails,
- @ApiParam(value = "Schedule identifier", allowMultiple = true) @QueryParam("scheduleId") String scheduleId,
- @ApiParam(value = "Schedule name", allowMultiple = true) @QueryParam("scheduleName") String scheduleName,
- @ApiParam(value = "SCheduler creator User id of ",
- allowMultiple = true) @QueryParam("userId") String userId,
- @ApiParam(value = "Schedule status", allowMultiple = true) @QueryParam("status") String status,
- @ApiParam(value = "Creation date and time (<low date>[,<hi date>])",
- allowMultiple = true) @QueryParam("createDateTime") String createDateTime,
- @ApiParam(value = "Optimizer status",
- allowMultiple = true) @QueryParam("optimizerStatus") String optimizerStatus,
- @ApiParam(value = "Workflow", allowMultiple = true) @QueryParam("WorkflowName") String workflowName,
- @Context UriInfo uri, @Context HttpServletRequest request);
-
- // ******************************************************************
- @POST
- @Path("/schedules/{scheduleId}")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "", notes = "Creates a schedule request for scheduleId")
- @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") CMSMessage scheduleMessage,
- @Context HttpServletRequest request);
-
- // ******************************************************************
- @DELETE
- @Path("/schedules/{scheduleId}")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "", notes = "Cancels the schedule request for scheduleId")
- @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"),
- @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- public Response deleteScheduleRequest(
- @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(
- value = "Schedule id to uniquely identify the schedule request being deleted.") @PathParam("scheduleId") String scheduleId,
- @Context HttpServletRequest request);
-
- // ******************************************************************
- @GET
- @Path("/schedules/{scheduleId}")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "", notes = "Retrieve the schedule request for scheduleId", response = Schedule.class)
- @ApiResponses(
- value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "No record found"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- public Response getScheduleRequestInfo(
- @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(
- value = "Schedule id to uniquely identify the schedule info being retrieved.") @PathParam("scheduleId") String scheduleId,
- @Context HttpServletRequest request);
-
- // ******************************************************************
- @POST
- @Path("/schedules/{scheduleId}/approvals")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "",
- notes = "Adds an accept/reject approval status to the schedule request identified by scheduleId")
- @ApiResponses(
- value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "No record found"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- public Response approveScheduleRequest(
- @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(
- value = "Schedule id to uniquely identify the schedule request being accepted or rejected.") @PathParam("scheduleId") String scheduleId,
- @ApiParam(value = "Accept or reject approval message") ApprovalMessage approval,
- @Context HttpServletRequest request);
-
- // ******************************************************************
- @GET
- @Path("/schedules/scheduleDetails")
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "", notes = "Returns a list of Schedule request details based upon the filter criteria.",
- response = CmDetailsMessage.class, responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class),
- @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
- public Response searchScheduleRequestDetails(
- @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(value = "Schedule identifier",
- allowMultiple = true) @QueryParam("request.scheduleId") String scheduleId,
- @ApiParam(value = "Schedule name",
- allowMultiple = true) @QueryParam("request.scheduleName") String scheduleName,
- @ApiParam(value = "Scheduler creator User id of ",
- allowMultiple = true) @QueryParam("request.userId") String userId,
- @ApiParam(value = "Schedule status", allowMultiple = true) @QueryParam("request.status") String status,
- @ApiParam(value = "Creation date and time (<low date>[,<hi date>])",
- allowMultiple = true) @QueryParam("request.createDateTime") String createDateTime,
- @ApiParam(value = "Optimizer status",
- allowMultiple = true) @QueryParam("request.optimizerStatus") String optimizerStatus,
- @ApiParam(value = "Request Approval user id",
- allowMultiple = true) @QueryParam("request.approvalUserId") String requestApprovalUserId,
- @ApiParam(value = "Request Approval status",
- allowMultiple = true) @QueryParam("request.approvalStatus") String requestApprovalStatus,
- @ApiParam(value = "Request Approval type",
- allowMultiple = true) @QueryParam("request.approvalType") String requestApprovalType,
- @ApiParam(value = "Workflow", allowMultiple = true) @QueryParam("WorkflowName") String workflowName,
- @ApiParam(value = "VNF Name", allowMultiple = true) @QueryParam("vnfName") String vnfName,
- @ApiParam(value = "VNF Id", allowMultiple = true) @QueryParam("vnfId") String vnfId,
- @ApiParam(value = "VNF Status", allowMultiple = true) @QueryParam("vnfStatus") String vnfStatus,
- // @ApiParam(value="VNF Schedule Id", allowMultiple=true) @QueryParam("vnfScheduleId")
- // String
- // vnfScheduleId,
- @ApiParam(value = "Start time <low>,<high>",
- allowMultiple = true) @QueryParam("startTime") String startTime,
- @ApiParam(value = "Finish time <low>,<high>",
- allowMultiple = true) @QueryParam("finishTime") String finishTime,
- @ApiParam(value = "Last instance start time <low>,<high>",
- allowMultiple = true) @QueryParam("lastInstanceTime") String lastInstanceTime,
- @ApiParam(value = "TM Change Ticket Change Id",
- allowMultiple = true) @QueryParam("tmChangeId") String tmChangeId,
- // @ApiParam(value="Approval user id", allowMultiple=true) @QueryParam("approvalUserId")
- // String approvalUserId,
- // @ApiParam(value="Approval status", allowMultiple=true) @QueryParam("approvalStatus")
- // String
- // approvalStatus,
- // @ApiParam(value="Approval type", allowMultiple=true) @QueryParam("approvalType")
- // String
- // approvalType,
- @ApiParam(value = "Maximum number of schedules to return") @QueryParam("maxSchedules") Integer maxSchedules,
- @ApiParam(value = "Return schedules > lastScheduleId") @QueryParam("lastScheduleId") String lastScheduleId,
- @ApiParam(
- value = "Return concurrencyLimit") @QueryParam("request.concurrencyLimit") Integer concurrencyLimit,
- @Context UriInfo uri, @Context HttpServletRequest request);
-
-}