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.tapi.impl.rpc;
10 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.transportpce.tapi.utils.TapiContext;
13 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetails;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutputBuilder;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
20 import org.opendaylight.yangtools.yang.common.ErrorType;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 public class GetServiceInterfacePointDetailsImpl implements GetServiceInterfacePointDetails {
28 private static final Logger LOG = LoggerFactory.getLogger(GetServiceInterfacePointDetailsImpl.class);
29 private final TapiContext tapiContext;
31 public GetServiceInterfacePointDetailsImpl(TapiContext tapiContext) {
32 this.tapiContext = tapiContext;
36 public ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> invoke(
37 GetServiceInterfacePointDetailsInput input) {
38 Uuid sipUuid = input.getUuid();
39 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
40 this.tapiContext.getTapiContext().getServiceInterfacePoint();
41 if (sips == null || sips.isEmpty()) {
42 return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
43 .withError(ErrorType.RPC, "No sips in datastore")
46 if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) {
47 return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
48 .withError(ErrorType.RPC, "Sip doesnt exist in datastore")
51 var outSip = new org.opendaylight.yang.gen.v1.urn
52 .onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.SipBuilder(
53 sips.get(new ServiceInterfacePointKey(sipUuid)))
55 return RpcResultBuilder
56 .success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build())