Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [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.faultmanagement.alarms.cli.completer; |
| 18 | |
Ray Milkey | df52129 | 2018-10-04 15:13:33 -0700 | [diff] [blame] | 19 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 20 | import org.onosproject.cli.AbstractChoicesCompleter; |
| 21 | import org.onosproject.faultmanagement.alarms.cli.UpdateAlarm; |
| 22 | |
| 23 | import java.time.Instant; |
| 24 | import java.util.ArrayList; |
| 25 | import java.util.List; |
| 26 | |
| 27 | /** |
| 28 | * CLI completer for Alarm Field values. |
| 29 | */ |
Ray Milkey | df52129 | 2018-10-04 15:13:33 -0700 | [diff] [blame] | 30 | @Service |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 31 | public class AlarmFieldValueCompleter extends AbstractChoicesCompleter { |
| 32 | @Override |
| 33 | protected List<String> choices() { |
| 34 | |
| 35 | List<String> choices = new ArrayList<>(); |
Ray Milkey | df52129 | 2018-10-04 15:13:33 -0700 | [diff] [blame] | 36 | UpdateAlarm.AlarmField field = UpdateAlarm.AlarmField.valueOf(commandLine.getArguments()[2]); |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 37 | |
| 38 | switch (field) { |
| 39 | case ACKNOWLEDGED: |
| 40 | case MANUALLY_CLEARABLE: |
| 41 | case SERVICE_AFFECTING: |
| 42 | choices.add("TRUE"); |
| 43 | choices.add("FALSE"); |
| 44 | return choices; |
| 45 | case TIME_CLEARED: |
| 46 | case TIME_UPDATED: |
| 47 | choices.add(Instant.now().toString()); |
| 48 | default: |
| 49 | return choices; |
| 50 | } |
| 51 | } |
| 52 | } |