List scheduled jobs
List scheduled jobs; Cloud Scheduler triggers recurring application work on a cron schedule.
Call the Google Cloud REST API with the JDK HTTP client. Requires JDK 17+. Results reflect resources already created in your local project.
Read-only: lists what already exists and creates nothing.
Save as Hello.java
import java.net.URI;
import java.net.http.*;
import java.time.Duration;
import java.util.Objects;
public class Hello {
public static void main(String[] args) throws Exception {
var project = Objects.requireNonNull(System.getenv("GOOGLE_CLOUD_PROJECT"));
var endpoint = Objects.requireNonNull(System.getenv("SERVICE_USAGE_EMULATOR_HOST"));
var url = URI.create(endpoint.replaceAll("/+$", "") + "/v1/projects/" + project + "/locations/us-central1/jobs");
var request = HttpRequest.newBuilder(url).timeout(Duration.ofSeconds(30)).GET().build();
var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
throw new IllegalStateException(response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
}
} Run the example
java Hello.java Verify the result
The request succeeds. An empty list or no printed rows is valid before matching resources exist. Continue with the workflows on this page for a resource test.