{
"basePath": "/",
"paths": {
- "/producer_simulator/supervision": {"get": {
- "summary": "Producer supervision",
+ "/producer_simulator/ei_job": {"post": {
+ "summary": "Callback for EI job creation",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "producerSupervisionUsingGET",
+ "operationId": "jobCreatedCallbackUsingPOST",
"responses": {
- "200": {
- "schema": {"type": "string"},
- "description": "OK"
- },
+ "200": {"description": "OK"},
+ "201": {"description": "Created"},
"401": {"description": "Unauthorized"},
"403": {"description": "Forbidden"},
"404": {"description": "Not Found"}
},
- "tags": ["Producer Callbacks"]
+ "parameters": [{
+ "schema": {"$ref": "#/definitions/producer_ei_job_request"},
+ "in": "body",
+ "name": "request",
+ "description": "request",
+ "required": true
+ }],
+ "tags": ["Producer Callbacks"],
+ "consumes": ["application/json"]
}},
"/A1-EI/v1/eitypes/{eiTypeId}": {"get": {
"summary": "Individual EI type",
},
"tags": ["A1-EI (enrichment information)"]
}},
- "/producer_simulator/job_deleted": {"post": {
- "summary": "Callback for EI job deletion",
- "deprecated": false,
- "produces": ["application/json"],
- "operationId": "jobDeletedCallbackUsingPOST",
- "responses": {
- "200": {"description": "OK"},
- "201": {"description": "Created"},
- "401": {"description": "Unauthorized"},
- "403": {"description": "Forbidden"},
- "404": {"description": "Not Found"}
- },
- "parameters": [{
- "schema": {"$ref": "#/definitions/producer_ei_job_request"},
- "in": "body",
- "name": "request",
- "description": "request",
- "required": true
- }],
- "tags": ["Producer Callbacks"],
- "consumes": ["application/json"]
- }},
"/ei-producer/v1/eiproducers/{eiProducerId}/status": {"get": {
"summary": "EI producer status",
"deprecated": false,
}],
"tags": ["Enrichment Data Producer API"]
}},
+ "/producer_simulator/ei_job/{eiJobId}": {"delete": {
+ "summary": "Callback for EI job deletion",
+ "deprecated": false,
+ "produces": ["application/json"],
+ "operationId": "jobDeletedCallbackUsingDELETE",
+ "responses": {
+ "200": {"description": "OK"},
+ "401": {"description": "Unauthorized"},
+ "204": {"description": "No Content"},
+ "403": {"description": "Forbidden"}
+ },
+ "parameters": [{
+ "in": "path",
+ "name": "eiJobId",
+ "description": "eiJobId",
+ "type": "string",
+ "required": true
+ }],
+ "tags": ["Producer Callbacks"]
+ }},
"/ei-producer/v1/eiproducers": {"get": {
"summary": "EI producer identifiers",
"deprecated": false,
"consumes": ["application/json"]
}
},
+ "/producer_simulator/health_check": {"get": {
+ "summary": "Producer supervision",
+ "deprecated": false,
+ "produces": ["application/json"],
+ "operationId": "producerSupervisionUsingGET",
+ "responses": {
+ "200": {
+ "schema": {"type": "string"},
+ "description": "OK"
+ },
+ "401": {"description": "Unauthorized"},
+ "403": {"description": "Forbidden"},
+ "404": {"description": "Not Found"}
+ },
+ "tags": ["Producer Callbacks"]
+ }},
"/ei-producer/v1/eiproducers/{eiProducerId}/eijobs": {"get": {
"summary": "EI job definitions",
"deprecated": false,
"required": true
}],
"tags": ["A1-EI (enrichment information)"]
- }},
- "/producer_simulator/job_created": {"post": {
- "summary": "Callback for EI job creation",
- "deprecated": false,
- "produces": ["application/json"],
- "operationId": "jobCreatedCallbackUsingPOST",
- "responses": {
- "200": {"description": "OK"},
- "201": {"description": "Created"},
- "401": {"description": "Unauthorized"},
- "403": {"description": "Forbidden"},
- "404": {"description": "Not Found"}
- },
- "parameters": [{
- "schema": {"$ref": "#/definitions/producer_ei_job_request"},
- "in": "body",
- "name": "request",
- "description": "request",
- "required": true
- }],
- "tags": ["Producer Callbacks"],
- "consumes": ["application/json"]
}}
},
- "host": "localhost:38499",
+ "host": "localhost:41549",
"definitions": {
"producer_ei_job_request": {
"description": "The body of the EI producer callbacks for EI job creation and deletion",
"type": "object",
"title": "producer_registration_info",
"required": [
- "ei_job_creation_callback_url",
- "ei_job_deletion_callback_url",
+ "ei_job_callback_url",
"ei_producer_supervision_callback_url",
"supported_ei_types"
],
"type": "array",
"items": {"$ref": "#/definitions/producer_ei_type_registration_info"}
},
- "ei_job_creation_callback_url": {
- "description": "callback for job creation",
- "type": "string"
- },
- "ei_job_deletion_callback_url": {
- "description": "callback for job deletion",
- "type": "string"
- },
"ei_producer_supervision_callback_url": {
"description": "callback for producer supervision",
"type": "string"
+ },
+ "ei_job_callback_url": {
+ "description": "callback for EI job",
+ "type": "string"
}
}
},
}
public void notifyProducersJobDeleted(EiJob eiJob) {
- ProducerJobInfo request = new ProducerJobInfo(eiJob);
- String body = gson.toJson(request);
for (EiProducer producer : getProducers(eiJob)) {
- restClient.post(producer.getJobDeletionCallbackUrl(), body) //
- .subscribe(notUsed -> logger.debug("Job deleted OK {}", producer.getId()), //
- throwable -> logger.warn("Job delete failed {}", producer.getId(), throwable.toString()), null);
+ String url = producer.getJobCallbackUrl() + "/" + eiJob.id();
+ restClient.delete(url) //
+ .subscribe(notUsed -> logger.debug("Producer job deleted OK {}", producer.getId()), //
+ throwable -> logger.warn("Producer job delete failed {} {}", producer.getId(),
+ throwable.getMessage()),
+ null);
}
}
ProducerJobInfo request = new ProducerJobInfo(eiJob);
String body = gson.toJson(request);
- return restClient.post(producer.getJobCreationCallbackUrl(), body)
+ return restClient.post(producer.getJobCallbackUrl(), body)
.doOnNext(resp -> logger.debug("Job subscription started OK {}", producer.getId()))
.onErrorResume(throwable -> {
logger.warn("Job subscription failed {}", producer.getId(), throwable.toString());
}
EiProducer createProducer(Collection<EiType> types, String producerId, ProducerRegistrationInfo registrationInfo) {
- return new EiProducer(producerId, types, registrationInfo.jobCreationCallbackUrl,
- registrationInfo.jobDeletionCallbackUrl, registrationInfo.producerSupervisionCallbackUrl);
+ return new EiProducer(producerId, types, registrationInfo.jobCallbackUrl,
+ registrationInfo.producerSupervisionCallbackUrl);
}
private EiProducer registerProducer(String producerId, ProducerRegistrationInfo registrationInfo) {
for (EiType type : p.getEiTypes()) {
types.add(toEiTypeRegistrationInfo(type));
}
- return new ProducerRegistrationInfo(types, p.getJobCreationCallbackUrl(), p.getJobDeletionCallbackUrl(),
- p.getProducerSupervisionCallbackUrl());
+ return new ProducerRegistrationInfo(types, p.getJobCallbackUrl(), p.getProducerSupervisionCallbackUrl());
}
private ProducerEiTypeRegistrationInfo toEiTypeRegistrationInfo(EiType type) {
@JsonProperty(value = "supported_ei_types", required = true)
public Collection<ProducerEiTypeRegistrationInfo> types;
- @ApiModelProperty(value = "callback for job creation", required = true)
- @SerializedName("ei_job_creation_callback_url")
- @JsonProperty(value = "ei_job_creation_callback_url", required = true)
- public String jobCreationCallbackUrl;
-
- @ApiModelProperty(value = "callback for job deletion", required = true)
- @SerializedName("ei_job_deletion_callback_url")
- @JsonProperty(value = "ei_job_deletion_callback_url", required = true)
- public String jobDeletionCallbackUrl;
+ @ApiModelProperty(value = "callback for EI job", required = true)
+ @SerializedName("ei_job_callback_url")
+ @JsonProperty(value = "ei_job_callback_url", required = true)
+ public String jobCallbackUrl;
@ApiModelProperty(value = "callback for producer supervision", required = true)
@SerializedName("ei_producer_supervision_callback_url")
@JsonProperty(value = "ei_producer_supervision_callback_url", required = true)
public String producerSupervisionCallbackUrl;
- public ProducerRegistrationInfo(Collection<ProducerEiTypeRegistrationInfo> types, String jobCreationCallbackUrl,
- String jobDeletionCallbackUrl, String producerSupervisionCallbackUrl) {
+ public ProducerRegistrationInfo(Collection<ProducerEiTypeRegistrationInfo> types, String jobCallbackUrl,
+ String producerSupervisionCallbackUrl) {
this.types = types;
- this.jobCreationCallbackUrl = jobCreationCallbackUrl;
- this.jobDeletionCallbackUrl = jobDeletionCallbackUrl;
+ this.jobCallbackUrl = jobCallbackUrl;
this.producerSupervisionCallbackUrl = producerSupervisionCallbackUrl;
}
private final Collection<EiType> eiTypes;
@Getter
- private final String jobCreationCallbackUrl;
-
- @Getter
- private final String jobDeletionCallbackUrl;
+ private final String jobCallbackUrl;
@Getter
private final String producerSupervisionCallbackUrl;
private int unresponsiveCounter = 0;
- public EiProducer(String id, Collection<EiType> eiTypes, String jobCreationCallbackUrl,
- String jobDeletionCallbackUrl, String producerSupervisionCallbackUrl) {
+ public EiProducer(String id, Collection<EiType> eiTypes, String jobCallbackUrl,
+ String producerSupervisionCallbackUrl) {
this.id = id;
this.eiTypes = eiTypes;
- this.jobCreationCallbackUrl = jobCreationCallbackUrl;
- this.jobDeletionCallbackUrl = jobDeletionCallbackUrl;
+ this.jobCallbackUrl = jobCallbackUrl;
this.producerSupervisionCallbackUrl = producerSupervisionCallbackUrl;
}
ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults();
await().untilAsserted(() -> assertThat(simulatorResults.jobsStopped.size()).isEqualTo(1));
- assertThat(simulatorResults.jobsStopped.get(0).id).isEqualTo("jobId");
+ assertThat(simulatorResults.jobsStopped.get(0)).isEqualTo("jobId");
}
@Test
Collection<ProducerEiTypeRegistrationInfo> types = new ArrayList<>();
types.add(producerEiTypeRegistrationInfo(typeId));
return new ProducerRegistrationInfo(types, //
- baseUrl() + ProducerSimulatorController.JOB_CREATED_ERROR_URL,
- baseUrl() + ProducerSimulatorController.JOB_DELETED_ERROR_URL,
+ baseUrl() + ProducerSimulatorController.JOB_ERROR_URL,
baseUrl() + ProducerSimulatorController.SUPERVISION_ERROR_URL);
}
Collection<ProducerEiTypeRegistrationInfo> types = new ArrayList<>();
types.add(producerEiTypeRegistrationInfo(typeId));
return new ProducerRegistrationInfo(types, //
- baseUrl() + ProducerSimulatorController.JOB_CREATED_URL,
- baseUrl() + ProducerSimulatorController.JOB_DELETED_URL,
- baseUrl() + ProducerSimulatorController.SUPERVISION_URL);
+ baseUrl() + ProducerSimulatorController.JOB_URL, baseUrl() + ProducerSimulatorController.SUPERVISION_URL);
}
private ConsumerEiJobInfo eiJobInfo() throws JsonMappingException, JsonProcessingException {
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static final String JOB_CREATED_URL = "/producer_simulator/job_created";
- public static final String JOB_DELETED_URL = "/producer_simulator/job_deleted";
- public static final String JOB_CREATED_ERROR_URL = "/producer_simulator/job_created_error";
- public static final String JOB_DELETED_ERROR_URL = "/producer_simulator/job_deleted_error";
+ public static final String JOB_URL = "/producer_simulator/ei_job";
+ public static final String JOB_ERROR_URL = "/producer_simulator/ei_job_error";
- public static final String SUPERVISION_URL = "/producer_simulator/supervision";
- public static final String SUPERVISION_ERROR_URL = "/producer_simulator/supervision_error";
+ public static final String SUPERVISION_URL = "/producer_simulator/health_check";
+ public static final String SUPERVISION_ERROR_URL = "/producer_simulator/health_check_error";
public static class TestResults {
public List<ProducerJobInfo> jobsStarted = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
- public List<ProducerJobInfo> jobsStopped = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
+ public List<String> jobsStopped = Collections.synchronizedList(new ArrayList<String>());
public int noOfRejectedCreate = 0;
public int noOfRejectedDelete = 0;
public boolean errorFound = false;
@Getter
private TestResults testResults = new TestResults();
- @PostMapping(path = JOB_CREATED_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(path = JOB_URL, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Callback for EI job creation", notes = "")
@ApiResponses(
value = { //
}
}
- @PostMapping(path = JOB_DELETED_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+ @DeleteMapping(path = "/producer_simulator/ei_job/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Callback for EI job deletion", notes = "")
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
)
public ResponseEntity<Object> jobDeletedCallback( //
- @RequestBody ProducerJobInfo request) {
+ @PathVariable("eiJobId") String eiJobId) {
try {
- logger.info("Job deleted callback {}", request.id);
- this.testResults.jobsStopped.add(request);
+ logger.info("Job deleted callback {}", eiJobId);
+ this.testResults.jobsStopped.add(eiJobId);
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
}
}
- @PostMapping(path = JOB_CREATED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(path = JOB_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true)
@ApiResponses(
value = { //
return ErrorResponse.create("Producer returns error on create job", HttpStatus.NOT_FOUND);
}
- @PostMapping(path = JOB_DELETED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+ @DeleteMapping(path = JOB_ERROR_URL + "/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true)
@ApiResponses(
value = { //