resolve job issues
[vfc/nfvo/lcm.git] / lcm / jobs / serializers.py
1 # Copyright 2018 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 rest_framework import serializers
16
17
18 class JobHistorySerializer(serializers.Serializer):
19     status = serializers.CharField(
20         help_text="Status of job",
21         required=True)
22     progress = serializers.CharField(
23         help_text="Progress of job",
24         required=True)
25     statusDescription = serializers.CharField(
26         help_text="Description of job",
27         required=False,
28         allow_null=True)
29     errorCode = serializers.CharField(
30         help_text="Error code of job",
31         required=False,
32         allow_null=True)
33     responseId = serializers.CharField(
34         help_text="Response index of job",
35         required=True)
36
37
38 class JobDescriptorSerializer(serializers.Serializer):
39     status = serializers.CharField(
40         help_text="Status of job",
41         required=True)
42     # progress = serializers.CharField(help_text="Progress of job", required=True)
43     progress = serializers.IntegerField(
44         help_text="Progress of job",
45         required=True)
46     statusDescription = serializers.CharField(
47         help_text="Description of job",
48         required=False,
49         allow_null=True)
50     errorCode = serializers.CharField(
51         help_text="Error code of job",
52         required=False,
53         allow_null=True)
54     responseId = serializers.CharField(
55         help_text="Response index of job",
56         required=True)
57     responseHistoryList = JobHistorySerializer(
58         help_text="History of job",
59         many=True)
60
61
62 class JobQueryRespSerializer(serializers.Serializer):
63     jobId = serializers.CharField(
64         help_text="UUID of job",
65         required=True)
66     responseDescriptor = JobDescriptorSerializer(
67         help_text="Descriptor of job",
68         required=False)
69
70
71 class JobUpdReqSerializer(serializers.Serializer):
72     progress = serializers.CharField(
73         help_text="Progress of job",
74         required=True)
75     desc = serializers.CharField(
76         help_text="Description of job",
77         required=False)
78     errcode = serializers.CharField(
79         help_text="Error code of job",
80         required=False)
81
82
83 class JobUpdRespSerializer(serializers.Serializer):
84     result = serializers.CharField(
85         help_text="Result of the job",
86         required=True)
87     msg = serializers.CharField(
88         help_text="Detail of the job",
89         required=False)