Remove unused code
[nonrtric/plt/ranpm.git] / pm-file-converter / common / dataTypes / dataTypes.go
1 // -
2 //
3 //      ========================LICENSE_START=================================
4 //      O-RAN-SC
5 //      %%
6 //      Copyright (C) 2023: Nordix Foundation
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 package dataTypes
22
23 import (
24         "encoding/xml"
25         "github.com/confluentinc/confluent-kafka-go/kafka"
26 )
27
28 // // Data type for event xml file download
29 type XmlFileEventHeader struct {
30         ProductName        string `json:"productName"`
31         VendorName         string `json:"vendorName"`
32         Location           string `json:"location"`
33         Compression        string `json:"compression"`
34         SourceName         string `json:"sourceName"`
35         FileFormatType     string `json:"fileFormatType"`
36         FileFormatVersion  string `json:"fileFormatVersion"`
37         StartEpochMicrosec int64  `json:"startEpochMicrosec"`
38         LastEpochMicrosec  int64  `json:"lastEpochMicrosec"`
39         Name               string `json:"name"`
40         ChangeIdentifier   string `json:"changeIdentifier"`
41         InternalLocation   string `json:"internalLocation"`
42         TimeZoneOffset     string `json:"timeZoneOffset"`
43         ObjectStoreBucket  string `json:"objectStoreBucket"`
44 }
45
46 // Data types for input xml file
47 type MeasCollecFile struct {
48         XMLName        xml.Name `xml:"measCollecFile"`
49         Text           string   `xml:",chardata"`
50         Xmlns          string   `xml:"xmlns,attr"`
51         Xsi            string   `xml:"xsi,attr"`
52         SchemaLocation string   `xml:"schemaLocation,attr"`
53         FileHeader     struct {
54                 Text              string `xml:",chardata"`
55                 FileFormatVersion string `xml:"fileFormatVersion,attr"`
56                 VendorName        string `xml:"vendorName,attr"`
57                 DnPrefix          string `xml:"dnPrefix,attr"`
58                 FileSender        struct {
59                         Text        string `xml:",chardata"`
60                         LocalDn     string `xml:"localDn,attr"`
61                         ElementType string `xml:"elementType,attr"`
62                 } `xml:"fileSender"`
63                 MeasCollec struct {
64                         Text      string `xml:",chardata"`
65                         BeginTime string `xml:"beginTime,attr"`
66                 } `xml:"measCollec"`
67         } `xml:"fileHeader"`
68         MeasData struct {
69                 Text           string `xml:",chardata"`
70                 ManagedElement struct {
71                         Text      string `xml:",chardata"`
72                         LocalDn   string `xml:"localDn,attr"`
73                         SwVersion string `xml:"swVersion,attr"`
74                 } `xml:"managedElement"`
75                 MeasInfo []struct {
76                         Text       string `xml:",chardata"`
77                         MeasInfoId string `xml:"measInfoId,attr"`
78                         Job        struct {
79                                 Text  string `xml:",chardata"`
80                                 JobId string `xml:"jobId,attr"`
81                         } `xml:"job"`
82                         GranPeriod struct {
83                                 Text     string `xml:",chardata"`
84                                 Duration string `xml:"duration,attr"`
85                                 EndTime  string `xml:"endTime,attr"`
86                         } `xml:"granPeriod"`
87                         RepPeriod struct {
88                                 Text     string `xml:",chardata"`
89                                 Duration string `xml:"duration,attr"`
90                         } `xml:"repPeriod"`
91                         MeasType []struct {
92                                 Text string `xml:",chardata"`
93                                 P    string `xml:"p,attr"`
94                         } `xml:"measType"`
95                         MeasValue []struct {
96                                 Text       string `xml:",chardata"`
97                                 MeasObjLdn string `xml:"measObjLdn,attr"`
98                                 R          []struct {
99                                         Text string `xml:",chardata"`
100                                         P    string `xml:"p,attr"`
101                                 } `xml:"r"`
102                                 Suspect string `xml:"suspect"`
103                         } `xml:"measValue"`
104                 } `xml:"measInfo"`
105         } `xml:"measData"`
106         FileFooter struct {
107                 Text       string `xml:",chardata"`
108                 MeasCollec struct {
109                         Text    string `xml:",chardata"`
110                         EndTime string `xml:"endTime,attr"`
111                 } `xml:"measCollec"`
112         } `xml:"fileFooter"`
113 }
114
115 // Splitted in sevreal part to allow add/remove in lists
116 type MeasResults struct {
117         P      int    `json:"p"`
118         SValue string `json:"sValue"`
119 }
120
121 type MeasValues struct {
122         MeasObjInstID   string        `json:"measObjInstId"`
123         SuspectFlag     string        `json:"suspectFlag"`
124         MeasResultsList []MeasResults `json:"measResults"`
125 }
126
127 type SMeasTypes struct {
128         SMeasType string `json:"sMeasTypesList"`
129 }
130
131 type MeasInfoList struct {
132         MeasInfoID struct {
133                 SMeasInfoID string `json:"sMeasInfoId"`
134         } `json:"measInfoId"`
135         MeasTypes struct {
136                 SMeasTypesList []string `json:"sMeasTypesList"`
137         } `json:"measTypes"`
138         MeasValuesList []MeasValues `json:"measValuesList"`
139 }
140
141 type PMJsonFile struct {
142         Event struct {
143                 CommonEventHeader struct {
144                         Domain                  string `json:"domain"`
145                         EventID                 string `json:"eventId"`
146                         Sequence                int    `json:"sequence"`
147                         EventName               string `json:"eventName"`
148                         SourceName              string `json:"sourceName"`
149                         ReportingEntityName     string `json:"reportingEntityName"`
150                         Priority                string `json:"priority"`
151                         StartEpochMicrosec      int64  `json:"startEpochMicrosec"`
152                         LastEpochMicrosec       int64  `json:"lastEpochMicrosec"`
153                         Version                 string `json:"version"`
154                         VesEventListenerVersion string `json:"vesEventListenerVersion"`
155                         TimeZoneOffset          string `json:"timeZoneOffset"`
156                 } `json:"commonEventHeader"`
157                 Perf3GppFields struct {
158                         Perf3GppFieldsVersion string `json:"perf3gppFieldsVersion"`
159                         MeasDataCollection    struct {
160                                 GranularityPeriod             int            `json:"granularityPeriod"`
161                                 MeasuredEntityUserName        string         `json:"measuredEntityUserName"`
162                                 MeasuredEntityDn              string         `json:"measuredEntityDn"`
163                                 MeasuredEntitySoftwareVersion string         `json:"measuredEntitySoftwareVersion"`
164                                 SMeasInfoList                 []MeasInfoList `json:"measInfoList"`
165                         } `json:"measDataCollection"`
166                 } `json:"perf3gppFields"`
167         } `json:"event"`
168 }
169
170 type FileDownloadedEvt struct {
171         Filename string `json:"filename"`
172 }
173
174 type KafkaPayload struct {
175         Msg   *kafka.Message
176         Topic string
177 }
178
179 // Type for controlling the topic reader
180 type ReaderControl struct {
181         Command string
182 }
183
184 // Type for controlling the topic writer
185 type WriterControl struct {
186         Command string
187 }
188
189 // == API Datatypes ==//
190 // Type for supported data types
191 type DataType struct {
192         ID                 string `json:"id"`
193         KafkaInputTopic    string `json:"kafkaInputTopic"`
194         InputJobType       string `json:inputJobType`
195         InputJobDefinition struct {
196                 KafkaOutputTopic string `json:kafkaOutputTopic`
197         } `json:inputJobDefinition`
198
199         Ext_job         *[]byte
200         Ext_job_created bool
201         Ext_job_id      string
202 }
203
204 // Type for controlling the job
205 type JobControl struct {
206         Command string
207         //Filter  Filter
208 }
209
210 type AppStates int64
211
212 var InfoTypes DataTypes
213
214 // Keep all info type jobs, key == type id
215 var TypeJobs map[string]TypeJobRecord = make(map[string]TypeJobRecord)
216
217 // Type for an infojob
218 type TypeJobRecord struct {
219         InfoType        string
220         InputTopic      string
221         Data_in_channel chan *KafkaPayload
222         Reader_control  chan ReaderControl
223         Job_control     chan JobControl
224         GroupId         string
225         ClientId        string
226 }
227
228 type DataTypes struct {
229         ProdDataTypes []DataType `json:"types"`
230 }