The FindRequest class

class pyspacegdn.requests.FindRequest(spacegdn)

A find request to SpaceGDN.

This class represents and builds a find request for SpaceGDN. It should be used to both create the request, and execute it.

Methods:
type()
Set the type of elements in the response
include_parents()
Define if the response should contain parent data
parents()
Set parents
parent()
Set a parent, alias for parents
sort()
Define how the results should be sorted
where()
Add filters
FindRequest.fetch()
Send the request to SpaceGDN and fetch the results
__init__(spacegdn)

Instantiate a new Request.

This should only be called by classes, functions or modules in pySpaceGDN.

fetch()

Run the request and fetch the results.

This method will compile the request, send it to the SpaceGDN endpoint defined with the SpaceGDN object and wrap the results in a pyspacegdn.Response object.

Returns a pyspacegdn.Response object.

include_parents()

Include parent data in the response.

This is also called ‘bubbling’. See also the documentation on bubbling.

parent(*parents)

Find only elements that are children of these parents.

The order of the parents matter. In reality only the last parent is accounted for. This method will override the old parents each time it’s called.

Arguments:
*parents (str)
The parents all elements must have
parents(*parents)

Find only elements that are children of these parents.

The order of the parents matter. In reality only the last parent is accounted for. This method will override the old parents each time it’s called.

Arguments:
*parents (str)
The parents all elements must have
sort(*sort)

Sort the results.

Define how the results should be sorted. The arguments should be tuples of string defining the key and direction to sort by. For example (‘name’, ‘asc’) and (‘version’, ‘desc’). The first sorte rule is considered first by the API. See also the API documentation on sorting.

Arguments:
*sort (tuple)
The rules to sort by
type(return_type)

Set the type the result elements has to be of.

Arguments:
return_type (str)
The type of elements to get
where(*where)

Filter the results.

Filter the results by provided rules. The rules should be tuples that look like this:

('<key>', '<operator>', '<value>')

For example:

('name', '$eq', 'Vanilla Minecraft')

This is also covered in the documentation of the SpaceGDN API.

Related Topics

This Page