udata-hydra-csvapi 0.3.2.dev6__py3-none-any.whl → 0.3.2.dev7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,8 @@ PAGE_SIZE_DEFAULT = 20
7
7
  PAGE_SIZE_MAX = 50
8
8
  BATCH_SIZE = 50000
9
9
  DOC_PATH = "/api/doc"
10
- ALLOW_AGGREGATION = [
10
+ ALLOW_AGGREGATION = false
11
+ ALLOW_AGGREGATION_EXCEPTIONS = [
11
12
  "dddddddd-7777-eeee-8888-ffffffffffff", # without indexes
12
13
  "aaaaaaaa-9999-bbbb-1010-cccccccccccc", # with indexes
13
14
  ] # list of resource_ids
api_tabular/core/utils.py CHANGED
@@ -6,7 +6,7 @@ from api_tabular.core.error import QueryException
6
6
 
7
7
 
8
8
  def is_aggregation_allowed(resource_id: str) -> bool:
9
- return resource_id in config.ALLOW_AGGREGATION
9
+ return config.ALLOW_AGGREGATION or resource_id in config.ALLOW_AGGREGATION_EXCEPTIONS
10
10
 
11
11
 
12
12
  def process_total(res: Response | ClientResponse) -> int:
@@ -149,7 +149,11 @@ async def get_health(request):
149
149
  @routes.get(r"/api/aggregation-exceptions/")
150
150
  async def get_aggregation_exceptions(request):
151
151
  """Return the list of resources for which aggregation queries are allowed"""
152
- return web.json_response(config.ALLOW_AGGREGATION)
152
+ body = {
153
+ "allowed": config.ALLOW_AGGREGATION,
154
+ "exceptions": config.ALLOW_AGGREGATION_EXCEPTIONS,
155
+ }
156
+ return web.json_response(body)
153
157
 
154
158
 
155
159
  async def app_factory():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: udata-hydra-csvapi
3
- Version: 0.3.2.dev6
3
+ Version: 0.3.2.dev7
4
4
  Summary: API for CSV converted by udata-hydra
5
5
  Author-email: "data.gouv.fr" <opendatateam@data.gouv.fr>
6
6
  License-Expression: MIT
@@ -323,7 +323,9 @@ column_name__sort=desc
323
323
  ```
324
324
 
325
325
  #### Aggregation Operators
326
- > ⚠️ **WARNING**: Aggregation requests are only available for resources that are listed in the `ALLOW_AGGREGATION` list of the config file, which can be seen at the `/api/aggregation-exceptions/` endpoint, and on columns that have an index.
326
+ > ⚠️ **WARNING**: Aggregation requests are disabled by default.
327
+ > You can allow or disallow it for all resources with the `ALLOW_AGGREGATION` config. If `ALLOW_AGGREGATION` is set to `false`, you can specify allow exceptions by listing these in the `ALLOW_AGGREGATION_EXCEPTIONS` list.
328
+ > You can get the current status and exceptions at `/api/aggregation-exceptions/` endpoint.
327
329
 
328
330
  ```
329
331
  # group by values
@@ -479,7 +481,8 @@ Configuration is handled through TOML files and environment variables. The defau
479
481
  | `PAGE_SIZE_MAX` | `50` | Maximum allowed page size |
480
482
  | `BATCH_SIZE` | `50000` | Batch size for streaming |
481
483
  | `DOC_PATH` | `/api/doc` | Swagger documentation path |
482
- | `ALLOW_AGGREGATION` | `["dddddddd-7777-eeee-8888-ffffffffffff", "aaaaaaaa-9999-bbbb-1010-cccccccccccc"]` | List of resource IDs allowed for aggregation |
484
+ | `ALLOW_AGGREGATION` | `False` | Whether aggregation queries are allowed (`column__groupby`). If False, it can still be explicitly allowed with `ALLOW_AGGREGATION_EXCEPTIONS` |
485
+ | `ALLOW_AGGREGATION_EXCEPTIONS` | `["dddddddd-7777-eeee-8888-ffffffffffff", "aaaaaaaa-9999-bbbb-1010-cccccccccccc"]` | List of resource IDs allowed for aggregation |
483
486
 
484
487
  ### Environment Variables
485
488
 
@@ -1,5 +1,5 @@
1
1
  api_tabular/__init__.py,sha256=sYG6CMz-twob-QLyfsPYRc6cWDtqWXvq_N5Dxk-U5qA,2263
2
- api_tabular/config_default.toml,sha256=3zQMpzr87qwd23dG_scGUptj0T3IUOjaHecI4ppJBqY,384
2
+ api_tabular/config_default.toml,sha256=cX506NdqHW7gK_2aZjzLiz0Z4gMSl1tU_tI4i4BvuXs,421
3
3
  api_tabular/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  api_tabular/core/data.py,sha256=5j-3d_el7LMoHpn6V__UdhYHD6GiJbwdH67jrnOYWZQ,1459
5
5
  api_tabular/core/error.py,sha256=xRt6fkQfsiupv0tWWzdX0DJjAKbw1n0tRxFyt15VBLA,1062
@@ -8,15 +8,15 @@ api_tabular/core/query.py,sha256=m98cO16mVkz0cSNICesgjC8MNVEfDW_645sz-DTd2Pw,557
8
8
  api_tabular/core/sentry.py,sha256=fN5MrDZszLnzLXF3b_nUymPVB0ffNn4PI7xS1GtJNyE,948
9
9
  api_tabular/core/swagger.py,sha256=0RZFu941CD3qWt2R6e3nnlcrkYjjAHU5eOFl4jH2liA,14188
10
10
  api_tabular/core/url.py,sha256=af7VKfrMtKMzlHrGgtLDLuRBim4qFv7xlt2PYxAyW2g,761
11
- api_tabular/core/utils.py,sha256=SWU1gVkOq728-eZHmZzlyA3pQg6kelEf3SMlL-uEbns,1032
11
+ api_tabular/core/utils.py,sha256=VTxPiNWE3FF6f2aX5Q21XPezCL3sVZ_KICIrGBJRm_E,1071
12
12
  api_tabular/core/version.py,sha256=OKLg0l1CpDRHV2hsqVgtSihoo3tg0aMG6kzMILtQ-bY,250
13
13
  api_tabular/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  api_tabular/metrics/app.py,sha256=5kZXzAiFh1tSNYO5GEz67m4zTsTVyoIkgcelDGyT1zE,4637
15
15
  api_tabular/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- api_tabular/tabular/app.py,sha256=JgqL1svglQ_fD5ndhft_Cm7HmTh5FuyoxYUPGS1_l-o,6771
16
+ api_tabular/tabular/app.py,sha256=b75nhHTXz4rt2kHNkXSU3-c0LpI91OFzRuDXYmJFx5k,6874
17
17
  api_tabular/tabular/utils.py,sha256=BL2nl04-3imBQG-RZiYvVMjxoBORi4lwrKq8NiWecLY,4487
18
- udata_hydra_csvapi-0.3.2.dev6.dist-info/licenses/LICENSE,sha256=fb-HAYw94ffh--z1cZrWbpk6YKM0p9WFG7kdd0K7uGQ,1062
19
- udata_hydra_csvapi-0.3.2.dev6.dist-info/METADATA,sha256=H8RvN_eAVebPVB0Hf4GfPPMxxNjy0IeyOcuh2x1lBtY,19156
20
- udata_hydra_csvapi-0.3.2.dev6.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
21
- udata_hydra_csvapi-0.3.2.dev6.dist-info/top_level.txt,sha256=MAaK09hxwPhIBBC0i1TdEBAgdu3W_gXnAZqk767gVak,12
22
- udata_hydra_csvapi-0.3.2.dev6.dist-info/RECORD,,
18
+ udata_hydra_csvapi-0.3.2.dev7.dist-info/licenses/LICENSE,sha256=fb-HAYw94ffh--z1cZrWbpk6YKM0p9WFG7kdd0K7uGQ,1062
19
+ udata_hydra_csvapi-0.3.2.dev7.dist-info/METADATA,sha256=si0qB7KLdF-XWFw4EwZNvBEB0FGZDqXgkq6SzGutCI0,19482
20
+ udata_hydra_csvapi-0.3.2.dev7.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
21
+ udata_hydra_csvapi-0.3.2.dev7.dist-info/top_level.txt,sha256=MAaK09hxwPhIBBC0i1TdEBAgdu3W_gXnAZqk767gVak,12
22
+ udata_hydra_csvapi-0.3.2.dev7.dist-info/RECORD,,