1388f14a75dcf07c087ec2714c467d5aea7da20b
[ric-plt/e2mgr.git] / E2Manager / models / ric_service_update_ack_message.go
1 //
2 // Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
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 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 //  platform project (RICP).
18
19 package models
20
21 import (
22         "encoding/xml"
23 )
24
25 type RicServiceAckRANFunctionIDItem struct {
26         Text                string `xml:",chardata"`
27         RanFunctionID       uint32 `xml:"ranFunctionID"`
28         RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
29 }
30
31 type RICserviceUpdateAcknowledgeProtocolIESingleContainer struct {
32                 Text        string `xml:",chardata"`
33                 Id          string `xml:"id"`
34                 Criticality struct {
35                                 Text   string `xml:",chardata"`
36                                 //Ignore string `xml:"ignore"`
37                                 Reject string `xml:"reject"`
38                 } `xml:"criticality"`
39                 Value struct {
40                                 Text              string `xml:",chardata"`
41                                 RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"`
42                 } `xml:"value"`
43 }
44
45 type RICserviceUpdateAcknowledgeIEs struct {
46         Text        string `xml:",chardata"`
47         ID          string `xml:"id"`
48         Criticality struct {
49                 Text   string `xml:",chardata"`
50                 Reject string `xml:"reject"`
51         } `xml:"criticality"`
52         Value struct {
53                 Text   string `xml:",chardata"`
54                 RANfunctionsIDList struct {
55                         Text   string `xml:",chardata"`
56                         ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
57                 } `xml:"RANfunctionsID-List"`
58         }`xml:"value"`
59 }
60
61 type RicServiceUpdateAckSuccessfulOutcome struct {
62         XMLName xml.Name        `xml:"successfulOutcome"`
63         Text          string `xml:",chardata"`
64         ProcedureCode string `xml:"procedureCode"`
65         Criticality   struct {
66                 Text   string `xml:",chardata"`
67                 Reject string `xml:"reject"`
68         } `xml:"criticality"`
69         Value struct {
70                 Text            string `xml:",chardata"`
71                 RICserviceUpdateAcknowledge  RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
72         } `xml:"value"`
73 }
74
75 type RICserviceUpdateAcknowledge struct {
76         Text        string `xml:",chardata"`
77         ProtocolIEs struct {
78                 Text               string `xml:",chardata"`
79                 RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
80         } `xml:"protocolIEs"`
81 }
82
83 type RicServiceUpdateAckE2APPDU struct {
84         XMLName xml.Name `xml:"E2AP-PDU"`
85         Text    string `xml:",chardata"`
86         InitiatingMessage interface{}
87 }
88
89 func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem) RicServiceUpdateAckE2APPDU {
90         successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{}
91         successfulOutcome.ProcedureCode = "7"
92         if len(ricServiceUpdate) == 0 {
93                 return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
94         }
95
96         ricServiceUpdateAcknowledgeIEs := make([]RICserviceUpdateAcknowledgeIEs, 1)
97         ricServiceUpdateAcknowledgeIEs[0].ID = "9"
98         protocolIESingleContainer := make([]RICserviceUpdateAcknowledgeProtocolIESingleContainer, len(ricServiceUpdate))
99         for i := 0; i < len(ricServiceUpdate); i++ {
100                 protocolIESingleContainer[i].Value.RANfunctionIDItem = ricServiceUpdate[i]
101                 protocolIESingleContainer[i].Id = "6"
102         }
103         ricServiceUpdateAcknowledgeIEs[0].Value.RANfunctionsIDList.ProtocolIESingleContainer = protocolIESingleContainer
104         successfulOutcome.Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs = ricServiceUpdateAcknowledgeIEs
105         return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
106 }
107