Search in sources :

Example 1 with GetSchemaListResponse

use of org.apache.servicecomb.service.center.client.model.GetSchemaListResponse in project java-chassis by ServiceComb.

the class ServiceCenterClient method getServiceSchemasList.

@Override
public List<SchemaInfo> getServiceSchemasList(String serviceId, boolean withContent) {
    String url = "/registry/microservices/" + serviceId + "/schemas";
    if (withContent) {
        url = url + "?withSchema=1";
    }
    try {
        HttpResponse response = httpClient.getHttpRequest(url, null, null);
        if (response.getStatusCode() == HttpStatus.SC_OK) {
            GetSchemaListResponse getSchemaResponse = HttpUtils.deserialize(response.getContent(), GetSchemaListResponse.class);
            return getSchemaResponse.getSchemas();
        }
        sendUnAuthorizedEvent(response);
        throw new OperationException("get service schemas list fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
    } catch (IOException e) {
        throw new OperationException("get service schemas list fails", e);
    }
}
Also used : HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) IOException(java.io.IOException) GetSchemaListResponse(org.apache.servicecomb.service.center.client.model.GetSchemaListResponse) OperationException(org.apache.servicecomb.service.center.client.exception.OperationException)

Aggregations

IOException (java.io.IOException)1 HttpResponse (org.apache.servicecomb.http.client.common.HttpResponse)1 OperationException (org.apache.servicecomb.service.center.client.exception.OperationException)1 GetSchemaListResponse (org.apache.servicecomb.service.center.client.model.GetSchemaListResponse)1