2 * Copyright © 2024 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.renderer.rpcs;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePath;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutputBuilder;
18 import org.opendaylight.yangtools.yang.common.RpcResult;
19 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
25 * This class is the implementation of the 'service-path' RESTCONF service,
26 * which is one of the external APIs into the renderer application. The
27 * service provides two functions:
30 * 1. Create This operation results in provisioning the device for a given
31 * wavelength and a list of nodes with each node listing its termination
35 * 2. Delete This operation results in de-provisioning the device for a
36 * given wavelength and a list of nodes with each node listing its
40 * The signature for this method was generated by yang tools from the
43 public class ServicePathImpl implements ServicePath {
44 private static final Logger LOG = LoggerFactory.getLogger(ServicePathImpl.class);
45 private DeviceRendererService deviceRendererService;
47 public ServicePathImpl(final DeviceRendererService deviceRendererService) {
48 this.deviceRendererService = requireNonNull(deviceRendererService);
52 public ListenableFuture<RpcResult<ServicePathOutput>> invoke(ServicePathInput input) {
53 if (input.getOperation() != null) {
54 if (input.getOperation().getIntValue() == 1) {
55 LOG.info("Create operation request received");
56 return RpcResultBuilder.success(
57 this.deviceRendererService.setupServicePath(input, null))
59 } else if (input.getOperation().getIntValue() == 2) {
60 LOG.info("Delete operation request received");
61 return RpcResultBuilder
62 .success(this.deviceRendererService.deleteServicePath(input))
66 return RpcResultBuilder
67 .success(new ServicePathOutputBuilder().setResult("Invalid operation").build())