Listar filas
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Lista as filas.
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"]],[],[],[],null,["# List queues\n\nLists queues.\n\nCode sample\n-----------\n\n### Java\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, 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 import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html;\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.LocationName.html;\n import com.google.cloud.tasks.v2.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html;\n import java.io.IOException;\n\n public class ListQueues {\n\n public static void main(String[] args) throws IOException {\n // TODO(developer): Replace these variables before running the sample.\n String projectId = \"my-project-id\";\n String locationId = \"us-central1\";\n listQueues(projectId, locationId);\n }\n\n // List queues using the Cloud Tasks client.\n public static void listQueues(String projectId, String locationId) throws IOException {\n\n // Instantiates a client.\n try (https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html.create()) {\n\n // Construct the fully qualified location path.\n String parent = https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.LocationName.html.of(projectId, locationId).toString();\n\n // Send list queues request.\n https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.html.https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.CloudTasksClient.ListQueuesPagedResponse.html response = client.listQueues(parent);\n\n // Iterate over results and print queue names\n int total = 0;\n for (https://cloud.google.com/java/docs/reference/google-cloud-tasks/latest/com.google.cloud.tasks.v2.Queue.html queue : response.iterateAll()) {\n System.out.println(queue.getName());\n total++;\n }\n\n if (total == 0) {\n System.out.println(\"No queues found!\");\n }\n }\n }\n }\n\n### Node.js\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, 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 // Imports the Google Cloud Tasks library.\n const cloudTasks = require('https://cloud.google.com/nodejs/docs/reference/tasks/latest/overview.html');\n\n // Instantiates a client.\n const client = new cloudTasks.https://cloud.google.com/nodejs/docs/reference/tasks/latest/overview.html();\n\n async function listQueues() {\n // Get the fully qualified path to the region\n const parent = client.locationPath(project, location);\n\n // list all fo the queues\n const [queues] = await client.listQueues({parent});\n\n if (queues.length \u003e 0) {\n console.log('Queues:');\n queues.forEach(queue =\u003e {\n console.log(` ${queue.name}`);\n });\n } else {\n console.log('No queues found!');\n }\n }\n listQueues();\n\n### Python\n\n\nTo learn how to install and use the client library for Cloud Tasks, see\n[Cloud Tasks client libraries](/tasks/docs/reference/libraries).\n\n\nTo authenticate to Cloud Tasks, 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 List\n\n from google.cloud import tasks_v2\n\n\n def list_queues(project: str, location: str) -\u003e List[str]:\n \"\"\"List all queues\n Args:\n project: The project ID to list queues from.\n location: The location ID to list queues from.\n\n Returns:\n A list of queue names.\n \"\"\"\n\n # Create a client.\n client = tasks_v2.CloudTasksClient()\n\n # Use the client to send a ListQueuesRequest.\n response = client.list_queues(\n tasks_v2.ListQueuesRequest(\n parent=client.common_location_path(project, location)\n )\n )\n\n # Return the results.\n return [queue.name for queue in 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=cloud_tasks)."]]