Borrar una cola

Organiza tus páginas con colecciones Guarda y categoriza el contenido según tus preferencias.

Borra una cola.

Muestra de código

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de Cloud Tasks, consulta Bibliotecas cliente de Cloud Tasks.

import com.google.cloud.tasks.v2.CloudTasksClient;
import com.google.cloud.tasks.v2.QueueName;
import java.io.IOException;

public class DeleteQueue {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String locationId = "us-central1";
    String queueId = "my-queue";
    deleteQueue(projectId, locationId, queueId);
  }

  // Delete a queue using the Cloud Tasks client.
  public static void deleteQueue(String projectId, String locationId, String queueId)
      throws IOException {

    // Instantiates a client.
    try (CloudTasksClient client = CloudTasksClient.create()) {

      // Construct the fully qualified queue path.
      String queuePath = QueueName.of(projectId, locationId, queueId).toString();

      // Send delete queue request.
      client.deleteQueue(queuePath);

      System.out.println("Queue deleted: " + queueId);
    }
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de Cloud Tasks, consulta Bibliotecas cliente de Cloud Tasks.

// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');

// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();

async function deleteQueue() {
  // Get the fully qualified path to the queue
  const name = client.queuePath(project, location, queue);

  // Send delete queue request.
  await client.deleteQueue({name});
  console.log(`Deleted queue '${queue}'.`);
}
deleteQueue();

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de Cloud Tasks, consulta Bibliotecas cliente de Cloud Tasks.

def delete_queue(project, queue_name, location):
    """Delete a task queue."""

    from google.cloud import tasks_v2

    # Create a client.
    client = tasks_v2.CloudTasksClient()

    # Get the fully qualified path to queue.
    queue = client.queue_path(project, location, queue_name)

    # Use the client to delete the queue.
    client.delete_queue(request={"name": queue})
    print("Deleted queue")

¿Qué sigue?

Para buscar y filtrar muestras de código en otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.