nemoguardrails.http.request
Managed request lifecycle helpers for outbound HTTP calls.
Module Contents
Functions
API
async
Yield an injected client or create and close an owned client.
async
Execute one outbound HTTP request with deterministic client ownership.
Parameters:
client
Optional caller-owned client. When omitted, factory creates
a client that is closed after the request.
method
HTTP method.
url
Absolute request URL.
headers
Optional request headers.
params
Optional query parameters.
json
Optional JSON-serializable request body.
content
Optional raw request body.
timeout
Optional total request timeout in seconds.
raise_for_status
Whether responses with status 400 or greater raise.
factory
Factory for an owned client when client is omitted.
Returns: HTTPResponse
The materialized transport-neutral response.
Raises:
HTTPStatusError: Ifraise_for_statusis enabled and the response status is 400 or greater.TypeError: Iffactoryreturns a client that cannot be closed.