pub async fn request_json(
client: &Client,
base_url: &str,
api_key: &str,
action: &str,
method: Method,
path: &str,
query: Option<&Value>,
body: Option<&Value>,
) -> Result<Value>Expand description
Issues one request against base_url using the caller-supplied client,
and maps the transport/status outcome into a Result.
action is a friendly name (e.g. "clients", "official_list_sites")
used only for the tracing span/logs this wraps the request in. Every
dispatch path — the 8 named UnifiClient methods
and the ~236 actions reachable only through
ActionDispatcher — funnels through this one
function, so this is the one place instrumentation needs to live for it
to cover all of them consistently, rather than only the named methods.
§Errors
Returns UnifiError::Timeout / UnifiError::Connect / UnifiError::Request
for transport failures, UnifiError::Unauthorized / UnifiError::Forbidden /
UnifiError::NotFound / UnifiError::RateLimited for the status codes UniFi
controllers use for those conditions, and UnifiError::UnexpectedStatus for any
other non-success status (its body is JSON when the response was JSON, otherwise
the raw text). For a success status, returns UnifiError::EmptyBody for a GET
with no response body, or UnifiError::Decode if the body isn’t valid
JSON.