a4ef8b9fa648f5f12108bc6571d8727da6862a2f
[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
43     ORANFM(NetconfDomAccessor netconfDomAccessor, QNameModule module) {
44         super(netconfDomAccessor, module);
45     }
46
47     public QName getFaultSourceQName() {
48         return getQName("fault-source");
49     }
50
51     public QName getFaultIdQName() {
52         return getQName("fault-id");
53     }
54
55     public QName getFaultSeverityQName() {
56         return getQName("fault-severity");
57     }
58
59     public QName getFaultTextQName() {
60         return getQName("fault-text");
61     }
62
63     public QName getAlarmNotifQName() {
64         return getQName("alarm-notif");
65     }
66
67     public QName getFaultIsClearedQName() {
68         return getQName("is-cleared");
69     }
70
71     public QName getFaultEventTimeQName() {
72         return getQName("event-time");
73     }
74
75     public QName getFaultActiveAlarmListQName() {
76         return getQName("active-alarm-list");
77     }
78
79     public QName getFaultActiveAlarmsQName() {
80         return getQName("active-alarms");
81     }
82
83     /**
84      * Get specific instance, depending on capabilities
85      *
86      * @param capabilities
87      * @return
88      */
89     public static Optional<ORANFM> getModule(NetconfDomAccessor netconfDomAccessor) {
90         Capabilities capabilities = netconfDomAccessor.getCapabilites();
91         for (QNameModule module : MODULES) {
92             if (capabilities.isSupportingNamespaceAndRevision(module)) {
93                 return Optional.of(new ORANFM(netconfDomAccessor, module));
94             }
95         }
96         return Optional.empty();
97     }
98
99 }