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.olm.rpc.impl;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.transportpce.olm.service.OlmPowerService;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPm;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput;
17 import org.opendaylight.yangtools.yang.common.ErrorType;
18 import org.opendaylight.yangtools.yang.common.RpcResult;
19 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * This class is the implementation of the 'get-pm' RESTCONF service, which
25 * is one of the external APIs into the olm application.
28 * This operation traverse through current PM list and gets PM for
29 * given NodeId and Resource name
31 public final class GetPmImpl implements GetPm {
32 private static final Logger LOG = LoggerFactory.getLogger(GetPmImpl.class);
33 private final OlmPowerService olmPowerService;
35 public GetPmImpl(final OlmPowerService olmPowerService) {
36 this.olmPowerService = requireNonNull(olmPowerService);
40 public ListenableFuture<RpcResult<GetPmOutput>> invoke(final GetPmInput input) {
41 if (input.getNodeId() == null) {
42 LOG.error("getPm: NodeId can not be null");
43 return RpcResultBuilder.<GetPmOutput>failed()
44 .withError(ErrorType.RPC, "Error with input parameters")
47 return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture();