20 lines
758 B
Python
Executable File
20 lines
758 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Delete test opportunities whose cProjektlink contains a token."""
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
from projektmatch.espocrm import EspoClient # noqa: E402
|
|
|
|
TOKENS = sys.argv[1:] or [
|
|
"python-entwickler-fuer-eine-ki-anwendung",
|
|
"test-engineer-m-w-d-3020995",
|
|
"nproj/3020338", "nproj/3020995"]
|
|
espo = EspoClient(os.environ["PM_ESPO_BASE"], os.environ["PM_ESPO_API_KEY"])
|
|
for token in TOKENS:
|
|
for hit in espo.search("Opportunity", "contains", "cProjektlink", token,
|
|
select="name,cProjektlink", max_size=100):
|
|
espo.delete("Opportunity", hit["id"])
|
|
print(f"deleted {hit['id']} {hit['name']}")
|
|
print("cleanup done")
|