Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.gnmi.api; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 20 | import gnmi.Gnmi.CapabilityResponse; |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 21 | import gnmi.Gnmi.GetRequest; |
Yi Tseng | d771648 | 2018-10-31 15:34:30 -0700 | [diff] [blame] | 22 | import gnmi.Gnmi.GetResponse; |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 23 | import gnmi.Gnmi.SetRequest; |
| 24 | import gnmi.Gnmi.SetResponse; |
Yi Tseng | e616d75 | 2018-11-27 10:53:27 -0800 | [diff] [blame] | 25 | import gnmi.Gnmi.SubscribeRequest; |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 26 | import org.onosproject.grpc.api.GrpcClient; |
| 27 | |
| 28 | import java.util.concurrent.CompletableFuture; |
| 29 | |
| 30 | /** |
| 31 | * Client to control a gNMI server. |
| 32 | */ |
| 33 | @Beta |
| 34 | public interface GnmiClient extends GrpcClient { |
| 35 | |
| 36 | /** |
Yi Tseng | d771648 | 2018-10-31 15:34:30 -0700 | [diff] [blame] | 37 | * Gets capability from a target. |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 38 | * |
| 39 | * @return the capability response |
| 40 | */ |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 41 | CompletableFuture<CapabilityResponse> capabilities(); |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
Yi Tseng | d771648 | 2018-10-31 15:34:30 -0700 | [diff] [blame] | 44 | * Retrieves a snapshot of data from the device. |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 45 | * |
| 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 Tseng | 5f7fef5 | 2018-11-05 11:30:47 -0800 | [diff] [blame] | 59 | /** |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 60 | * Starts a subscription for the given request. Updates will be notified by |
| 61 | * the controller via {@link GnmiEvent.Type#UPDATE} events. The client |
| 62 | * guarantees that a Subscription RPC is active at all times despite channel |
| 63 | * or server failures, unless {@link #unsubscribe()} is called. |
Yi Tseng | e616d75 | 2018-11-27 10:53:27 -0800 | [diff] [blame] | 64 | * |
| 65 | * @param request the subscribe request |
Yi Tseng | e616d75 | 2018-11-27 10:53:27 -0800 | [diff] [blame] | 66 | */ |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 67 | void subscribe(SubscribeRequest request); |
Yi Tseng | e616d75 | 2018-11-27 10:53:27 -0800 | [diff] [blame] | 68 | |
| 69 | /** |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 70 | * Terminates any Subscribe RPC active. |
Yi Tseng | e616d75 | 2018-11-27 10:53:27 -0800 | [diff] [blame] | 71 | */ |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 72 | void unsubscribe(); |
Yi Tseng | 890dc3f | 2018-11-01 13:23:11 -0700 | [diff] [blame] | 73 | } |