c472ca687b20c84fac6da3a5428ff7d652f4e213
[osm/common.git] / osm_common / dataclasses / temporal_dataclasses.py
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
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
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 from dataclasses import dataclass
19 from enum import auto, IntEnum
20
21 #######################################################################################
22 # Workflow Dataclasses
23
24
25 @dataclass
26 class VimOperationInput:
27 """
28 Input dataclass for workflows that perform operations
29 (create, update, delete) on VIMs.
30
31 Attributes:
32 -----------
33 vim_uuid : str
34 The UUID of the VIM account as stored in the OSM vim
35 collection in Mongo
36
37 op_id: str
38 The operation (task) id for this workflow. This is used
39 by the workflow at the end to update the status of the
40 operation in Mongo vim collection.
41 """
42
43 vim_uuid: str
44 op_id: str
45
46
47 @dataclass
48 class NsLcmOperationInput:
49 """
50 Input dataclass for workflows that run as LCM operations.
51
52 Attributes:
53 -----------
54
55 nslcmop: dict
56 A dictionary representing the nslcmop record from the
57 database.
58 """
59
60 nslcmop: dict
61
62
63 #######################################################################################
64 # Activity Dataclasses
65
66
67 class LcmOperationState(IntEnum):
68 PROCESSING = auto()
69 COMPLETED = auto()
70 FAILED = auto()
71
72
73 @dataclass
74 class UpdateLcmOperationStateInput:
75 """
76 Input dataclass for updating LCM Operations in the Mongo nslcmops
77 collection. The following attributes will be updated automatically
78 - statusEnteredTime
79 - _admin.modified
80
81 Attributes:
82 -----------
83 op_id: str
84 The operation (task) id for this activity. This is the key
85 to the record in nslcmops collection that will be updated.
86
87 op_state : LcmOperationState
88 A representation of the state of the specified operation id,
89 such as PROCESSING, COMPLETED, or FAILED.
90
91 stage: str
92 Human readable checkpoint message, intended only to give the
93 user feedback.
94
95 error_message: str
96 Human readable error message if any failure occurred.
97
98 detailed_status : str
99 Human readable message providing additional details to the
100 operation state, such as the error message explaining why
101 the operation failed.
102 """
103
104 op_id: str
105 op_state: LcmOperationState
106 stage: str
107 error_message: str
108 detailed_status: str
109
110
111 @dataclass
112 class TestVimConnectivityInput:
113 """
114 Input dataclass for the Test Vim Connectivity Ativity
115
116 Attributes:
117 -----------
118 vim_uuid : str
119 The UUID of the VIM account as stored in the OSM vim
120 collection in Mongo
121 """
122
123 vim_uuid: str
124
125
126 class VimState(IntEnum):
127 PROCESSING = auto()
128 ENABLED = auto()
129 ERROR = auto()
130
131
132 @dataclass
133 class UpdateVimStateInput:
134 """
135 Input dataclass for updating VIM state in the DB
136
137 Attributes:
138 -----------
139 vim_uuid : str
140 The UUID of the VIM account as stored in the OSM vim
141 collection in Mongo
142
143 operational_state : VimState
144 A representation of the operational state (ENABLED or ERROR)
145 of the VIM.
146
147 message : str
148 Human readable message providing additional details to the
149 operational state, such as the error message associated
150 with the ERROR operational_state.
151 """
152
153 vim_uuid: str
154 operational_state: VimState
155 message: str
156
157
158 class VimOperationState(IntEnum):
159 COMPLETED = auto()
160 FAILED = auto()
161
162
163 @dataclass
164 class UpdateVimOperationStateInput:
165 """
166 Input dataclass for updating VIM Operations in the Mongo VIM
167 collection.
168
169 Attributes:
170 -----------
171 vim_uuid : str
172 The UUID of the VIM account as stored in the OSM vim
173 collection in Mongo
174
175 op_id: str
176 The operation (task) id for this workflow. This is used
177 to update the status of the operation in Mongo vim collection.
178
179 op_state : VimOperationState
180 A representation of the state of the specified operation id,
181 such as COMPLETED, or FAILED.
182
183 message : str
184 Human readable message providing additional details to the
185 operation state, such as the error message explaining why
186 the operation failed.
187 """
188
189 vim_uuid: str
190 op_id: str
191 op_state: VimOperationState
192 message: str
193
194
195 @dataclass
196 class DeleteVimInput:
197 """
198 Input dataclass for deleting vim record from the database
199
200 Attributes:
201 -----------
202 vim_uuid : str
203 The UUID of the VIM account as stored in the OSM vim
204 collection in Mongo
205
206 """
207
208 vim_uuid: str