/**
 * NOTE: This class is auto generated by the swagger code generator program (2.4.16).
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */
package com.sequenceiq.mock.swagger.v43.api;

import com.sequenceiq.mock.swagger.model.ApiEcho;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2021-04-23T12:05:48.864+02:00")

@Api(value = "ToolsResource", description = "the ToolsResource API")
@RequestMapping(value = "/{mockUuid}/api/v43")
public interface ToolsResourceApi {

    Logger log = LoggerFactory.getLogger(ToolsResourceApi.class);

    default Optional<ObjectMapper> getObjectMapper() {
        return Optional.empty();
    }

    default Optional<HttpServletRequest> getRequest() {
        return Optional.empty();
    }

    default Optional<String> getAcceptHeader() {
        return getRequest().map(r -> r.getHeader("Accept"));
    }

    @ApiOperation(value = "Echoes the provided message back to the caller.", nickname = "echo", notes = "Echoes the provided message back to the caller.", response = ApiEcho.class, authorizations = {
        @Authorization(value = "basic")
    }, tags={ "ToolsResource", })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "The original message", response = ApiEcho.class) })
    @RequestMapping(value = "/tools/echo",
        produces = { "application/json" }, 
        method = RequestMethod.GET)
    default ResponseEntity<ApiEcho> echo(@ApiParam(value = "The unique id of CB cluster (works in CB test framework only)",required=true) @PathVariable("mockUuid") String mockUuid,@ApiParam(value = "The message to echo back", defaultValue = "Hello, World!") @Valid @RequestParam(value = "message", required = false, defaultValue="Hello, World!") String message) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
            if (getAcceptHeader().get().contains("application/json")) {
                try {
                    return new ResponseEntity<>(getObjectMapper().get().readValue("{  \"message\" : \"...\"}", ApiEcho.class), HttpStatus.NOT_IMPLEMENTED);
                } catch (IOException e) {
                    log.error("Couldn't serialize response for content type application/json", e);
                    return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default ToolsResourceApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }


    @ApiOperation(value = "Throws an error containing the given input message.", nickname = "echoError", notes = "Throws an error containing the given input message. This is what an error response looks like.  <pre>    {      \"message\": \"An error message\",      \"causes\": [ \"A list of causes\", \"Potentially null\" ]    }  </pre>  <p>The <em>message</em> field contains a description of the error. The <em>causes</em> field, if not null, contains a list of causes for the error. </p>  <p>Note that this <strong>never</strong> returns an echoMessage. Instead, the result (and all error results) has the above structure. </p>", response = ApiEcho.class, authorizations = {
        @Authorization(value = "basic")
    }, tags={ "ToolsResource", })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "Will always be an exception", response = ApiEcho.class) })
    @RequestMapping(value = "/tools/echoError",
        produces = { "application/json" }, 
        method = RequestMethod.GET)
    default ResponseEntity<ApiEcho> echoError(@ApiParam(value = "The unique id of CB cluster (works in CB test framework only)",required=true) @PathVariable("mockUuid") String mockUuid,@ApiParam(value = "The error message to echo", defaultValue = "Default error message") @Valid @RequestParam(value = "message", required = false, defaultValue="Default error message") String message) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
            if (getAcceptHeader().get().contains("application/json")) {
                try {
                    return new ResponseEntity<>(getObjectMapper().get().readValue("{  \"message\" : \"...\"}", ApiEcho.class), HttpStatus.NOT_IMPLEMENTED);
                } catch (IOException e) {
                    log.error("Couldn't serialize response for content type application/json", e);
                    return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default ToolsResourceApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }

}
