/* * Copyright © 2024 Orange, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.transportpce.tapi.impl.rpc; import com.google.common.util.concurrent.ListenableFuture; import java.util.Map; import org.opendaylight.transportpce.tapi.utils.TapiContext; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetails; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutputBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey; import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class GetServiceInterfacePointDetailsImpl implements GetServiceInterfacePointDetails { private static final Logger LOG = LoggerFactory.getLogger(GetServiceInterfacePointDetailsImpl.class); private final TapiContext tapiContext; public GetServiceInterfacePointDetailsImpl(TapiContext tapiContext) { this.tapiContext = tapiContext; } @Override public ListenableFuture> invoke( GetServiceInterfacePointDetailsInput input) { Uuid sipUuid = input.getUuid(); Map sips = this.tapiContext.getTapiContext().getServiceInterfacePoint(); if (sips == null || sips.isEmpty()) { return RpcResultBuilder.failed() .withError(ErrorType.RPC, "No sips in datastore") .buildFuture(); } if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) { return RpcResultBuilder.failed() .withError(ErrorType.RPC, "Sip doesnt exist in datastore") .buildFuture(); } var outSip = new org.opendaylight.yang.gen.v1.urn .onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.SipBuilder( sips.get(new ServiceInterfacePointKey(sipUuid))) .build(); return RpcResultBuilder .success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build()) .buildFuture(); } }