Skip to main content

namespaces.delete

Removes a namespace and every item in it. The operation runs in the background. Use the returned job_id with namespaces.delete_job_status to poll until completion.
client.namespaces.delete(namespace_name: str) -> dict[str, Any]
API: DELETE /namespaces/{namespace_name} — see Delete namespace

Parameters

namespace_name
str
required
Name of the namespace to delete.
Returns: dict[str, Any]status and job_id for the async delete job. Raises: MoorchehApiError — HTTP 404 when the namespace is not found.

Examples

Delete Namespace
from moorcheh import MoorchehClient

with MoorchehClient("http://localhost:8080") as client:
    resp = client.namespaces.delete("my-documents")
    job_id = resp["job_id"]
    print(f"Delete job started: {job_id}")
Poll Until Complete
import time
from moorcheh import MoorchehClient

with MoorchehClient("http://localhost:8080") as client:
    resp = client.namespaces.delete("my-documents")
    job_id = resp["job_id"]

    while True:
        job = client.namespaces.delete_job_status("my-documents", job_id)
        if job["status"] in ("completed", "failed"):
            break
        time.sleep(0.5)

Error Handling

Error Handling Example
from moorcheh import MoorchehClient, MoorchehApiError

with MoorchehClient("http://localhost:8080") as client:
    try:
        resp = client.namespaces.delete("my-documents")
    except MoorchehApiError as e:
        if e.status_code == 404:
            print("Namespace not found")
        else:
            raise
StatusCause
404Namespace not found
Deleting a namespace frees global item quota for all items that were in it. This cannot be undone.