blob: 6e65dd358cf513a703c8f16d85cf4cd0ab47e253 [file] [log] [blame]
Yi Tseng890dc3f2018-11-01 13:23:11 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.gnmi.api;
18
19import com.google.common.annotations.Beta;
Yi Tseng890dc3f2018-11-01 13:23:11 -070020import gnmi.Gnmi.CapabilityResponse;
Yi Tseng890dc3f2018-11-01 13:23:11 -070021import gnmi.Gnmi.GetRequest;
Yi Tsengd7716482018-10-31 15:34:30 -070022import gnmi.Gnmi.GetResponse;
Yi Tseng890dc3f2018-11-01 13:23:11 -070023import gnmi.Gnmi.SetRequest;
24import gnmi.Gnmi.SetResponse;
Yi Tsenge616d752018-11-27 10:53:27 -080025import gnmi.Gnmi.SubscribeRequest;
Yi Tseng890dc3f2018-11-01 13:23:11 -070026import org.onosproject.grpc.api.GrpcClient;
27
28import java.util.concurrent.CompletableFuture;
29
30/**
31 * Client to control a gNMI server.
32 */
33@Beta
34public interface GnmiClient extends GrpcClient {
35
36 /**
Yi Tsengd7716482018-10-31 15:34:30 -070037 * Gets capability from a target.
Yi Tseng890dc3f2018-11-01 13:23:11 -070038 *
39 * @return the capability response
40 */
41 CompletableFuture<CapabilityResponse> capability();
42
43 /**
Yi Tsengd7716482018-10-31 15:34:30 -070044 * Retrieves a snapshot of data from the device.
Yi Tseng890dc3f2018-11-01 13:23:11 -070045 *
46 * @param request the get request
47 * @return the snapshot of data from the device
48 */
49 CompletableFuture<GetResponse> get(GetRequest request);
50
51 /**
52 * Modifies the state of data on the device.
53 *
54 * @param request the set request
55 * @return the set result
56 */
57 CompletableFuture<SetResponse> set(SetRequest request);
58
Yi Tseng5f7fef52018-11-05 11:30:47 -080059 /**
Yi Tsenge616d752018-11-27 10:53:27 -080060 * Subscribes to a given specific gNMI path.
61 *
62 * @param request the subscribe request
63 * @return true if subscribe successfully; false otherwise
64 */
65 boolean subscribe(SubscribeRequest request);
66
67 /**
68 * Terminates the subscription channel of this device.
69 */
70 void terminateSubscriptionChannel();
71
72 /**
73 * Check weather the gNMI service is available or not by sending a dummy get
74 * request message.
Yi Tseng5f7fef52018-11-05 11:30:47 -080075 *
76 * @return true if gNMI service available; false otherwise
77 */
78 CompletableFuture<Boolean> isServiceAvailable();
Yi Tseng890dc3f2018-11-01 13:23:11 -070079}