blob: c32be06eae4548e20d0421a9d57199de415ea086 [file] [log] [blame]
Boyuan Yana00e3d02019-04-10 23:43:12 -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 * This work was partially supported by EC H2020 project METRO-HAUL (761727).
17 */
18package org.onosproject.cli.net;
19
20import org.apache.karaf.shell.api.action.lifecycle.Service;
21import org.apache.karaf.shell.api.console.CommandLine;
22import org.apache.karaf.shell.api.console.Completer;
23import org.apache.karaf.shell.api.console.Session;
24import org.apache.karaf.shell.support.completers.StringsCompleter;
25
26import java.util.List;
27import java.util.SortedSet;
28
29/**
30 * Netconf Operation Completer.
31 */
32@Service
33public class NetconfOperationCompleter implements Completer {
34
35 @Override
36 public int complete(Session session, CommandLine commandLine, List<String> candidates) {
37 // Delegate string completer
38 StringsCompleter delegate = new StringsCompleter();
39 SortedSet<String> strings = delegate.getStrings();
40 // The available operations are defined in NETCONF protocol (https://tools.ietf.org/html/rfc6241#section-7).
41 strings.add("get");
42 strings.add("get-config");
43 strings.add("edit-config");
44 strings.add("copy-config");
45 strings.add("delete-config");
46 strings.add("lock");
47 strings.add("unlock");
48 strings.add("close-session");
49 strings.add("kill-session");
50 return delegate.complete(session, commandLine, candidates);
51 }
52
53}