apicrud.Trashcan

class apicrud.Trashcan

Deleted-items management

Read/Update/Delete/find controller operations.

This class provides permission-based, paginated access to database resources that have been marked inactive.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

create(body[, id_prefix, limit_related])

Controller for POST endpoints.

db_get(id)

Activate a SQLalchemy query object for the specified ID in the current model

delete(ids)

Controller for DELETE endpoints.

find(**kwargs)

Find records which match query parameters passed from connexion by name, in a dictionary that also includes user and token info

get(id)

Controller for GET endpoint.

update(id, body)

Controller for PUT endpoint.

update_contact(id, body)

This is a special-case function for the contact-update resource

static delete(ids)

Controller for DELETE endpoints. This method looks for existing records, evaluates user’s permissions, and updates or removes rows in the back-end database.

Parameters

ids (list of str) – composite record IDs to be flagged for removal

Returns

first element is a dict with the id, second element is response code (200 on success)

Return type

tuple

static find(**kwargs)

Find records which match query parameters passed from connexion by name, in a dictionary that also includes user and token info

Due to limitation of react-admin, pagination is provided for both offset/limit and cursor/limit. The offset approach requires unfortunate hacks and is not recommended: use cursor_next.

Parameters
  • cursor_next (str) – pagination token to fetch subsequent records

  • filter (dict) – field/value pairs to query (simple queries only, with string or list matching; or * for any)

  • limit (int) – max records to fetch

  • offset (int) – old-style pagination starting offset

  • sort (str) – <field>[:{asc|desc}]

  • status (str) – value is added to filter

Returns

items (list), count(int), cursor_next (str)

Return type

dict

static get(id)

Controller for GET endpoint. This method evaluates privacy settings against the user’s permissions, looks up category, owner and geocode values, and fetches a single record.

Parameters

id (str) – composite ID of the desired resource

Returns

first element is a dict with the object or error message, second element is response code (200 on success)

Return type

tuple

static update(id, body)

Controller for PUT endpoint. This method looks for an existing record, evaluates user’s permissions, and updates the row in the back-end database.

Parameters

body (dict) – fields to be updated

Returns

first element is a dict with the id, second element is response code (200 on success)

Return type

dict