gestalt.invoke_support¶
Decode runtime for json_result methods: the standard JSON operation
envelope semantics shared by app invocation results. Success envelopes return
their data, error envelopes and HTTP-error statuses raise InvokeError, and any
other JSON body passes through unchanged. The requests-style ok and
raise_for_status helpers expose the HTTP status semantics directly.
- exception InvokeError(message='app invoke failed', *, app='', operation='', status=None, code=None, body=None, raw_body=b'')¶
Bases:
ExceptionDecoded app invocation failure: an HTTP-error status, an error envelope, or an undecodable result body.
- Parameters:
message (str)
app (str)
operation (str)
status (int | None)
code (str | None)
body (JsonValue)
raw_body (bytes | str)
- Return type:
None
- ok(status)¶
Report whether an HTTP status is a success (200-299), mirroring the requests library’s
Response.ok.- Parameters:
status (int)
- Return type:
bool
- raise_for_status(app, operation, status, body)¶
Raise
InvokeErrorfor an HTTP-error status (400 and above), decoding the result body for the error message and code exactly likedecode_app_result(). Other statuses return None, mirroring the requests library’sResponse.raise_for_status.- Parameters:
app (str)
operation (str)
status (int)
body (bytes)
- Return type:
None
- decode_app_result(app, operation, status, body)¶
Decode one app operation result with the standard JSON envelope semantics: success envelopes return their data, error envelopes and HTTP-error statuses raise
InvokeError, and any other JSON body passes through unchanged.- Parameters:
app (str)
operation (str)
status (int)
body (bytes)
- Return type:
Any
- decode_graphql_result(app, status, body)¶
Decode one GraphQL invocation result like
decode_app_result()and additionally raiseInvokeErrorwhen the response carries a non-empty GraphQL errors array.- Parameters:
app (str)
status (int)
body (bytes)
- Return type:
Any