Skip to content

Workflows return 'Executing', not 'Running' (or possibly both). #116

Open
@rob-buskens-sp

Description

@rob-buskens-sp

/Users/rob.buskens/Documents/Code/workflows/venv/lib/python3.13/site-packages/sailpoint/v2025/models/workflow_execution.py:46: UserWarning: must be one of enum values ('Completed', 'Failed', 'Canceled', 'Running', 'Queued') unknown value: Executing
warnings.warn(f"must be one of enum values ('Completed', 'Failed', 'Canceled', 'Running', 'Queued') unknown value: {value}")

The status enum is missing Executing although that's what is returned by the underlying API call.

type: object
properties:
  id:
    type: string
    description: Workflow execution ID.
    example: b393f4e2-4785-4d7f-ab27-3a6b8ded4c81
  workflowId:
    type: string
    description: Workflow ID.
    example: d201c5d9-d37b-4a2f-af14-66414f39d568
  requestId:
    type: string
    description: Backend ID that tracks a workflow request in the system. Provide this ID in a customer support ticket for debugging purposes.
    example: 41e12a74fa7b4a6a98ae47887b64acdb
  startTime:
    type: string
    format: date-time
    description: Date/time when the workflow started.
    example: "2022-02-07T20:13:29.356648026Z"
  closeTime:
    type: string
    format: date-time
    description: Date/time when the workflow ended.
    example: "2022-02-07T20:13:31.682410165Z"
  status:
    description: Workflow execution status.
    type: string
    enum:
    - "Completed"
    - "Failed"
    - "Canceled"
    - "Running"
    - "Queued"
    example: "Completed"

https://github.com/sailpoint-oss/api-specs/blob/1d0c5fcc1a2ae01125bedb52b160d877478312af/idn/v2025/schemas/workflows/WorkflowExecution.yaml#L32C5-L32C16

import sailpoint
import sailpoint.v2025
import logging

from sailpoint.configuration import Configuration
from sailpoint.paginator import Paginator
import sailpoint.v3.models
from sailpoint.v3.models.search import Search
from pprint import pprint
from urllib3 import Retry

import os
import json
from datetime import datetime

# from http.client import HTTPConnection

if __name__ == '__main__':
    logging.basicConfig(filename='workflow.log',
                        filemode='a',
                        format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
                        datefmt='%H:%M:%S',
                        level=getattr(logging, "DEBUG"))
                        
    # HTTPConnection.debuglevel = 1 # Low level, goes to stdout
    # Requests logging
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel('DEBUG')
    requests_log.propagate = True

    configuration = Configuration()
    configuration.retries = Retry(
            total = 5,
            respect_retry_after_header = True
        )

    with sailpoint.v2025.ApiClient(configuration) as v2025_client:

        workflow_executions = sailpoint.v2025.WorkflowsApi(v2025_client).get_workflow_executions(id = '686ed244-5f9a-49fc-a490-215bdd3fcd2e')

        for workflow_execution in workflow_executions:
            start_time_date = workflow_execution.start_time.strftime("%Y-%m-%d")
            status = workflow_execution.status
            os.makedirs(start_time_date, exist_ok=True)

            workflow_execution_history_events = sailpoint.v2025.WorkflowsApi(v2025_client).get_workflow_execution_history(id = workflow_execution.id)

            events = []
            for workflow_event in workflow_execution_history_events:
                events.append(json.loads(workflow_event.model_dump_json(indent=2)))
            events.sort(key=lambda x: datetime.fromisoformat(x['timestamp']))

            with open(f"{start_time_date}/{workflow_execution.id}-{status}.json","w") as execution_history_file:
                json.dump(events, execution_history_file, indent=2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions