use of org.apache.servicecomb.service.center.client.model.CreateMicroserviceRequest in project java-chassis by ServiceComb.
the class ServiceCenterClient method registerMicroservice.
@Override
public RegisteredMicroserviceResponse registerMicroservice(Microservice microservice) {
try {
CreateMicroserviceRequest request = new CreateMicroserviceRequest();
request.setService(microservice);
HttpResponse response = httpClient.postHttpRequest("/registry/microservices", null, HttpUtils.serialize(request));
if (response.getStatusCode() == HttpStatus.SC_OK) {
return HttpUtils.deserialize(response.getContent(), RegisteredMicroserviceResponse.class);
}
sendUnAuthorizedEvent(response);
throw new OperationException("register service fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("register service fails", e);
}
}
Aggregations