blob: b698d56c872187aaf9235bc9f2d34aa95b8b9851 [file] [log] [blame]
Sean Condon87b78502018-09-17 20:53:24 +01001/*
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
17package org.onosproject.faultmanagement.alarms.cli.completer;
18
Ray Milkeydf521292018-10-04 15:13:33 -070019import org.apache.karaf.shell.api.action.lifecycle.Service;
Sean Condon87b78502018-09-17 20:53:24 +010020import org.onosproject.cli.AbstractChoicesCompleter;
21import org.onosproject.faultmanagement.alarms.cli.UpdateAlarm;
22
23import java.time.Instant;
24import java.util.ArrayList;
25import java.util.List;
26
27/**
28 * CLI completer for Alarm Field values.
29 */
Ray Milkeydf521292018-10-04 15:13:33 -070030@Service
Sean Condon87b78502018-09-17 20:53:24 +010031public class AlarmFieldValueCompleter extends AbstractChoicesCompleter {
32 @Override
33 protected List<String> choices() {
34
35 List<String> choices = new ArrayList<>();
Ray Milkeydf521292018-10-04 15:13:33 -070036 UpdateAlarm.AlarmField field = UpdateAlarm.AlarmField.valueOf(commandLine.getArguments()[2]);
Sean Condon87b78502018-09-17 20:53:24 +010037
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}