def topic(client: AdminClient) -> Generator[Topic, None, None]:
    location = CloudZone(CloudRegion(CLOUD_REGION), ZONE_ID)
    topic_path = TopicPath(PROJECT_NUMBER, location, TOPIC_ID)

    # A topic of 2 partitions, each of size 30 GiB, publish throughput
    # capacity per partition to 4 MiB/s, and subscribe throughput
    # capacity per partition to 8 MiB/s.
    topic = Topic(
        name=str(topic_path),
        partition_config=Topic.PartitionConfig(
            count=2,
            capacity=Topic.PartitionConfig.Capacity(
                publish_mib_per_sec=4, subscribe_mib_per_sec=8,
            ),
        ),
        retention_config=Topic.RetentionConfig(
            per_partition_bytes=30 * 1024 * 1024 * 1024,
        ),
    )

    try:
        response = client.get_topic(topic.name)
    except NotFound:
        response = client.create_topic(topic)

    yield response

    try:
        client.delete_topic(response.name)
    except NotFound as e:
        print(e.message)
def delete_lite_topic(project_number, cloud_region, zone_id, topic_id):
    # [START pubsublite_delete_topic]
    from google.api_core.exceptions import NotFound
    from google.cloud.pubsublite import AdminClient
    from google.cloud.pubsublite.types import CloudRegion, CloudZone, TopicPath

    # TODO(developer):
    # project_number = 1122334455
    # cloud_region = "us-central1"
    # zone_id = "a"
    # topic_id = "your-topic-id"

    cloud_region = CloudRegion(cloud_region)
    location = CloudZone(cloud_region, zone_id)
    topic_path = TopicPath(project_number, location, topic_id)

    client = AdminClient(cloud_region)
    try:
        client.delete_topic(topic_path)
        print(f"{topic_path} deleted successfully.")
    except NotFound:
        print(f"{topic_path} not found.")