Skip to content

Migrate collection operations from APIHarnessV2 to CustomStorage#118

Draft
mraible wants to merge 6 commits intomainfrom
chore/use-custom-storage-service-class
Draft

Migrate collection operations from APIHarnessV2 to CustomStorage#118
mraible wants to merge 6 commits intomainfrom
chore/use-custom-storage-service-class

Conversation

@mraible
Copy link
Copy Markdown
Contributor

@mraible mraible commented Mar 31, 2026

Replaces APIHarnessV2 (Uber class) with CustomStorage (service class) for collection CRUD operations in the log-event function handler.

The Falcon Foundry Functions Editor parses from falconpy import CustomStorage to auto-detect required OAuth scopes (custom-storage:read, custom-storage:write). It cannot parse the Uber class .command() pattern, which means apps using APIHarnessV2 require manual scope configuration.

Changes in log-event/main.py:

  • APIHarnessV2().command("PutObject", ...)CustomStorage(ext_headers=...).PutObject(...)
  • APIHarnessV2().command("SearchObjects", ...)client.SearchObjects(...)
  • Added defensive .get("body", {}) for SearchObjects response handling

The ext_headers constructor parameter replaces per-request headers kwargs, applying the X-CS-APP-ID header to all requests from the client instance. Response shapes and behavior are unchanged.

Draft because the associated blog post needs updating to match the new patterns.

mraible added 2 commits March 23, 2026 11:29
Use CustomStorage service class instead of APIHarnessV2 (Uber class) for
collection CRUD operations. Service class imports enable the Foundry Functions
Editor to auto-detect required OAuth scopes, which is not possible with
Uber class .command() calls.

Changes:
- Replace APIHarnessV2 with CustomStorage(ext_headers=_app_headers())
- Replace .command("PutObject"/"SearchObjects") with .PutObject()/.SearchObjects()
- Add defensive .get() for SearchObjects response body
- Move header construction to _app_headers() helper
@mraible mraible requested a review from a team March 31, 2026 20:27
mraible added 2 commits March 31, 2026 14:49
Align test mocks with the APIHarnessV2-to-CustomStorage migration in
main.py: patch CustomStorage instead of APIHarnessV2, mock individual
PutObject/SearchObjects methods instead of .command() side_effect, and
verify ext_headers construction instead of per-request headers kwargs.
"""Build app headers for CustomStorage construction."""
app_id = os.environ.get("APP_ID")
if app_id:
return {"X-CS-APP-ID": app_id}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don’t need this if calling from a app function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add verifyWorkflowExecutionCompleted() that polls the execution status
page until terminal state, catching function failures that were
previously invisible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants