Merge "Make the API page size configurable" into feature/1.0

This commit is contained in:
Zuul 2019-06-04 22:45:37 +00:00 committed by Gerrit Code Review
commit 47b98a6aea
4 changed files with 20 additions and 1 deletions

View File

@ -187,9 +187,10 @@ WSGI_APPLICATION = "ara.server.wsgi.application"
ROOT_URLCONF = "ara.server.urls"
APPEND_SLASH = False
PAGE_SIZE = settings.get("PAGE_SIZE", 100)
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": 100,
"PAGE_SIZE": PAGE_SIZE,
"DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",),
"DEFAULT_RENDERER_CLASSES": (
"rest_framework.renderers.JSONRenderer",
@ -232,6 +233,7 @@ if not os.path.exists(DEFAULT_SETTINGS) and "ARA_SETTINGS" not in os.environ:
LOGGING=LOGGING,
READ_LOGIN_REQUIRED=READ_LOGIN_REQUIRED,
WRITE_LOGIN_REQUIRED=WRITE_LOGIN_REQUIRED,
PAGE_SIZE=PAGE_SIZE,
)
with open(DEFAULT_SETTINGS, "w+") as settings_file:
comment = f"""

View File

@ -48,6 +48,8 @@ For more details, click on the configuration parameters.
+--------------------------------+--------------------------------------------------------+------------------------------------------------------+
| ARA_LOG_LEVEL_ | ``INFO`` | Log level of the different components |
+--------------------------------+--------------------------------------------------------+------------------------------------------------------+
| ARA_PAGE_SIZE_ | ``100`` | Amount of results returned per page by the API |
+--------------------------------+--------------------------------------------------------+------------------------------------------------------+
| ARA_READ_LOGIN_REQUIRED_ | ``False`` | Whether authentication is required for reading data |
+--------------------------------+--------------------------------------------------------+------------------------------------------------------+
| ARA_SECRET_KEY_ | Randomized token, see ARA_SECRET_KEY_ | Django's SECRET_KEY_ setting |
@ -346,6 +348,17 @@ python library.
.. _dynaconf: https://github.com/rochacbruno/dynaconf
ARA_PAGE_SIZE
~~~~~~~~~~~~~
- **Environment variable**: ``ARA_PAGE_SIZE``
- **Configuration file variable**: ``PAGE_SIZE``
- **Type**: ``integer``
- **Default**: ``50``
- **Provided by**: django-rest-framework `pagination <https://www.django-rest-framework.org/api-guide/pagination/>`_
When querying the API server, the amount of items per page returned.
ARA_READ_LOGIN_REQUIRED
~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -96,6 +96,9 @@ ara_api_read_login_required: false
# ARA_WRITE_LOGIN_REQUIRED - Whether authentication is required for writing data
ara_api_write_login_required: false
# ARA_PAGE_SIZE - Amount of results returned per page by the API
ara_api_page_size: 100
# ARA_LOG_LEVEL - Log level of the different components
ara_api_log_level: INFO

View File

@ -79,6 +79,7 @@
SECRET_KEY: "{{ ara_api_secret_key }}"
READ_LOGIN_REQUIRED: "{{ ara_api_read_login_required }}"
WRITE_LOGIN_REQUIRED: "{{ ara_api_write_login_required }}"
PAGE_SIZE: "{{ ara_api_page_size }}"
set_fact:
ara_api_configuration: "{'{{ ara_api_env }}': {{ reconciled_configuration }} }"
no_log: yes