Add support for returning only certain fields or links in the API.
Review Request #6846 — Created Jan. 31, 2015 and discarded
API resources now support a couple new query arguments for limiting the
results in a payload, in order to reduce database queries and payload
sizes.The
?only-fields=
query argument limits the returned fields in the
payload to the comma-separated list of field names. If the value is
blank, then no fields will be returned, leaving only links.Likewise, the
?only-links=
query argument limits the returned links in the
payload. It behaves exactly like?only-fields=
.Resources that inject custom fields into the payload outside of
serialize_object()
can callget_only_fields()
andget_only_links()
to
determine whether to include specific fields.
Unit tests pass.
Used this with changes in RBTools and verified, through some extra debugging
information, that only the requested fields/links were being returned.