本文整理汇总了Java中com.ecwid.consul.transport.RawResponse.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java RawResponse.getStatusCode方法的具体用法?Java RawResponse.getStatusCode怎么用?Java RawResponse.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ecwid.consul.transport.RawResponse
的用法示例。
在下文中一共展示了RawResponse.getStatusCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: getHealthChecksState
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<List<Check>> getHealthChecksState(Check.CheckStatus checkStatus, QueryParams queryParams) {
String status = checkStatus == null ? "ANY" : checkStatus.name().toLowerCase();
RawResponse rawResponse = rawClient.makeGetRequest("/v1/health/state/" + status, queryParams);
if (rawResponse.getStatusCode() == 200) {
List<Check> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Check>>() {
}.getType());
return new Response<List<Check>>(value, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例11: agentCheckWarn
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckWarn(String checkId, String note) {
UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/warn/" + checkId, noteParams);
if (rawResponse.getStatusCode() == 200) {
return new Response<Void>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例12: agentCheckPass
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckPass(String checkId, String note) {
UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/pass/" + checkId, noteParams);
if (rawResponse.getStatusCode() == 200) {
return new Response<Void>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例13: deleteKVValue
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> deleteKVValue(String key, String token, QueryParams queryParams) {
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makeDeleteRequest("/v1/kv/" + key, tokenParam, queryParams);
if (rawResponse.getStatusCode() == 200) {
return new Response<Void>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例14: agentCheckFail
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckFail(String checkId, String note) {
UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/fail/" + checkId, noteParams);
if (rawResponse.getStatusCode() == 200) {
return new Response<Void>(null, rawResponse);
} else {
throw new OperationException(rawResponse);
}
}
示例15: aclClone
import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<String> aclClone(String aclId, String token) {
UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
RawResponse rawResponse = rawClient.makePutRequest("/v1/acl/clone/" + aclId, "", tokenParams);
if (rawResponse.getStatusCode() == 200) {
Map<String, String> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<Map<String, String>>() {
}.getType());
return new Response<String>(value.get("ID"), rawResponse);
} else {
throw new OperationException(rawResponse);
}
}