Apresentar operações de longa duração
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Apresente as operações de longa duração de um recurso especificado.
Explore mais
Para ver documentação detalhada que inclui este exemplo de código, consulte o seguinte:
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","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)."]]