summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Flood <jflood@att.com>2019-03-28 05:54:00 -0400
committerJerry Flood <jflood@att.com>2019-03-28 06:02:03 -0400
commit8cb9db78bb16d36c03be6ba282448faf700d3253 (patch)
tree5159929ff6d45981870554989a6b548362ce34c1
parent24fa414588a4dca98d6e215ecf486769a7e293bb (diff)
Commit 7 for Define OPtimizer API mS
Multiple commits required due to commit size limitation. Change-Id: I3b5f2648d365ed41c014315e44045361bda6b585 Issue-ID: OPTFRA-437 Signed-off-by: Jerry Flood <jflood@att.com>
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Response.java75
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Ticket.java110
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Topology.java108
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/OptimizerDao.java38
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/RequestDao.java38
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/ResponseDao.java38
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TicketDao.java38
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TopologyDao.java38
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminTool.java63
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminToolImpl.java60
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheck.java62
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheckImpl.java106
-rw-r--r--cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterface.java115
13 files changed, 889 insertions, 0 deletions
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Response.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Response.java
new file mode 100644
index 0000000..b327ccd
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Response.java
@@ -0,0 +1,75 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model;
+
+import java.io.Serializable;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQuery;
+
+
+/**
+ * The persistent class for the response database table.
+ *
+ */
+@Entity
+@NamedQuery(name = "Response.findAll", query = "SELECT r FROM Response r")
+public class Response implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ private UUID uuid;
+
+ @Column(name = "delivered_time")
+ private Long deliveredTime;
+
+ @Lob
+ private String response;
+
+ public Response() {}
+
+ public UUID getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public Long getDeliveredTime() {
+ return this.deliveredTime;
+ }
+
+ public void setDeliveredTime(Long deliveredTime) {
+ this.deliveredTime = deliveredTime;
+ }
+
+ public String getRepsonse() {
+ return this.response;
+ }
+
+ public void setRepsonse(String repsonse) {
+ this.response = repsonse;
+ }
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Ticket.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Ticket.java
new file mode 100644
index 0000000..1fb9ed5
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Ticket.java
@@ -0,0 +1,110 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model;
+
+import java.io.Serializable;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+
+/**
+ * The persistent class for the tickets database table.
+ *
+ */
+@Entity
+@Table(name = "tickets")
+@NamedQuery(name = "Ticket.findAll", query = "SELECT t FROM Ticket t")
+public class Ticket implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ private UUID uuid;
+
+ @Lob
+ private String tickets;
+
+ @Column(name = "tickets_end")
+ private Long ticketsEnd;
+
+ @Column(name = "tickets_retries")
+ private Integer ticketsRetries;
+
+ @Column(name = "tickets_start")
+ private Long ticketsStart;
+
+ @Column(name = "topology_polling_interval")
+ private Integer topologyPollingInterval;
+
+ public Ticket() {}
+
+ public UUID getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getTickets() {
+ return this.tickets;
+ }
+
+ public void setTickets(String tickets) {
+ this.tickets = tickets;
+ }
+
+ public Long getTicketsEnd() {
+ return this.ticketsEnd;
+ }
+
+ public void setTicketsEnd(Long ticketsEnd) {
+ this.ticketsEnd = ticketsEnd;
+ }
+
+ public Integer getTicketsRetries() {
+ return this.ticketsRetries;
+ }
+
+ public void setTicketsRetries(Integer ticketsRetries) {
+ this.ticketsRetries = ticketsRetries;
+ }
+
+ public Long getTicketsStart() {
+ return this.ticketsStart;
+ }
+
+ public void setTicketsStart(Long ticketsStart) {
+ this.ticketsStart = ticketsStart;
+ }
+
+ public Integer getTopologyPollingInterval() {
+ return this.topologyPollingInterval;
+ }
+
+ public void setTopologyPollingInterval(Integer topologyPollingInterval) {
+ this.topologyPollingInterval = topologyPollingInterval;
+ }
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Topology.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Topology.java
new file mode 100644
index 0000000..f113634
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/Topology.java
@@ -0,0 +1,108 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model;
+
+import java.io.Serializable;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQuery;
+
+
+/**
+ * The persistent class for the topology database table.
+ *
+ */
+@Entity
+@NamedQuery(name = "Topology.findAll", query = "SELECT t FROM Topology t")
+public class Topology implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ private UUID uuid;
+
+ @Lob
+ private String topology;
+
+ @Column(name = "topology_end")
+ private Long topologyEnd;
+
+ @Column(name = "topology_polling_interval")
+ private Integer topologyPollingInterval;
+
+ @Column(name = "topology_retries")
+ private Integer topologyRetries;
+
+ @Column(name = "topology_start")
+ private Long topologyStart;
+
+ public Topology() {}
+
+ public UUID getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getTopology() {
+ return this.topology;
+ }
+
+ public void setTopology(String topology) {
+ this.topology = topology;
+ }
+
+ public Long getTopologyEnd() {
+ return this.topologyEnd;
+ }
+
+ public void setTopologyEnd(Long topologyEnd) {
+ this.topologyEnd = topologyEnd;
+ }
+
+ public Integer getTopologyPollingInterval() {
+ return this.topologyPollingInterval;
+ }
+
+ public void setTopologyPollingInterval(Integer topologyPollingInterval) {
+ this.topologyPollingInterval = topologyPollingInterval;
+ }
+
+ public Integer getTopologyRetries() {
+ return this.topologyRetries;
+ }
+
+ public void setTopologyRetries(Integer topologyRetries) {
+ this.topologyRetries = topologyRetries;
+ }
+
+ public Long getTopologyStart() {
+ return this.topologyStart;
+ }
+
+ public void setTopologyStart(Long topologyStart) {
+ this.topologyStart = topologyStart;
+ }
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/OptimizerDao.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/OptimizerDao.java
new file mode 100644
index 0000000..96a4fe1
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/OptimizerDao.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model.dao;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.onap.optf.cmso.optimizer.model.Optimizer;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+public interface OptimizerDao extends PagingAndSortingRepository<Optimizer, UUID> {
+ @Override
+ Optional<Optimizer> findById(UUID id);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ Optimizer save(Optimizer persisted);
+
+ @Override
+ void delete(Optimizer toDelete);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/RequestDao.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/RequestDao.java
new file mode 100644
index 0000000..6a2ac3b
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/RequestDao.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model.dao;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.onap.optf.cmso.optimizer.model.Request;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+public interface RequestDao extends PagingAndSortingRepository<Request, UUID> {
+ @Override
+ Optional<Request> findById(UUID id);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ Request save(Request persisted);
+
+ @Override
+ void delete(Request toDelete);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/ResponseDao.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/ResponseDao.java
new file mode 100644
index 0000000..bf91b6b
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/ResponseDao.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model.dao;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.onap.optf.cmso.optimizer.model.Response;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+public interface ResponseDao extends PagingAndSortingRepository<Response, UUID> {
+ @Override
+ Optional<Response> findById(UUID id);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ Response save(Response persisted);
+
+ @Override
+ void delete(Response toDelete);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TicketDao.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TicketDao.java
new file mode 100644
index 0000000..41642f7
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TicketDao.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model.dao;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.onap.optf.cmso.optimizer.model.Ticket;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+public interface TicketDao extends PagingAndSortingRepository<Ticket, UUID> {
+ @Override
+ Optional<Ticket> findById(UUID id);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ Ticket save(Ticket persisted);
+
+ @Override
+ void delete(Ticket toDelete);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TopologyDao.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TopologyDao.java
new file mode 100644
index 0000000..e0d0566
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/model/dao/TopologyDao.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START==============================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * =======================================================================
+ * 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.
+ * ============LICENSE_END=================================================
+ *
+ */
+
+package org.onap.optf.cmso.optimizer.model.dao;
+
+import java.util.Optional;
+import java.util.UUID;
+import org.onap.optf.cmso.optimizer.model.Topology;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+public interface TopologyDao extends PagingAndSortingRepository<Topology, UUID> {
+ @Override
+ Optional<Topology> findById(UUID id);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ Topology save(Topology persisted);
+
+ @Override
+ void delete(Topology toDelete);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminTool.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminTool.java
new file mode 100644
index 0000000..bc9a389
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminTool.java
@@ -0,0 +1,63 @@
+/*
+ * 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.optimizer.service.rs;
+
+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;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+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.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+@Api("Administration")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface AdminTool {
+
+ // ******************************************************************
+ @GET
+ @Path("/admin/{id}")
+ @Produces({MediaType.TEXT_PLAIN})
+ @RequestMapping(value = "/{apiVersion}/admin/{id}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN)
+ @ApiOperation(value = "", notes = "Returns encrypted value of id.", response = String.class)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 400, message = "Request failed")})
+ public Response exec(@ApiParam(
+ value = "v1|v2") @PathVariable @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Identifier") @PathVariable @PathParam("id") String id);
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminToolImpl.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminToolImpl.java
new file mode 100644
index 0000000..7b4859d
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/AdminToolImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.optimizer.service.rs;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.onap.optf.cmso.common.PropertiesManagement;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class AdminToolImpl implements AdminTool {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);
+
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+ @Override
+ public Response exec(String apiVersion, String id) {
+ log.info("AdminTool.exec entered " + uri.getPath());
+ if (id.length() < 4) {
+ return Response.ok("").build();
+ }
+ String encrypted = PropertiesManagement.getEncryptedValue(id);
+ Response response = Response.ok(encrypted).build();
+ return response;
+ }
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheck.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheck.java
new file mode 100644
index 0000000..aba9cde
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheck.java
@@ -0,0 +1,62 @@
+/*
+ * 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.optimizer.service.rs;
+
+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;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+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.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.optf.cmso.optimizer.service.rs.models.HealthCheckMessage;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Api("Administration")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface HealthCheck {
+
+ // ******************************************************************
+ @GET
+ @Path("/health")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/health", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "Returns health status of server.", response = HealthCheckMessage.class)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 400, message = "Not healthy", response = HealthCheckMessage.class)})
+ public Response healthCheck(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Check Interfaces") @QueryParam("checkInterfaces") @DefaultValue(
+ value = "true") Boolean checkInterfaces);
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheckImpl.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheckImpl.java
new file mode 100644
index 0000000..80deaaf
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/HealthCheckImpl.java
@@ -0,0 +1,106 @@
+/*
+ * 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.optimizer.service.rs;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.onap.optf.cmso.optimizer.model.dao.RequestDao;
+import org.onap.optf.cmso.optimizer.service.rs.models.HealthCheckComponent;
+import org.onap.optf.cmso.optimizer.service.rs.models.HealthCheckMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class HealthCheckImpl implements HealthCheck {
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+
+
+ @Autowired
+ Environment env;
+
+ @Autowired
+ RequestDao requestDao;
+
+
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+
+ @Override
+ public Response healthCheck(String apiVersion, Boolean checkInterfaces) {
+ debug.debug("Entered healthcheck");
+ Response response = null;
+ HealthCheckMessage hc = new HealthCheckMessage();
+ hc.setHealthy(true);
+
+ addToHealthCheckMessage(hc, this.healthCheckDb());
+
+ if (hc.getHealthy()) {
+ response = Response.ok().entity(hc).build();
+ }
+ else {
+ response = Response.status(Response.Status.BAD_REQUEST).entity(hc).build();
+ }
+ return response;
+ }
+
+ private void addToHealthCheckMessage(HealthCheckMessage hc, HealthCheckComponent hcc) {
+ if (!hcc.getHealthy()) {
+ hc.setHealthy(false);
+ }
+
+ hc.setHostname(System.getenv("HOSTNAME"));
+ hc.addComponent(hcc);
+ }
+
+ private HealthCheckComponent healthCheckDb() {
+ HealthCheckComponent hcc = new HealthCheckComponent();
+ hcc.setName("Optimizer database");
+ String url = env.getProperty("spring.datasource.url");
+ hcc.setUrl(url);
+ try {
+ requestDao.findById(UUID.randomUUID());
+ hcc.setHealthy(true);
+ hcc.setStatus("OK");
+ } catch (Exception e) {
+ hcc.setStatus(e.getMessage());
+
+ }
+ return hcc;
+ }
+
+}
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterface.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterface.java
new file mode 100644
index 0000000..27a368f
--- /dev/null
+++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterface.java
@@ -0,0 +1,115 @@
+/*
+ * 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.optimizer.service.rs;
+
+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;
+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.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.optf.cmso.common.CmsoRequestError;
+import org.onap.optf.cmso.optimizer.service.rs.models.OptimizerRequest;
+import org.onap.optf.cmso.optimizer.service.rs.models.OptimizerResponse;
+import org.onap.optf.cmso.optimizer.service.rs.models.PolicyInfo;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Api("Optimizer Interface")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface OptimizerInterface {
+ // ******************************************************************
+
+ @POST
+ @Path("/optimize/schedule")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/optimize/shedule", method = RequestMethod.POST,
+ consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "API to request schedule optimization for the passed elements.")
+ @ApiResponses(value = {@ApiResponse(code = 202, message = "Accepted"),
+ @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response optimizeSchedule(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(
+ value = "v1") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Optimization data.") OptimizerRequest optimizerRequest);
+
+ @GET
+ @Path("/policies")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/policies", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "API to retrieve supported change management policies.",
+ response = PolicyInfo.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response getPolicies(@ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(
+ value = "v1") @DefaultValue("v1") String apiVersion);
+
+ @GET
+ @Path("/optimize/schedule/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/schedule/{id}", method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "API to poll for " + " optimized schedule.", response = OptimizerResponse.class)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "Not found.", response = CmsoRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response getSchedule(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(
+ value = "v1") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Request id") @PathParam("id") @PathVariable(value = "id") String id);
+
+ @DELETE
+ @Path("/optimize/schedule/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/schedule/{id}", method = RequestMethod.DELETE,
+ produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "API to acknowledge and delete"
+ + " optimized schedule request. Acknowledgesthat optimization has "
+ + "results have been retrieved an are safe to delete")
+ @ApiResponses(value = {@ApiResponse(code = 204, message = "Deleted"),
+ @ApiResponse(code = 404, message = "Not found.", response = CmsoRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response deleteSchedule(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(
+ value = "v1") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Request id") @PathParam("id") @PathVariable(value = "id") String id);
+
+
+
+}