/** Retrieves a key. Returns null if not found. */ public EtcdResult get(String key) throws EtcdClientException { URI uri = buildKeyUri("v1/keys", key, ""); HttpGet request = new HttpGet(uri); EtcdResult result = syncExecute(request, 100); if (result.isError()) { if (result.errorCode == 100) { return null; } } return result; }
private EtcdResult jsonToEtcdResult(JsonResponse response, int... expectedErrorCodes) throws EtcdClientException { if (response == null || response.json == null) { return null; } EtcdResult result = parseEtcdResult(response.json); if (result.isError()) { if (!contains(expectedErrorCodes, result.errorCode)) { throw new EtcdClientException(result.message, result); } } return result; }