-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch java API client for /api/v1/admin/usage
- Loading branch information
Showing
3 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java | ||
index 376df77e9..be5b616c3 100644 | ||
--- a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java | ||
+++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java | ||
@@ -17,17 +17,12 @@ import org.vcell.restclient.ApiException; | ||
import org.vcell.restclient.ApiResponse; | ||
import org.vcell.restclient.Pair; | ||
|
||
-import java.io.File; | ||
+import java.io.*; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
-import java.io.InputStream; | ||
-import java.io.ByteArrayInputStream; | ||
-import java.io.ByteArrayOutputStream; | ||
import java.io.File; | ||
-import java.io.IOException; | ||
-import java.io.OutputStream; | ||
import java.net.http.HttpRequest; | ||
import java.nio.channels.Channels; | ||
import java.nio.channels.Pipe; | ||
@@ -111,10 +106,16 @@ public class AdminResourceApi { | ||
if (localVarResponse.statusCode()/ 100 != 2) { | ||
throw getApiException("getUsage", localVarResponse); | ||
} | ||
+ // Create a temporary file to store the PDF | ||
+ File tempFile = File.createTempFile("usage_summary", ".pdf"); | ||
+ try (OutputStream out = new FileOutputStream(tempFile)) { | ||
+ // Write the response body to the file | ||
+ localVarResponse.body().transferTo(out); | ||
+ } | ||
return new ApiResponse<File>( | ||
- localVarResponse.statusCode(), | ||
- localVarResponse.headers().map(), | ||
- localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<File>() {}) // closes the InputStream | ||
+ localVarResponse.statusCode(), | ||
+ localVarResponse.headers().map(), | ||
+ tempFile | ||
); | ||
} finally { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters