package dp.kotul.solrapiapplication.client

import dp.kotul.solrapiapplication.model.SolrRequest
import dp.kotul.starter.config.FeignConfiguration
import feign.Response
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.http.MediaType.APPLICATION_JSON_VALUE
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody

@FeignClient(name = "SolrClient", url = "\${solr.url}", configuration = [FeignConfiguration::class])
interface SolrClient {

    @PostMapping(value = ["/{collection}/select?wt=json"], consumes = [APPLICATION_JSON_VALUE])
    fun select(@PathVariable collection: String, @RequestBody parameters: SolrRequest): Response

    @PostMapping(value = ["/{collection}/update/json?commit=true&overwrite=true"], consumes = ["application/json"])
    fun update(@PathVariable collection: String, content: String): Response
}


