Eliminate network-pcep-topology-config
[bgpcep.git] / pcep / topology / topology-provider / src / main / java / org / opendaylight / bgpcep / pcep / topology / provider / TopologyRPCs.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, 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.bgpcep.pcep.topology.provider;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.AddLspOutputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.EnsureLspOperationalInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.EnsureLspOperationalOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.EnsureLspOperationalOutputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.NetworkTopologyPcepService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.RemoveLspOutputBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TearDownSessionInput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TearDownSessionOutput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TearDownSessionOutputBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TriggerSyncInput;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TriggerSyncOutput;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TriggerSyncOutputBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspInput;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspOutput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.UpdateLspOutputBuilder;
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36
37 final class TopologyRPCs implements NetworkTopologyPcepService {
38     private final ServerSessionManager manager;
39
40     TopologyRPCs(final ServerSessionManager manager) {
41         this.manager = requireNonNull(manager);
42     }
43
44     @Override
45     public ListenableFuture<RpcResult<AddLspOutput>> addLsp(final AddLspInput input) {
46         return Futures.transform(this.manager.addLsp(input),
47             input1 -> SuccessfulRpcResult.create(new AddLspOutputBuilder(input1).build()),
48             MoreExecutors.directExecutor());
49     }
50
51     @Override
52     public ListenableFuture<RpcResult<RemoveLspOutput>> removeLsp(final RemoveLspInput input) {
53         return Futures.transform(this.manager.removeLsp(input),
54             input1 -> SuccessfulRpcResult.create(new RemoveLspOutputBuilder(input1).build()),
55             MoreExecutors.directExecutor());
56     }
57
58     @Override
59     public ListenableFuture<RpcResult<TriggerSyncOutput>> triggerSync(final TriggerSyncInput input) {
60         return Futures.transform(this.manager.triggerSync(input),
61             input1 -> SuccessfulRpcResult.create(new TriggerSyncOutputBuilder(input1).build()),
62             MoreExecutors.directExecutor());
63     }
64
65     @Override
66     public ListenableFuture<RpcResult<UpdateLspOutput>> updateLsp(final UpdateLspInput input) {
67         return Futures.transform(this.manager.updateLsp(input),
68             input1 -> SuccessfulRpcResult.create(new UpdateLspOutputBuilder(input1).build()),
69             MoreExecutors.directExecutor());
70     }
71
72     @Override
73     public ListenableFuture<RpcResult<EnsureLspOperationalOutput>> ensureLspOperational(
74             final EnsureLspOperationalInput input) {
75         return Futures.transform(this.manager.ensureLspOperational(input),
76             input1 -> SuccessfulRpcResult.create(new EnsureLspOperationalOutputBuilder(input1).build()),
77             MoreExecutors.directExecutor());
78     }
79
80     @Override
81     public ListenableFuture<RpcResult<TearDownSessionOutput>> tearDownSession(final TearDownSessionInput input) {
82         return Futures.transform(this.manager.tearDownSession(input),
83             input1 -> SuccessfulRpcResult.create(new TearDownSessionOutputBuilder().build()),
84             MoreExecutors.directExecutor());
85     }
86 }