in src/main/java/com/google/cloud/run/kafkascaler/clients/CloudRunMetadataClient.java [48:68]
public String projectNumberRegion() throws IOException {
try {
URL url = new URI(METADATA_SERVER_REGION_URL).toURL();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Metadata-Flavor", "Google");
StringBuilder response = new StringBuilder();
try (BufferedReader in =
new BufferedReader(new InputStreamReader(connection.getInputStream(), UTF_8))) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
}
return response.toString();
} catch (URISyntaxException e) {
throw new IOException("Failed to parse metadata URL " + METADATA_SERVER_REGION_URL, e);
}
}