def validate_parameters( # pylint: disable=too-many-return-statements self, ) -> FlaskResponse: """validates database connection parameters --- post: description: >- Validates parameters used to connect to a database requestBody: description: DB-specific parameters required: true content: application/json: schema: $ref: "#/components/schemas/DatabaseValidateParametersSchema" responses: 200: description: Database Test Connection content: application/json: schema: type: object properties: message: type: string 400: $ref: '#/components/responses/400' 422: $ref: '#/components/responses/422' 500: $ref: '#/components/responses/500' """ if not request.is_json: raise InvalidPayloadFormatError("Request is not JSON") try: payload = DatabaseValidateParametersSchema().load(request.json) except ValidationError as error: errors = [ SupersetError( message="\n".join(messages), error_type=SupersetErrorType.INVALID_PAYLOAD_SCHEMA_ERROR, level=ErrorLevel.ERROR, extra={"invalid": [attribute]}, ) for attribute, messages in error.messages.items() ] raise InvalidParametersError(errors) command = ValidateDatabaseParametersCommand(g.user, payload) command.run() return self.response(200, message="OK")
def validate_parameters( # pylint: disable=too-many-return-statements self, ) -> FlaskResponse: """validates database connection parameters --- post: description: >- Validates parameters used to connect to a database requestBody: description: DB-specific parameters required: true content: application/json: schema: $ref: "#/components/schemas/DatabaseValidateParametersSchema" responses: 200: description: Database Test Connection content: application/json: schema: type: object properties: message: type: string 400: $ref: '#/components/responses/400' 422: $ref: '#/components/responses/422' 500: $ref: '#/components/responses/500' """ if not request.is_json: raise InvalidPayloadFormatError("Request is not JSON") try: payload = DatabaseValidateParametersSchema().load(request.json) except ValidationError as error: raise InvalidPayloadSchemaError(error) command = ValidateDatabaseParametersCommand(g.user, payload) command.run() return self.response(200, message="OK")