Cette page a été traduite par l'API Cloud Translation.
Switch to English

Obtenir l'état d'une opération

Récupérez l'état d'une opération.

Exemple de code


 * Demonstrates using the AutoML client to get operation status.
 * @param operationFullId Full name of a operation. For example, the name of your operation is
 *     projects/[projectId]/locations/us-central1/operations/[operationId].
 * @throws IOException on Input/Output errors.
private static void getOperationStatus(String operationFullId) throws IOException {
  // Instantiates a client
  try (AutoMlClient client = AutoMlClient.create()) {

    // Get the latest state of a long-running operation.
    Operation response = client.getOperationsClient().getOperation(operationFullId);

    System.out.println(String.format("Operation status: %s", response));


    # TODO(developer): Uncomment and set the following variables
    # operation_full_id =
    #   'projects/<projectId>/locations/<region>/operations/<operationId>'

    from google.cloud import automl_v1beta1 as automl

    client = automl.AutoMlClient()

    # Get the latest state of a long-running operation.
    response = client._transport.operations_client.get_operation(operation_full_id)

    print("Operation status: {}".format(response))