Listing Response¶
-
class
moco_wrapper.util.response.
ListingResponse
(response)¶ Class for handling http responses where the response body is a json list.
Listings in Moco are usually paginated (if there are more than 100 items that fit your request).
Example usage:
from moco_wrapper import Moco m = Moco() all_projects = [] project_list = m.Project.getlist() all_projects.extend(project_list.items) while not project_list.is_last: project_list = m.Project.getlist(page=project_list.next_page) all_projects.extend(project_list.items)
Or with a for loop:
from moco_wrapper import Moco m = Moco all_projects = [] project_list = m.Project.getlist() all_projects.extend(project_list.items) for i in range(2, project_list.last_page + 1): #first page alread queried project_list = m.Project.getlist(page=i) all_projects.extend(project_list.items)
-
current_page
¶ Returns the current page number
Type: int
-
is_last
¶ Returns wether the current page is the last page
Type: bool
-
items
¶ Get the list of objects the response contains
Type: list m = Moco() project_list = m.Project.getlist() for item in project_list.items: print(item)
See also
-
last_page
¶ Returns the last page number
Type: int
-
next_page
¶ Returns the next page number
Type: int Note
Do not use this for checking if there is another page, use
is_last()
-
page_size
¶ Returns the amount of items that are in the current page (usually 100)
Type: int
-
response
¶ http response object
-
total
¶ Returns the amount of items that are in the current (paginated) collection
Type: int
-