Revoke delegation sent as Pcinitiate message.
[bgpcep.git] / pcep / 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 com.google.common.base.Function;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.Futures;
13
14 import java.util.concurrent.Future;
15
16 import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspOutputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalOutputBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.NetworkTopologyPcepService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutputBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspInput;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutput;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutputBuilder;
31 import org.opendaylight.yangtools.yang.common.RpcResult;
32
33 final class TopologyRPCs implements NetworkTopologyPcepService {
34     private final ServerSessionManager manager;
35
36     TopologyRPCs(final ServerSessionManager manager) {
37         this.manager = Preconditions.checkNotNull(manager);
38     }
39
40     @Override
41     public Future<RpcResult<AddLspOutput>> addLsp(final AddLspInput input) {
42         return Futures.transform(manager.addLsp(input), new Function<OperationResult, RpcResult<AddLspOutput>>() {
43             @Override
44             public RpcResult<AddLspOutput> apply(final OperationResult input) {
45                 return SuccessfulRpcResult.create(new AddLspOutputBuilder(input).build());
46             }
47         });
48     }
49
50     @Override
51     public Future<RpcResult<RemoveLspOutput>> removeLsp(final RemoveLspInput input) {
52         return Futures.transform(manager.removeLsp(input), new Function<OperationResult, RpcResult<RemoveLspOutput>>() {
53             @Override
54             public RpcResult<RemoveLspOutput> apply(final OperationResult input) {
55                 return SuccessfulRpcResult.create(new RemoveLspOutputBuilder(input).build());
56             }
57         });
58     }
59
60     @Override
61     public Future<RpcResult<UpdateLspOutput>> updateLsp(final UpdateLspInput input) {
62         return Futures.transform(manager.updateLsp(input), new Function<OperationResult, RpcResult<UpdateLspOutput>>() {
63             @Override
64             public RpcResult<UpdateLspOutput> apply(final OperationResult input) {
65                 return SuccessfulRpcResult.create(new UpdateLspOutputBuilder(input).build());
66             }
67         });
68     }
69
70     @Override
71     public Future<RpcResult<EnsureLspOperationalOutput>> ensureLspOperational(final EnsureLspOperationalInput input) {
72         return Futures.transform(manager.ensureLspOperational(input),
73                 new Function<OperationResult, RpcResult<EnsureLspOperationalOutput>>() {
74                     @Override
75                     public RpcResult<EnsureLspOperationalOutput> apply(final OperationResult input) {
76                         return SuccessfulRpcResult.create(new EnsureLspOperationalOutputBuilder(input).build());
77                     }
78                 });
79     }
80 }