|
2 | 2 | Jobs view api for V1.
|
3 | 3 | """
|
4 | 4 |
|
| 5 | +from drf_yasg import openapi |
5 | 6 | from drf_yasg.utils import swagger_auto_schema
|
6 | 7 | from rest_framework import permissions, status
|
7 | 8 | from rest_framework.decorators import action
|
@@ -72,6 +73,64 @@ def result(self, request, pk=None):
|
72 | 73 |
|
73 | 74 | @swagger_auto_schema(
|
74 | 75 | operation_description="Update the sub status of a job",
|
| 76 | + request_body=openapi.Schema( |
| 77 | + type=openapi.TYPE_OBJECT, |
| 78 | + required=["sub_status"], |
| 79 | + properties={ |
| 80 | + "sub_status": openapi.Schema(type=openapi.TYPE_STRING) |
| 81 | + }, |
| 82 | + description="Value to populate the sub-status of a Job" |
| 83 | + ), |
| 84 | + responses={ |
| 85 | + status.HTTP_200_OK: openapi.Response( |
| 86 | + description="In case everything is ok.", |
| 87 | + schema=openapi.Schema( |
| 88 | + type=openapi.TYPE_OBJECT, |
| 89 | + properties={ |
| 90 | + "message": openapi.Schema( |
| 91 | + type=openapi.TYPE_STRING, |
| 92 | + example="Sub status updated correctly" |
| 93 | + ) |
| 94 | + } |
| 95 | + ) |
| 96 | + ), |
| 97 | + status.HTTP_400_BAD_REQUEST: openapi.Response( |
| 98 | + description="In case your request doesnt have a valid 'sub_status'.", |
| 99 | + schema=openapi.Schema( |
| 100 | + type=openapi.TYPE_OBJECT, |
| 101 | + properties={ |
| 102 | + "message": openapi.Schema( |
| 103 | + type=openapi.TYPE_STRING, |
| 104 | + example="'sub_status' not provided or is not valid" |
| 105 | + ) |
| 106 | + } |
| 107 | + ) |
| 108 | + ), |
| 109 | + status.HTTP_403_FORBIDDEN: openapi.Response( |
| 110 | + description="In case you cannot change the sub_status.", |
| 111 | + schema=openapi.Schema( |
| 112 | + type=openapi.TYPE_OBJECT, |
| 113 | + properties={ |
| 114 | + "message": openapi.Schema( |
| 115 | + type=openapi.TYPE_STRING, |
| 116 | + example="Cannot update 'sub_status' when is not in RUNNING status. (Currently PENDING)" |
| 117 | + ) |
| 118 | + } |
| 119 | + ) |
| 120 | + ), |
| 121 | + status.HTTP_404_NOT_FOUND: openapi.Response( |
| 122 | + description="In case the job doesnt exist or you dont have access to it.", |
| 123 | + schema=openapi.Schema( |
| 124 | + type=openapi.TYPE_OBJECT, |
| 125 | + properties={ |
| 126 | + "message": openapi.Schema( |
| 127 | + type=openapi.TYPE_STRING, |
| 128 | + example="Job [XXXX] not found" |
| 129 | + ) |
| 130 | + } |
| 131 | + ) |
| 132 | + ) |
| 133 | + }, |
75 | 134 | )
|
76 | 135 | @action(methods=["POST"], detail=True)
|
77 | 136 | def sub_status(self, request, pk=None):
|
|
0 commit comments