本文整理汇总了Java中com.ecwid.consul.transport.RawResponse类的典型用法代码示例。如果您正苦于以下问题:Java RawResponse类的具体用法?Java RawResponse怎么用?Java RawResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RawResponse类属于com.ecwid.consul.transport包,在下文中一共展示了RawResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAcl
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<Acl> getAcl(String id) {
RawResponse rawResponse = rawClient.makeGetRequest("/v1/acl/info/" + id);
if (rawResponse.getStatusCode() == 200) {
List<Acl> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Acl>>() {
}.getType());
if (value.isEmpty()) {
return new Response<Acl>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<Acl>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else {
throw new OperationException(rawResponse);
}
}
示例2: catalogDeregister
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration, CatalogDeregistration... catalogDeregistrations) {
List<CatalogDeregistration> items = new ArrayList<CatalogDeregistration>();
items.add(catalogDeregistration);
if (catalogDeregistrations != null) {
items.addAll(Arrays.asList(catalogDeregistrations));
}
String json = GsonFactory.getGson().toJson(items);
RawResponse rawResponse = rawClient.makePutRequest("/v1/catalog/deregister", json);
if (rawResponse.getStatusCode() == 200) {
return new Response<Void>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例3: getSessionInfo
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<Session> getSessionInfo(String session, QueryParams queryParams) {
RawResponse rawResponse = rawClient.makeGetRequest("/v1/session/info/" + session, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<Session> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Session>>() {
}.getType());
if (value.isEmpty()) {
return new Response<Session>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<Session>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else {
throw new OperationException(rawResponse);
}
}
示例4: renewSession
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
public Response<Session> renewSession(String session, QueryParams queryParams) {
RawResponse rawResponse = rawClient.makePutRequest("/v1/session/renew/" + session, "", queryParams);
if (rawResponse.getStatusCode() == 200) {
List<Session> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Session>>() {
}.getType());
if (value.size() == 1) {
return new Response<Session>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else {
throw new OperationException(rawResponse);
}
}
示例5: getKVValue
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<GetValue> getKVValue(String key, String token, QueryParams queryParams) {
UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + key, tokenParams, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>(){}.getType());
if (value.size() == 0) {
return new Response<GetValue>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<GetValue>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else if (rawResponse.getStatusCode() == 404) {
return new Response<GetValue>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例6: getKVBinaryValue
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<GetBinaryValue> getKVBinaryValue(String key, String token, QueryParams queryParams) {
UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + key, tokenParams, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetBinaryValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetBinaryValue>>(){}.getType());
if (value.size() == 0) {
return new Response<GetBinaryValue>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<GetBinaryValue>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else if (rawResponse.getStatusCode() == 404) {
return new Response<GetBinaryValue>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例7: getKVValues
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<GetValue>> getKVValues(String keyPrefix, String token, QueryParams queryParams) {
UrlParameters recurseParam = new SingleUrlParameters("recurse");
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, recurseParam, tokenParam, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>() {
}.getType());
return new Response<List<GetValue>>(value, rawResponse);
} else if (rawResponse.getStatusCode() == 404) {
return new Response<List<GetValue>>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例8: getKVBinaryValues
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<GetBinaryValue>> getKVBinaryValues(String keyPrefix, String token, QueryParams queryParams) {
UrlParameters recurseParam = new SingleUrlParameters("recurse");
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, recurseParam, tokenParam, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetBinaryValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetBinaryValue>>() {
}.getType());
return new Response<List<GetBinaryValue>>(value, rawResponse);
} else if (rawResponse.getStatusCode() == 404) {
return new Response<List<GetBinaryValue>>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例9: getKVKeysOnly
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<String>> getKVKeysOnly(String keyPrefix, String separator, String token, QueryParams queryParams) {
UrlParameters separatorParam = separator != null ? new SingleUrlParameters("separator", separator) : null;
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, separatorParam, tokenParam, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<String> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<String>>() {
}.getType());
return new Response<List<String>>(value, rawResponse);
} else if (rawResponse.getStatusCode() == 404) {
return new Response<List<String>>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例10: getCatalogService
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag,
QueryParams queryParams, String token) {
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
UrlParameters tagParam = tag != null ? new SingleUrlParameters("tag", tag) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/catalog/service/" + serviceName, tagParam, queryParams, tokenParam);
if (rawResponse.getStatusCode() == 200) {
List<com.ecwid.consul.v1.catalog.model.CatalogService> value = GsonFactory.getGson().fromJson(rawResponse.getContent(),
new TypeToken<List<com.ecwid.consul.v1.catalog.model.CatalogService>>() {
}.getType());
return new Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>>(value, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例11: getSessionInfo
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<Session> getSessionInfo(String session, QueryParams queryParams) {
RawResponse rawResponse = rawClient.makeGetRequest("/v1/session/info/" + session, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<Session> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Session>>() {
}.getType());
if (value == null || value.isEmpty()) {
return new Response<Session>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<Session>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else {
throw new OperationException(rawResponse);
}
}
示例12: getHealthServices
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<com.ecwid.consul.v1.health.model.HealthService>> getHealthServices(String serviceName, String tag, boolean onlyPassing, QueryParams queryParams, String token) {
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
UrlParameters tagParams = tag != null ? new SingleUrlParameters("tag", tag) : null;
UrlParameters passingParams = onlyPassing ? new SingleUrlParameters("passing") : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/health/service/" + serviceName, tagParams, passingParams, queryParams, tokenParam);
if (rawResponse.getStatusCode() == 200) {
List<com.ecwid.consul.v1.health.model.HealthService> value = GsonFactory.getGson().fromJson(rawResponse.getContent(),
new TypeToken<List<com.ecwid.consul.v1.health.model.HealthService>>() {
}.getType());
return new Response<List<com.ecwid.consul.v1.health.model.HealthService>>(value, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例13: getKVValue
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<GetValue> getKVValue(String key, String token, QueryParams queryParams) {
UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + key, tokenParams, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>() {
}.getType());
if (value.size() == 0) {
return new Response<GetValue>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<GetValue>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else if (rawResponse.getStatusCode() == 404) {
return new Response<GetValue>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例14: getKVBinaryValue
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<GetBinaryValue> getKVBinaryValue(String key, String token, QueryParams queryParams) {
UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + key, tokenParams, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<GetBinaryValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetBinaryValue>>() {
}.getType());
if (value.size() == 0) {
return new Response<GetBinaryValue>(null, rawResponse);
} else if (value.size() == 1) {
return new Response<GetBinaryValue>(value.get(0), rawResponse);
} else {
throw new ConsulException("Strange response (list size=" + value.size() + ")");
}
} else if (rawResponse.getStatusCode() == 404) {
return new Response<GetBinaryValue>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例15: getKVKeysOnly
import com.ecwid.consul.transport.RawResponse; //导入依赖的package包/类
@Override
public Response<List<String>> getKVKeysOnly(String keyPrefix, String separator, String token, QueryParams queryParams) {
UrlParameters keysParam = new SingleUrlParameters("keys");
UrlParameters separatorParam = separator != null ? new SingleUrlParameters("separator", separator) : null;
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, keysParam, separatorParam, tokenParam, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<String> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<String>>() {
}.getType());
return new Response<List<String>>(value, rawResponse);
} else if (rawResponse.getStatusCode() == 404) {
return new Response<List<String>>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}