Updating RMR version to 4.8.5
[ric-plt/alarm-go.git] / alarm / types.go
1 /*
2  *  Copyright (c) 2020 AT&T Intellectual Property.
3  *  Copyright (c) 2020 Nokia.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
18  * platform project (RICP).
19  */
20
21 package alarm
22
23 import (
24         "fmt"
25         "os"
26         "sync"
27         "unsafe"
28 )
29
30 import "C"
31
32 // Severity for alarms
33 type Severity string
34
35 // Possible values for Severity
36 const (
37         SeverityUnspecified Severity = "UNSPECIFIED"
38         SeverityCritical    Severity = "CRITICAL"
39         SeverityMajor       Severity = "MAJOR"
40         SeverityMinor       Severity = "MINOR"
41         SeverityWarning     Severity = "WARNING"
42         SeverityCleared     Severity = "CLEARED"
43         SeverityDefault     Severity = "DEFAULT"
44 )
45
46 // Alarm object - see README for more information
47 type Alarm struct {
48         ManagedObjectId   string   `json:"managedObjectId"`
49         ApplicationId     string   `json:"applicationId"`
50         SpecificProblem   int      `json:"specificProblem"`
51         PerceivedSeverity Severity `json:"perceivedSeverity"`
52         IdentifyingInfo   string   `json:"identifyingInfo"`
53         AdditionalInfo    string   `json:"additionalInfo"`
54 }
55
56 // Alarm actions
57 type AlarmAction string
58
59 // Possible values for alarm actions
60 const (
61         AlarmActionRaise    AlarmAction = "RAISE"
62         AlarmActionClear    AlarmAction = "CLEAR"
63         AlarmActionClearAll AlarmAction = "CLEARALL"
64 )
65
66 type AlarmMessage struct {
67         Alarm
68         AlarmAction
69         AlarmTime int64
70 }
71
72 type AlarmConfigParams struct {
73         MaxActiveAlarms int `json:"maxactivealarms"`
74         MaxAlarmHistory int `json:"maxalarmhistory"`
75 }
76
77 // RICAlarm is an alarm instance
78 type RICAlarm struct {
79         moId        string
80         appId       string
81         managerUrl  string
82         rmrEndpoint string
83         rmrCtx      unsafe.Pointer
84         rmrReady    bool
85         mutex       sync.Mutex
86 }
87
88 const (
89         RIC_ALARM_UPDATE = 13111
90         RIC_ALARM_QUERY  = 13112
91 )
92
93 // Temp alarm constants & definitions
94 const (
95         E2_CONNECTION_PROBLEM              int = 72004
96         ACTIVE_ALARM_EXCEED_MAX_THRESHOLD  int = 72007
97         ALARM_HISTORY_EXCEED_MAX_THRESHOLD int = 72008
98 )
99
100 type AlarmDefinition struct {
101         AlarmId               int    `json:"alarmId"`
102         AlarmText             string `json:"alarmText"`
103         EventType             string `json:"eventType"`
104         OperationInstructions string `json:"operationInstructions"`
105         RaiseDelay            int    `json:"raiseDelay"`
106         ClearDelay            int    `json:"clearDelay"`
107         TimeToLive            int    `json:"timeToLive"`
108 }
109
110 var RICAlarmDefinitions map[int]*AlarmDefinition
111 var RICPerfAlarmObjects map[int]*Alarm
112
113 var (
114         namespace                     = os.Getenv("PLT_NAMESPACE")
115         ALARM_MANAGER_HTTP_URL string = fmt.Sprintf("http://service-%s-alarmmanager-http.%s:8080", namespace, namespace)
116         ALARM_MANAGER_RMR_URL  string = fmt.Sprintf("service-%s-alarmmanager-rmr.%s:4560", namespace, namespace)
117 )