Bump upstream dependencies to Ca
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / impl / rpc / GetNodeEdgePointDetailsImpl.java
1 /*
2  * Copyright © 2024 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.tapi.impl.rpc;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.transportpce.tapi.utils.TapiContext;
12 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
13 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetails;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsInput;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutput;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutputBuilder;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.edge.point.details.output.NodeEdgePointBuilder;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
19 import org.opendaylight.yangtools.yang.common.ErrorType;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25
26 public class GetNodeEdgePointDetailsImpl implements GetNodeEdgePointDetails {
27     private static final Logger LOG = LoggerFactory.getLogger(GetNodeEdgePointDetailsImpl.class);
28     private final TapiContext tapiContext;
29
30     public GetNodeEdgePointDetailsImpl(TapiContext tapiContext) {
31         this.tapiContext = tapiContext;
32     }
33
34     @Override
35     public ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> invoke(GetNodeEdgePointDetailsInput input) {
36         // TODO Auto-generated method stub
37         // TODO -> maybe we get errors when having CEPs?
38         Uuid topoUuid = input.getTopologyId();
39         // Node id: if roadm -> ROADMid+PHOTONIC_MEDIA. if xpdr -> XPDRid-XPDRnbr+DSR/OTSi
40         Uuid nodeUuid = input.getNodeId();
41         // NEP id: if roadm -> ROADMid+PHOTONIC_MEDIA/MC/OTSiMC+TPid.
42         // if xpdr -> XPDRid-XPDRnbr+DSR/eODU/iODU/iOTSi/eOTSi/PHOTONIC_MEDIA+TPid
43         Uuid nepUuid = input.getNodeEdgePointId();
44         OwnedNodeEdgePoint nep = this.tapiContext.getTapiNEP(topoUuid, nodeUuid, nepUuid);
45         if (nep == null) {
46             LOG.error("Invalid TAPI nep name");
47             return RpcResultBuilder.<GetNodeEdgePointDetailsOutput>failed()
48                 .withError(ErrorType.RPC, "Invalid NEP name")
49                 .buildFuture();
50         }
51         return RpcResultBuilder
52                 .success(new GetNodeEdgePointDetailsOutputBuilder()
53                         .setNodeEdgePoint(new NodeEdgePointBuilder(nep).build()).build())
54                 .buildFuture();
55     }
56
57 }