0 votes
13 views
ago by (30.6k points)
We want to script housekeeping (delete finished instances older than 90 days, archive old snapshots, pause the event manager during maintenance) instead of clicking through Process Admin. Which API is meant for that and how are the calls shaped?

1 Answer

0 votes
ago by (30.6k points)

The Operations REST API (BAW 20.0.0.1+, context root /ops, Swagger at /ops/docs) is the administration API: it covers what Process Admin and the Process Center console do - containers (process apps / toolkits), versions (snapshots), servers, instance and task housekeeping, event manager, users / teams synchronisation, indexing, and asynchronous operation queues. It needs the Workflow administrator role and the CSRF token on every call.

# CSRF token
TOKEN=$(curl -sk -u admin:pw -X POST "$BAW/ops/system/login" -H "Content-Type: application/json" -d '{"refresh_groups":false,"requested_lifetime":7200}' | jq -r .csrf_token)
H=(-H "BPMCSRFToken: $TOKEN" -u admin:pw)

# 1. delete finished instances of a container older than 90 days (asynchronous: returns a queue id)
curl -sk "${H[@]}" -X DELETE "$BAW/ops/std/bpm/processes?states=finished&container=ORD&ended_before=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ)"
# -> { "id": "op-123", "status": "running" }   ;  poll:  GET $BAW/ops/system/queue/op-123
# count first:  GET $BAW/ops/std/bpm/processes/count?states=finished&container=ORD&ended_before=…

# 2. snapshots: list, deactivate, archive
curl -sk "${H[@]}" "$BAW/ops/std/bpm/containers/ORD?optional_parts=versions"
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/containers/ORD/versions/2.1/deactivate"
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/containers/ORD/versions/2.1/archive"

# 3. event manager: pause during maintenance, resume after
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/event_manager/pause";   curl -sk "${H[@]}" "$BAW/ops/std/bpm/event_manager/monitor";   curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/event_manager/resume"

# 4. other housekeeping: completed tasks, durable messages, EPV history, PDW prune, saved-search acceleration
DELETE /ops/std/bpm/tasks?task_type=USER_TASK&task_status=ALL_COMPLETED&ended_before=…
DELETE /ops/std/bpm/durable_messages?ended_before=…          DELETE /ops/std/bpm/epvs/history?container=ORD&version=2.1
POST   /ops/std/bpm/pdw/prune?days=180                        POST   /ops/std/bpm/saved_search_acceleration/optimize

Rules: long operations are asynchronous - always poll the queue and log its result; run deletions in batches by date window on big databases; pause the event manager only briefly (timers queue up); on CP4BA the same API sits behind the Zen front door (ZenApiKey instead of basic auth). Parameter names differ slightly between 20.x, 22.x and 24.x - generate your scripts from the /ops/docs Swagger of the target level.

References

Related questions

723 questions

807 answers

98 comments

4.8k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...