David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 180c109 | 2017-08-03 22:46:14 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 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 | package org.opencord.sadis.cli; |
| 17 | |
Carmelo Cascone | 3405985 | 2019-09-30 19:33:00 -0700 | [diff] [blame^] | 18 | import org.apache.karaf.shell.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 22 | import org.opencord.sadis.BaseInformationService; |
| 23 | import org.opencord.sadis.SadisService; |
Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 24 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Subscriber And Device Information Service CLI. |
| 28 | */ |
Carmelo Cascone | 3405985 | 2019-09-30 19:33:00 -0700 | [diff] [blame^] | 29 | @Service |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 30 | @Command(scope = "onos", name = "sadis", description = "Subscriber And Device Information Service CLI command") |
| 31 | public class SubscriberGetCommand extends AbstractShellCommand { |
| 32 | |
| 33 | @Argument(index = 0, name = "ID", description = "subscriber ID", required = true, multiValued = false) |
| 34 | String id; |
| 35 | |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 36 | private SadisService sadisService = get(SadisService.class); |
| 37 | private BaseInformationService<SubscriberAndDeviceInformation> service = sadisService.getSubscriberInfoService(); |
Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 38 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 39 | @Override |
Carmelo Cascone | 3405985 | 2019-09-30 19:33:00 -0700 | [diff] [blame^] | 40 | protected void doExecute() { |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 41 | SubscriberAndDeviceInformation info = service.get(id); |
Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 42 | if (info != null) { |
| 43 | print(info.toString()); |
| 44 | } else { |
| 45 | print("Subscriber not found"); |
| 46 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 47 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 48 | } |