mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-09 01:49:35 -06:00
20496 fix max_page_size for REST API
This commit is contained in:
parent
c094699dc0
commit
c770e6b45d
@ -214760,7 +214760,7 @@
|
|||||||
},
|
},
|
||||||
"mark_utilized": {
|
"mark_utilized": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Report space as 100% utilized"
|
"description": "Report space as fully utilized"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@ -214869,7 +214869,7 @@
|
|||||||
},
|
},
|
||||||
"mark_utilized": {
|
"mark_utilized": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Report space as 100% utilized"
|
"description": "Report space as fully utilized"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@ -231880,7 +231880,7 @@
|
|||||||
},
|
},
|
||||||
"mark_utilized": {
|
"mark_utilized": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Report space as 100% utilized"
|
"description": "Report space as fully utilized"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -252203,7 +252203,7 @@
|
|||||||
},
|
},
|
||||||
"mark_utilized": {
|
"mark_utilized": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Report space as 100% utilized"
|
"description": "Report space as fully utilized"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@ -44,22 +44,28 @@ class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
|||||||
return list(queryset[self.offset:])
|
return list(queryset[self.offset:])
|
||||||
|
|
||||||
def get_limit(self, request):
|
def get_limit(self, request):
|
||||||
|
max_limit = self.default_limit
|
||||||
|
MAX_PAGE_SIZE = get_config().MAX_PAGE_SIZE
|
||||||
|
if MAX_PAGE_SIZE:
|
||||||
|
max_limit = min(max_limit, MAX_PAGE_SIZE)
|
||||||
|
|
||||||
if self.limit_query_param:
|
if self.limit_query_param:
|
||||||
MAX_PAGE_SIZE = get_config().MAX_PAGE_SIZE
|
|
||||||
if MAX_PAGE_SIZE:
|
|
||||||
MAX_PAGE_SIZE = max(MAX_PAGE_SIZE, self.default_limit)
|
|
||||||
try:
|
try:
|
||||||
limit = int(request.query_params[self.limit_query_param])
|
limit = int(request.query_params[self.limit_query_param])
|
||||||
if limit < 0:
|
if limit < 0:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
# Enforce maximum page size, if defined
|
|
||||||
if MAX_PAGE_SIZE:
|
if MAX_PAGE_SIZE:
|
||||||
return MAX_PAGE_SIZE if limit == 0 else min(limit, MAX_PAGE_SIZE)
|
if limit == 0:
|
||||||
return limit
|
max_limit = MAX_PAGE_SIZE
|
||||||
|
else:
|
||||||
|
max_limit = min(MAX_PAGE_SIZE, limit)
|
||||||
|
else:
|
||||||
|
max_limit = limit
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return self.default_limit
|
return max_limit
|
||||||
|
|
||||||
def get_queryset_count(self, queryset):
|
def get_queryset_count(self, queryset):
|
||||||
return queryset.count()
|
return queryset.count()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user