Squash-merging e2ap-v2.0 branch
[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 interface{} `xml:"value"`
53 }
54
55 type RICserviceUpdateAcknowledgeTransactionID struct {
56         Text          string `xml:",chardata"`
57         TransactionID string `xml:"TransactionID"`
58 }
59
60 type RICserviceUpdateAcknowledgeRANfunctionsList struct {
61         Text               string `xml:",chardata"`
62         RANfunctionsIDList struct {
63                 Text                      string                                                 `xml:",chardata"`
64                 ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
65         } `xml:"RANfunctionsID-List"`
66 }
67 type RicServiceUpdateAckSuccessfulOutcome struct {
68         XMLName       xml.Name `xml:"successfulOutcome"`
69         Text          string   `xml:",chardata"`
70         ProcedureCode string   `xml:"procedureCode"`
71         Criticality   struct {
72                 Text   string `xml:",chardata"`
73                 Reject string `xml:"reject"`
74         } `xml:"criticality"`
75         Value struct {
76                 Text                        string                      `xml:",chardata"`
77                 RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
78         } `xml:"value"`
79 }
80
81 type RICserviceUpdateAcknowledge struct {
82         Text        string `xml:",chardata"`
83         ProtocolIEs struct {
84                 Text                           string                           `xml:",chardata"`
85                 RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
86         } `xml:"protocolIEs"`
87 }
88
89 type RicServiceUpdateAckE2APPDU struct {
90         XMLName           xml.Name `xml:"E2AP-PDU"`
91         Text              string   `xml:",chardata"`
92         SuccessfulOutcome interface{}
93 }
94
95 func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem, txId string) RicServiceUpdateAckE2APPDU {
96
97         txIE := RICserviceUpdateAcknowledgeIEs{
98                 ID: ProtocolIE_ID_id_TransactionID,
99                 Value: RICserviceUpdateAcknowledgeTransactionID{
100                         TransactionID: txId,
101                 },
102         }
103
104         protocolIESingleContainer := make([]RICserviceUpdateAcknowledgeProtocolIESingleContainer, len(ricServiceUpdate))
105         for i := 0; i < len(ricServiceUpdate); i++ {
106                 protocolIESingleContainer[i].Value.RANfunctionIDItem = ricServiceUpdate[i]
107                 protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item
108         }
109
110         // mandatory RANFunctionsAccepted
111         functionListIE := RICserviceUpdateAcknowledgeIEs{
112                 ID: ProtocolIE_ID_id_RANfunctionsAccepted,
113                 Value: RICserviceUpdateAcknowledgeRANfunctionsList{
114                         RANfunctionsIDList: struct {
115                                 Text                      string                                                 `xml:",chardata"`
116                                 ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
117                         }{
118                                 ProtocolIESingleContainer: protocolIESingleContainer,
119                         },
120                 },
121         }
122
123         successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{
124                 ProcedureCode: ProcedureCode_id_RICserviceUpdate,
125                 Value: struct {
126                         Text                        string                      `xml:",chardata"`
127                         RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
128                 }{
129                         RICserviceUpdateAcknowledge: RICserviceUpdateAcknowledge{
130                                 ProtocolIEs: struct {
131                                         Text                           string                           `xml:",chardata"`
132                                         RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
133                                 }{
134                                         RICserviceUpdateAcknowledgeIEs: []RICserviceUpdateAcknowledgeIEs{txIE, functionListIE},
135                                 },
136                         },
137                 },
138         }
139
140         return RicServiceUpdateAckE2APPDU{SuccessfulOutcome: successfulOutcome}
141 }