blob: 81130a2f6ed6f484f42391130c476b76ae640f28 [file] [log] [blame]
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07001/*
Brian O'Connor180c1092017-08-03 22:46:14 -07002 * Copyright 2017-present Open Networking Foundation
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07003 *
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 */
16package org.opencord.sadis.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
Gamze Abaka1e5ccf52018-07-02 11:59:03 +000021import org.opencord.sadis.BaseInformationService;
22import org.opencord.sadis.SadisService;
Deepa vaddireddy386f38b2017-08-02 06:24:01 +000023import org.opencord.sadis.SubscriberAndDeviceInformation;
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070024
25/**
26 * Subscriber And Device Information Service CLI.
27 */
28@Command(scope = "onos", name = "sadis", description = "Subscriber And Device Information Service CLI command")
29public class SubscriberGetCommand extends AbstractShellCommand {
30
31 @Argument(index = 0, name = "ID", description = "subscriber ID", required = true, multiValued = false)
32 String id;
33
Gamze Abaka1e5ccf52018-07-02 11:59:03 +000034 private SadisService sadisService = get(SadisService.class);
35 private BaseInformationService<SubscriberAndDeviceInformation> service = sadisService.getSubscriberInfoService();
Deepa vaddireddy386f38b2017-08-02 06:24:01 +000036
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070037 @Override
38 protected void execute() {
Gamze Abaka1e5ccf52018-07-02 11:59:03 +000039 SubscriberAndDeviceInformation info = service.get(id);
Deepa vaddireddy386f38b2017-08-02 06:24:01 +000040 if (info != null) {
41 print(info.toString());
42 } else {
43 print("Subscriber not found");
44 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070045 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070046}