Répertorier les opérations de longue durée
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Lister les opérations de longue durée pour une ressource spécifiée.
En savoir plus
Pour obtenir une documentation détaillée incluant cet exemple de code, consultez les articles suivants :
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis code sample demonstrates how to list long-running operations for a specified resource using the Vertex AI Agent Builder.\u003c/p\u003e\n"],["\u003cp\u003eThe process requires setting up Application Default Credentials for authentication and defining parameters such as project ID, location, and search engine ID.\u003c/p\u003e\n"],["\u003cp\u003eThe code utilizes the \u003ccode\u003ediscoveryengine\u003c/code\u003e and \u003ccode\u003eoperations_pb2\u003c/code\u003e modules from the Google Cloud client library to create and send a ListOperations request.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elist_operations_sample\u003c/code\u003e function allows for optional filtering of operations, and returns a list of operations response that can then be displayed.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a list of long running operations based on the provided parameters, within the specified search engine.\u003c/p\u003e\n"]]],[],null,["# List long running operations\n\nList the long running operations for a specified resource.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Monitor long-running operations](/agentspace/docs/long-running-operations)\n- [Monitor long-running operations](/generative-ai-app-builder/docs/long-running-operations)\n\nCode sample\n-----------\n\n### Python\n\n\nFor more information, see the\n[AI Applications Python API\nreference documentation](/python/docs/reference/discoveryengine/latest).\n\n\nTo authenticate to AI Applications, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from typing import Optional\n\n from google.cloud import discoveryengine\n from google.longrunning import operations_pb2\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_id = \"YOUR_PROJECT_ID\"\n # location = \"YOUR_PROCESSOR_LOCATION\" # Options: \"global\"\n # search_engine_id = \"YOUR_SEARCH_ENGINE_ID\"\n\n # Create filter in https://google.aip.dev/160 syntax\n # operations_filter = \"YOUR_FILTER\"\n\n\n def list_operations_sample(\n project_id: str,\n location: str,\n search_engine_id: str,\n operations_filter: Optional[str] = None,\n ) -\u003e operations_pb2.ListOperationsResponse:\n # Create a client\n client = discoveryengine.https://cloud.google.com/python/docs/reference/discoveryengine/latest/google.cloud.discoveryengine_v1.services.document_service.DocumentServiceClient.html()\n\n # The full resource name of the search engine branch.\n name = f\"projects/{project_id}/locations/{location}/collections/default_collection/dataStores/{search_engine_id}\"\n\n # Make ListOperations request\n request = operations_pb2.ListOperationsRequest(\n name=name,\n filter=operations_filter,\n )\n\n # Make ListOperations request\n response = client.https://cloud.google.com/python/docs/reference/discoveryengine/latest/google.cloud.discoveryengine_v1.services.document_service.DocumentServiceClient.html#google_cloud_discoveryengine_v1_services_document_service_DocumentServiceClient_list_operations(request=request)\n\n # Print the Operation Information\n for operation in response.operations:\n print(operation)\n\n return response\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=genappbuilder)."]]