31 lines
1.1 KiB
Java
31 lines
1.1 KiB
Java
package com.barrelsofdata.springexamples.controller;
|
|
|
|
import com.barrelsofdata.springexamples.dto.EventRequestDto;
|
|
import com.barrelsofdata.springexamples.service.TelemetryService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
@RestController
|
|
public class TelemetryController {
|
|
|
|
@Autowired private TelemetryService telemetryService;
|
|
|
|
@PutMapping(
|
|
value = "/telemetry",
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
)
|
|
public ResponseEntity<String> receiveTelemetry(@RequestBody @Valid EventRequestDto eventRequest) {
|
|
telemetryService.receiveTelemetry(eventRequest);
|
|
return new ResponseEntity<>(HttpStatus.CREATED.getReasonPhrase(), HttpStatus.CREATED);
|
|
}
|
|
|
|
}
|