Merge "Fix bug for nslcm stop sh"
[vfc/nfvo/lcm.git] / lcm / jobs / api_model.py
1 # Copyright 2019 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from lcm.pub.base import ApiModelBase
16
17
18 class JobHistory(ApiModelBase):
19     def __init__(self, status="", progress="", statusDescription="", errorCode="", responseId=""):
20         self.status = status
21         self.progress = progress
22         self.statusDescription = statusDescription
23         self.errorCode = errorCode
24         self.responseId = responseId
25
26
27 class JobDescriptor(ApiModelBase):
28     def __init__(self, status="", progress=0, statusDescription="", errorCode="", responseId="", responseHistoryList=None, dict_str=None):
29         self.status = dict_str.get("status", "") if dict_str else status
30         self.progress = dict_str.get("progress", 0) if dict_str else progress
31         self.statusDescription = dict_str.get("statusDescription", "") if dict_str else statusDescription
32         self.errorCode = dict_str.get("errorCode", "") if dict_str else errorCode
33         self.responseId = dict_str.get("responseId", "") if dict_str else responseId
34         self.responseHistoryList = [JobHistory(job_history) for job_history in dict_str.get("responseHistoryList", None)] if dict_str else responseHistoryList
35
36
37 class JobQueryResp(ApiModelBase):
38     def __init__(self, jobId="", responseDescriptor=None, dict_str=None):
39         self.jobId = dict_str.get("jobId", "") if dict_str else jobId
40         self.responseDescriptor = JobDescriptor(dict_str=dict_str.get("responseDescriptor", None)) if dict_str else responseDescriptor
41
42
43 class JobUpdReq(ApiModelBase):
44     def __init__(self, progress="", desc="", errcode=""):
45         self.progress = progress
46         self.desc = desc
47         self.errcode = errcode
48
49
50 class JobUpdResp(ApiModelBase):
51     def __init__(self, result="", msg=""):
52         self.result = result
53         self.msg = msg