https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/instanceにGETリクエストを送信できます。
これは、status
プロパティを含むInstance Resourceを返します。
CE REST API hereの詳細については、こちらをご覧ください。
またthis page
public class ComputeExample {
public static void main(String[] args) throws IOException, GeneralSecurityException {
// Authentication is provided by the 'gcloud' tool when running locally
// and by built-in service accounts when running on GAE, GCE, or GKE.
GoogleCredential credential = GoogleCredential.getApplicationDefault();
// The createScopedRequired method returns true when running on GAE or a local developer
// machine. In that case, the desired scopes must be passed in manually. When the code is
// running in GCE, GKE or a Managed VM, the scopes are pulled from the GCE metadata server.
// For more information, see
// https://developers.google.com/identity/protocols/application-default-credentials
if (credential.createScopedRequired()) {
credential =
credential.createScoped(
Collections.singletonList("https://www.googleapis.com/auth/cloud-platform"));
}
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
Compute computeService =
new Compute.Builder(httpTransport, jsonFactory, credential)
.setApplicationName("Google Cloud Platform Sample")
.build();
// TODO: Change placeholders below to appropriate parameter values for the 'get' method:
// * Project ID for this request.
String project = "";
// * The name of the zone for this request.
String zone = "";
// * Name of the instance resource to return.
String instance = "";
Compute.Instances.Get request = computeService.instances().get(project, zone, instance);
Instance response = request.execute();
//I'm assuming there's a getStatus method here
String status = response.getStatus();
}
}
に基づいてGETリクエストを送信するJavaでこの例をチェックアウトすることができ、あなたがちょうど発売してきたインスタンスのステータスを照会する方法を求めていますか? compute.instances.getを使用できます(https://cloud.google.com/compute/docs/reference/latest/instances/getをご覧ください)。 – jarmod