@Override public List<NamespaceMeta> list() throws Exception { HttpRequest request = HttpRequest.get(resolve("namespaces")).build(); HttpResponse response = execute(request); if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return ObjectResponse.fromJsonBody(response, new TypeToken<List<NamespaceMeta>>() { }).getResponseObject(); } throw new IOException(String.format("Cannot list namespaces. Reason: %s", response.getResponseBodyAsString())); }
@Override public List<NamespaceMeta> list() throws Exception { HttpRequest request = HttpRequest.get(resolve("namespaces")).build(); HttpResponse response = execute(request); if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return ObjectResponse.fromJsonBody(response, new TypeToken<List<NamespaceMeta>>() { }).getResponseObject(); } throw new IOException(String.format("Cannot list namespaces. Reason: %s", response.getResponseBodyAsString())); }
@Override public NamespaceMeta get(NamespaceId namespaceId) throws Exception { HttpResponse response = execute(HttpRequest.get(resolve(String.format("namespaces/%s", namespaceId.getNamespace()))).build()); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NamespaceNotFoundException(namespaceId); } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return ObjectResponse.fromJsonBody(response, NamespaceMeta.class).getResponseObject(); } throw new IOException(String.format("Cannot get namespace %s. Reason: %s", namespaceId, response.getResponseBodyAsString())); }
@Override public NamespaceMeta get(NamespaceId namespaceId) throws Exception { HttpResponse response = execute(HttpRequest.get(resolve(String.format("namespaces/%s", namespaceId.getNamespace()))).build()); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NamespaceNotFoundException(namespaceId); } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return ObjectResponse.fromJsonBody(response, NamespaceMeta.class).getResponseObject(); } throw new IOException(String.format("Cannot get namespace %s. Reason: %s", namespaceId, response.getResponseBodyAsString())); }