File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
src/mmw/apps/geoprocessing_api Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,18 @@ def validate_gwlfe_prepare(data):
102
102
raise ValidationError (error )
103
103
104
104
105
+ def validate_gwlfe_run (input , job_uuid ):
106
+ if not check_gwlfe_only_one ([input , job_uuid ]):
107
+ error = ('Invalid parameter: Only one type of prepared input'
108
+ '(input JSON or job_uuid) is allowed' )
109
+ raise ValidationError (error )
110
+
111
+ if not check_gwlfe_run_input (input ):
112
+ error = ("Invalid input: Please use the full result "
113
+ "of gwlf-e/prepare endpoint's result object" )
114
+ raise ValidationError (error )
115
+
116
+
105
117
def check_gwlfe_only_one (params ):
106
118
if sum (map (check_is_none , params )) == 1 :
107
119
return True
@@ -132,6 +144,11 @@ def check_streams_layer_overrides(layers):
132
144
return layers ['__STREAMS__' ] in STREAM_LAYER_OVERRIDES
133
145
134
146
147
+ def check_gwlfe_run_input (input ):
148
+ result = all (el in input for el in settings .GWLFE_DEFAULTS .keys ())
149
+ return result
150
+
151
+
135
152
def create_layer_overrides_keys_not_valid_msg (layers ):
136
153
error = 'These layers are not standard layers for layer overrides: '
137
154
for layler in layers :
Original file line number Diff line number Diff line change 45
45
46
46
from apps .geoprocessing_api .validation import (validate_rwd ,
47
47
validate_uuid ,
48
- validate_gwlfe_prepare )
48
+ validate_gwlfe_prepare ,
49
+ validate_gwlfe_run )
49
50
50
51
51
52
@swagger_auto_schema (method = 'post' ,
@@ -1707,11 +1708,12 @@ def _parse_gwlfe_input(request, raw_input=True):
1707
1708
model_input = request .data .get ('input' )
1708
1709
1709
1710
if model_input :
1710
- # TODO #3484 Validate model_input
1711
+ validate_gwlfe_run ( model_input , job_uuid )
1711
1712
return model_input , job_uuid , mods , hash
1712
1713
1713
1714
if not job_uuid :
1714
- raise ValidationError ('`job_uuid` must be specified' )
1715
+ raise ValidationError ('Either `input` or `job_uuid` '
1716
+ 'must be specified.' )
1715
1717
1716
1718
if not validate_uuid (job_uuid ):
1717
1719
raise ValidationError (f'Invalid `job_uuid`: { job_uuid } ' )
@@ -1727,5 +1729,6 @@ def _parse_gwlfe_input(request, raw_input=True):
1727
1729
1728
1730
model_input = json .loads (input_job .result )
1729
1731
1730
- # TODO #3484 Validate model_input
1732
+ validate_gwlfe_run (model_input , job_uuid )
1733
+
1731
1734
return model_input , job_uuid , mods , hash
You can’t perform that action at this time.
0 commit comments