Controllare lo stato dell'operazione

Questa pagina descrive come elencare tutte le operazioni a lunga esecuzione e come visualizzare lo stato di un'operazione a lunga esecuzione.

Per controllare lo stato e visualizzare eventuali dettagli aggiuntivi sugli errori di un'operazione di lunga durata, devi prima recuperare il valore di OPERATION_NAME e poi puoi richiedere lo stato.

ListOperations

Per elencare tutte le operazioni a lunga esecuzione, invia la seguente richiesta:

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://blockchainnodeengine.googleapis.com/v1/projects/PROJECT_ID/\
locations/LOCATION/operations

Dove:

  • PROJECT_ID è il tuo Google Cloud ID progetto. Ad esempio, my-project-id.
  • LOCATION è la posizione in cui sono ospitate le tue risorse. Ad esempio: us-central1.

Ecco un esempio di risposta al comando precedente:

{
  "operations": [
    {
      "name": "projects/my-project-id/locations/us-central1/operations/operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.OperationMetadata",
        "createTime": "2023-05-05T21:19:33.245698045Z",
        "endTime": "2023-05-05T21:58:44.520319810Z",
        "target": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
        "verb": "create",
        "requestedCancellation": false,
        "apiVersion": "v1"
      },
      "done": true,
      "response": {
        "@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.BlockchainNode",
        "name": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
        "createTime": "2023-05-05T21:19:33.308756Z",
        "updateTime": "2023-05-05T21:58:44.513286Z",
        "labels": {
          "label-key": "label-value"
        },
        "blockchainType": "ETHEREUM",
        "connectionInfo": {
          "ipInfo": {
            "rpcIpv4Address": "203.0.113.1"
          },
          "endpointInfo": {
            "jsonRpcApiEndpoint": "json-rpc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
            "websocketsApiEndpoint": "ws.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
          }
        },
        "ethereumDetails": {
          "network": "MAINNET",
          "nodeType": "FULL",
          "executionClient": "GETH",
          "consensusClient": "LIGHTHOUSE",
          "apiEnableAdmin": false,
          "apiEnableDebug": false,
          "additionalEndpoints": {
            "beaconApiEndpoint": "beacon.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
            "beaconPrometheusMetricsApiEndpoint": "bc-mc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
          }
        },
        "state": "RUNNING"
      }
    }
  ]
}

Prendi nota del codice OPERATION_ID, che ha il seguente aspetto:

"name": "projects/my-project-id/locations/us-central1/operations/
    operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",

GetOperation

Quando invii una richiesta e ricevi una risposta, ad esempio da CreateBlockchainNode o DeleteBlockchainNode, la risposta include OPERATION_ID:

  "name": "projects/my-project-id/locations/us-central1/operations/
    operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",

Per questo esempio, imposta OPERATION_NAME su operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828.

Puoi anche ottenere il nome dell'operazione dai risultati del comando ListOperations.

Una volta ottenuto il valore di OPERATION_NAME, invia la seguente richiesta:

curl \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
https://blockchainnodeengine.googleapis.com/v1/projects/PROJECT_ID/\
locations/LOCATION/operations/OPERATION_NAME

Dove:

  • PROJECT_ID è il tuo Google Cloud ID progetto. Ad esempio my-project-id.
  • LOCATION è la località in cui sono ospitate le risorse. Ad esempio: us-central1.
  • OPERATION_NAME è una stringa che specifica l'operazione. Ad esempio, operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828.

Ecco un esempio di risposta al comando precedente:

{
  "name": "projects/my-project-id/locations/us-central1/operations/operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.OperationMetadata",
    "createTime": "2023-05-05T21:19:33.245698045Z",
    "endTime": "2023-05-05T21:58:44.520319810Z",
    "target": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.BlockchainNode",
    "name": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
    "createTime": "2023-05-05T21:19:33.308756Z",
    "updateTime": "2023-05-05T21:58:44.513286Z",
    "labels": {
      "label-key": "label-value"
    },
    "blockchainType": "ETHEREUM",
    "connectionInfo": {
      "ipInfo": {
        "rpcIpv4Address": "203.0.113.1"
      },
      "endpointInfo": {
        "jsonRpcApiEndpoint": "json-rpc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
        "websocketsApiEndpoint": "ws.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
      }
    },
    "ethereumDetails": {
      "network": "MAINNET",
      "nodeType": "FULL",
      "executionClient": "GETH",
      "consensusClient": "LIGHTHOUSE",
      "apiEnableAdmin": false,
      "apiEnableDebug": false,
      "additionalEndpoints": {
        "beaconApiEndpoint": "beacon.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
        "beaconPrometheusMetricsApiEndpoint": "bc-mc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
      }
    },
    "state": "RUNNING"
  }
}