5be18e75be5c0f2c68c99100d5b14fcfd70ad08e
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs;
23
24 import java.util.Arrays;
25 import java.util.List;
26 import java.util.Optional;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
29 import org.opendaylight.yangtools.yang.common.QName;
30 import org.opendaylight.yangtools.yang.common.QNameModule;
31 import org.opendaylight.yangtools.yang.common.Revision;
32 import org.opendaylight.yangtools.yang.common.XMLNamespace;
33
34 public class ORANFM extends YangModule {
35
36     public static final String NAMESPACE = "urn:o-ran:fm:1.0";
37     public static final QNameModule ORANFM_2019_02_04 =
38             QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2019-02-04"));
39     public static final QNameModule ORANFM_2022_08_15 =
40             QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-08-15"));
41     private static final List<QNameModule> MODULES = Arrays.asList(ORANFM_2019_02_04, ORANFM_2022_08_15);
42 //    private final QName ORAN_FM_ALARM_NOTIF;
43 //    private final QName ORAN_FM_FAULT_ID;
44 //    private final QName ORAN_FM_FAULT_SOURCE;
45 //    private final QName ORAN_FM_FAULT_SEVERITY;
46 //    private final QName ORAN_FM_FAULT_TEXT;
47 //    private final QName ORAN_FM_FAULT_IS_CLEARED;
48
49
50
51     ORANFM(NetconfDomAccessor netconfDomAccessor, QNameModule module) {
52         super(netconfDomAccessor, module);
53 //        ORAN_FM_ALARM_NOTIF = QName.create(module, "alarm-notif");
54 //        ORAN_FM_FAULT_ID = QName.create(module, "fault-id");
55 //        ORAN_FM_FAULT_SOURCE = QName.create(module, "fault-source");
56 //        ORAN_FM_FAULT_SEVERITY = QName.create(module, "fault-severity");
57 //        ORAN_FM_FAULT_TEXT = QName.create(module, "fault-text");
58 //        ORAN_FM_FAULT_IS_CLEARED = QName.create(module, "is-cleared");
59     }
60
61     public QName getFaultSourceQName() {
62         return getQName("fault-source");
63     }
64
65     public QName getFaultIdQName() {
66         return getQName("fault-id");
67     }
68
69     public QName getFaultSeverityQName() {
70         return getQName("fault-severity");
71     }
72
73     public QName getFaultTextQName() {
74         return getQName("fault-text");
75     }
76
77     public QName getAlarmNotifQName() {
78         return getQName("alarm-notif");
79     }
80
81     public QName getFaultIsClearedQName() {
82         return getQName("is-cleared");
83     }
84
85     public QName getFaultEventTimeQName() {
86         return getQName("event-time");
87     }
88     
89     public QName getFaultActiveAlarmListQName() {
90         return getQName("active-alarm-list");
91     }
92     
93     public QName getFaultActiveAlarmsQName() {
94         return getQName("active-alarms");
95     }
96     
97     /**
98      * Get specific instance, depending on capabilities
99      *
100      * @param capabilities
101      * @return
102      */
103     public static Optional<ORANFM> getModule(NetconfDomAccessor netconfDomAccessor) {
104         Capabilities capabilities = netconfDomAccessor.getCapabilites();
105         for (QNameModule module : MODULES) {
106             if (capabilities.isSupportingNamespaceAndRevision(module)) {
107                 return Optional.of(new ORANFM(netconfDomAccessor, module));
108             }
109         }
110         return Optional.empty();
111     }
112
113 }