2016-12-06 1 views
0

우리는 작업 상태를 확인할 수있는 REST API를 찾고 있습니다. ServiceNow에서 REST API 호출을 사용하여 가상 인스턴스 제공을 수행하기 위해 노력하고 있습니다. 성공적으로 REST 호출을 만들 수 있었고 REST 호출에서받은 응답은 STATUS : PENDING 상태를 나타냅니다.REST API를 사용하여 Google 클라우드 상태를 확인 하시겠습니까?

따라서 상태가 STATUS : PENDING에서 STATUS : DONE/READY로 변경되었는지 확인하고 싶습니다. REST API 호출을 사용하여이를 확인하고 싶습니다.이를 확인하기 위해 REST API 호출이 있습니까?

https://developers.google.com/apis-explorer/?hl=en_US#p/compute/v1/

위의 링크는 VM에 다양한 작업을 수행하는 구글의 API 콘솔에 사용됩니다.

+1

this page이 방금 시작했습니다하는 인스턴스의 상태를 조회하는 방법을 묻는 기반으로 GET 요청을 전송 자바에서이 예제를 확인하실 수 있습니다? compute.instances.get을 사용할 수 있습니다 (https://cloud.google.com/compute/docs/reference/latest/instances/get 참조). – jarmod

답변

0

https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/instance에게 GET 요청을 보낼 수 있습니다.

status 속성을 포함하는 Instance Resource을 반환합니다.

CE REST API here에 대한 자세한 정보를 찾을 수 있습니다.

또한

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(); 
    } 
} 
관련 문제