commonground-api-common 2.0.1__py3-none-any.whl → 2.1.0__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.
- {commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/METADATA +3 -3
- {commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/RECORD +11 -11
- vng_api_common/__init__.py +1 -1
- vng_api_common/client.py +12 -9
- vng_api_common/migrations/0006_delete_apicredential.py +1 -0
- vng_api_common/views.py +13 -2
- {commonground_api_common-2.0.1.data → commonground_api_common-2.1.0.data}/scripts/generate_schema +0 -0
- {commonground_api_common-2.0.1.data → commonground_api_common-2.1.0.data}/scripts/patch_content_types +0 -0
- {commonground_api_common-2.0.1.data → commonground_api_common-2.1.0.data}/scripts/use_external_components +0 -0
- {commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/WHEEL +0 -0
- {commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/top_level.txt +0 -0
{commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: commonground-api-common
|
3
|
-
Version: 2.0
|
3
|
+
Version: 2.1.0
|
4
4
|
Summary: Commonground API tooling
|
5
5
|
Home-page: https://github.com/maykinmedia/commonground-api-common
|
6
6
|
Author: Maykin Media, VNG-Realisatie
|
@@ -29,10 +29,10 @@ Requires-Dist: drf-yasg>=1.20.0
|
|
29
29
|
Requires-Dist: drf-nested-routers>=0.94.1
|
30
30
|
Requires-Dist: iso-639
|
31
31
|
Requires-Dist: isodate
|
32
|
-
Requires-Dist: notifications-api-common>=0.3.
|
32
|
+
Requires-Dist: notifications-api-common>=0.3.1
|
33
33
|
Requires-Dist: zgw-consumers>=0.35.1
|
34
34
|
Requires-Dist: oyaml
|
35
|
-
Requires-Dist: PyJWT>=2.0
|
35
|
+
Requires-Dist: PyJWT>=2.1.0
|
36
36
|
Requires-Dist: requests
|
37
37
|
Requires-Dist: requests-mock
|
38
38
|
Requires-Dist: coreapi
|
@@ -1,12 +1,12 @@
|
|
1
|
-
commonground_api_common-2.0.
|
2
|
-
commonground_api_common-2.0.
|
3
|
-
commonground_api_common-2.0.
|
4
|
-
vng_api_common/__init__.py,sha256=
|
1
|
+
commonground_api_common-2.1.0.data/scripts/generate_schema,sha256=UKhznmbHX1zUjPx8G3XtxUPQiqnyd3TOIXs27Tnjl7U,952
|
2
|
+
commonground_api_common-2.1.0.data/scripts/patch_content_types,sha256=dpGpYrZOZe8O5CHWd0F0QnP6Wk_7lK6DyuVZpBPr4mY,319
|
3
|
+
commonground_api_common-2.1.0.data/scripts/use_external_components,sha256=xvvbngO2aDUagVXv4xRUqPaVtH_eOaVMWLQ8lyAPhEA,369
|
4
|
+
vng_api_common/__init__.py,sha256=Xybt2skBZamGMNlLuOX1IG-h4uIxqUDGAO8MIGWrJac,22
|
5
5
|
vng_api_common/admin.py,sha256=iFtUPGf-ha0I-bXgq8QIFrP23Kzk_H3FlgAjt0U-ip0,259
|
6
6
|
vng_api_common/apps.py,sha256=wOQuxUImMpH39R0JrDdCZp5ADaUM8jU8vFPFW9froSs,3458
|
7
7
|
vng_api_common/checks.py,sha256=tOyfV7MMLGh4anrd_W30LvJCxiyQ4sFs1mGd9mtrEc0,1175
|
8
8
|
vng_api_common/choices.py,sha256=dboFRoM34GpRUpxB9WexexccopcQSogu1QIyY4B9ACY,541
|
9
|
-
vng_api_common/client.py,sha256=
|
9
|
+
vng_api_common/client.py,sha256=HNLc86RwczAudPBDgH_zQncE19OUaLyhSnacQRxJO0c,1972
|
10
10
|
vng_api_common/compat.py,sha256=n4jDFSPzXnh-D_VXjftKMCJYj_q_t6eJrUTWLayl8jQ,768
|
11
11
|
vng_api_common/constants.py,sha256=yYtnYId9alRuhGBoqaO8lkXYi_ATi2FW-wEDGRpiRuQ,10948
|
12
12
|
vng_api_common/decorators.py,sha256=_p-mAyi5Na_-ll00ErcQ3mRoZNCsJzYDAliXn50Bmes,278
|
@@ -35,7 +35,7 @@ vng_api_common/urls.py,sha256=9IWHYLlEIIHNaZ_Zq02qNQ2HJpETb7o-89r7yBM_tQs,270
|
|
35
35
|
vng_api_common/utils.py,sha256=zrtpssOA-NcJHhAlxioBiXeY3G2R_uf0l8oWkDD_EiE,8511
|
36
36
|
vng_api_common/validators.py,sha256=Y1OQrmnH3U01hnCizWc_xjpSSGUWKlwiFxeHHGCThpI,11012
|
37
37
|
vng_api_common/version.py,sha256=yJV9_yTM7Qnzg0zGNkJQkN9Uai3I_ZUkcyseJRPRk5I,129
|
38
|
-
vng_api_common/views.py,sha256=
|
38
|
+
vng_api_common/views.py,sha256=trsAZjyZt0PRaZOCDvjMJ5xTz4Ic0u4M73k0K_2qS4o,7620
|
39
39
|
vng_api_common/viewsets.py,sha256=z5pzvSymFiiuCjP_-uuW-3OJKZY_psPAt8fWeWySU0c,2278
|
40
40
|
vng_api_common/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
41
|
vng_api_common/api/permissions.py,sha256=okbwiscxlAtbQWTCRDLL2reOxgj0rRDZeDcrtXAYq00,739
|
@@ -132,7 +132,7 @@ vng_api_common/migrations/0002_apicredential.py,sha256=AYgkLMizI0g-Ogth8j_FVJHTD
|
|
132
132
|
vng_api_common/migrations/0003_auto_20190417_1145.py,sha256=0ABqDggAdjmZxhSsLrMb2ZBwTcR1BOWo1Tn8StfiG0A,1001
|
133
133
|
vng_api_common/migrations/0004_auto_20190517_0903.py,sha256=-Qcei-AJx4SXbEYMojmYInhV74uKtDncGP1PLs6hn0M,707
|
134
134
|
vng_api_common/migrations/0005_auto_20190614_1346.py,sha256=5n8SVpbEJzLrSx-7d446Vy1--SaDfO05hAltrSRQx6o,2949
|
135
|
-
vng_api_common/migrations/0006_delete_apicredential.py,sha256=
|
135
|
+
vng_api_common/migrations/0006_delete_apicredential.py,sha256=lN9NFSbwMGlrREe_5LtqxiPk74_1iCbeoMhY5B7pXjc,3681
|
136
136
|
vng_api_common/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
137
137
|
vng_api_common/notifications/__init__.py,sha256=UvHr_M8s-dZjCQOp60rLDqP_T3D0CgRIqc8ry5bIM8c,229
|
138
138
|
vng_api_common/notifications/apps.py,sha256=7grk1hxQn5usAWV-sWATmNJ4TwSvT3izXVvV-L-zb_s,208
|
@@ -191,7 +191,7 @@ vng_api_common/tests/auth.py,sha256=IKDWTEFv4Bign4F70-ibsFcnJqRxEJaXvqaPQJWa1xY,
|
|
191
191
|
vng_api_common/tests/caching.py,sha256=zfIw5cRRvO9cekHZZKfRqZc8cx5IfJUYNmcH6cuIMg4,624
|
192
192
|
vng_api_common/tests/schema.py,sha256=irt_kIp1uJsnYIJlrpk0-qM9W6i44WyX3GSiJvGUfdU,2288
|
193
193
|
vng_api_common/tests/urls.py,sha256=PFrYzQbBC0TFPMEn3uPhcBG0IQs9JsEPqckicJT1UA4,2159
|
194
|
-
commonground_api_common-2.0.
|
195
|
-
commonground_api_common-2.0.
|
196
|
-
commonground_api_common-2.0.
|
197
|
-
commonground_api_common-2.0.
|
194
|
+
commonground_api_common-2.1.0.dist-info/METADATA,sha256=SCXtFBl_MO_jXJ-9ulYtK3dX0bTQcuK84IDaWTwbRUM,6497
|
195
|
+
commonground_api_common-2.1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
196
|
+
commonground_api_common-2.1.0.dist-info/top_level.txt,sha256=vPismc83zPzWXTmlNCCwfDlFV9iygJYxNJW5iDjKTgw,15
|
197
|
+
commonground_api_common-2.1.0.dist-info/RECORD,,
|
vng_api_common/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.0
|
1
|
+
__version__ = "2.1.0"
|
vng_api_common/client.py
CHANGED
@@ -3,10 +3,6 @@ Interface to get a client object for a given URL.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
import logging
|
6
|
-
from typing import Any, Optional
|
7
|
-
|
8
|
-
from django.conf import settings
|
9
|
-
from django.utils.module_loading import import_string
|
10
6
|
|
11
7
|
from ape_pie import APIClient
|
12
8
|
from requests import JSONDecodeError, RequestException, Response
|
@@ -18,6 +14,10 @@ class ClientError(RuntimeError):
|
|
18
14
|
pass
|
19
15
|
|
20
16
|
|
17
|
+
class NoServiceConfigured(RuntimeError):
|
18
|
+
pass
|
19
|
+
|
20
|
+
|
21
21
|
# TODO: use more approriate method name
|
22
22
|
def to_internal_data(response: Response) -> dict | list | None:
|
23
23
|
try:
|
@@ -33,7 +33,6 @@ def to_internal_data(response: Response) -> dict | list | None:
|
|
33
33
|
raise
|
34
34
|
raise ClientError(response_json if response_json is not None else {}) from exc
|
35
35
|
|
36
|
-
assert response_json
|
37
36
|
return response_json
|
38
37
|
|
39
38
|
|
@@ -56,7 +55,9 @@ class Client(APIClient):
|
|
56
55
|
return super().request(method, url, *args, **kwargs)
|
57
56
|
|
58
57
|
|
59
|
-
def get_client(
|
58
|
+
def get_client(
|
59
|
+
url: str, raise_exceptions: bool = False, **client_kwargs
|
60
|
+
) -> Client | None:
|
60
61
|
"""
|
61
62
|
Get a client instance for the given URL.
|
62
63
|
If no suitable client is found, ``None`` is returned.
|
@@ -64,10 +65,12 @@ def get_client(url: str) -> Client | None:
|
|
64
65
|
from zgw_consumers.client import build_client
|
65
66
|
from zgw_consumers.models import Service
|
66
67
|
|
67
|
-
service:
|
68
|
+
service: Service | None = Service.get_service(url)
|
68
69
|
|
69
70
|
if not service:
|
70
71
|
logger.warning(f"No service configured for {url}")
|
71
|
-
|
72
|
+
if raise_exceptions:
|
73
|
+
raise NoServiceConfigured(f"{url} API should be added to Service model")
|
74
|
+
return
|
72
75
|
|
73
|
-
return build_client(service, client_factory=Client)
|
76
|
+
return build_client(service, client_factory=Client, **client_kwargs)
|
vng_api_common/views.py
CHANGED
@@ -174,7 +174,7 @@ def _test_ac_config() -> list:
|
|
174
174
|
return checks
|
175
175
|
|
176
176
|
|
177
|
-
def _test_nrc_config() -> list:
|
177
|
+
def _test_nrc_config(check_autorisaties_subscription=True) -> list:
|
178
178
|
if not apps.is_installed("notifications_api_common"):
|
179
179
|
return []
|
180
180
|
|
@@ -183,6 +183,9 @@ def _test_nrc_config() -> list:
|
|
183
183
|
nrc_config = NotificationsConfig.get_solo()
|
184
184
|
nrc_client: Optional[Client] = NotificationsConfig.get_client()
|
185
185
|
|
186
|
+
if not nrc_client:
|
187
|
+
return [((_("NRC"), _("Missing"), False))]
|
188
|
+
|
186
189
|
has_nrc_auth = nrc_client.auth is not None if nrc_client else False
|
187
190
|
|
188
191
|
if not nrc_config.notifications_api_service:
|
@@ -209,14 +212,22 @@ def _test_nrc_config() -> list:
|
|
209
212
|
try:
|
210
213
|
response: requests.Response = nrc_client.get("kanaal")
|
211
214
|
response.raise_for_status()
|
212
|
-
except requests.
|
215
|
+
except requests.ConnectionError:
|
213
216
|
error = True
|
214
217
|
message = _("Could not connect with NRC")
|
218
|
+
except requests.HTTPError as exc:
|
219
|
+
error = True
|
220
|
+
message = _("Cannot retrieve kanalen: HTTP {status_code}").format(
|
221
|
+
status_code=exc.response.status_code
|
222
|
+
)
|
215
223
|
else:
|
216
224
|
message = _("Can retrieve kanalen")
|
217
225
|
|
218
226
|
checks.append((_("NRC connection and authorizations"), message, not error))
|
219
227
|
|
228
|
+
if not check_autorisaties_subscription:
|
229
|
+
return checks
|
230
|
+
|
220
231
|
# check if there's a subscription for AC notifications
|
221
232
|
has_sub = (
|
222
233
|
Subscription.objects.filter(channels__contains=["autorisaties"])
|
{commonground_api_common-2.0.1.data → commonground_api_common-2.1.0.data}/scripts/generate_schema
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{commonground_api_common-2.0.1.dist-info → commonground_api_common-2.1.0.dist-info}/top_level.txt
RENAMED
File without changes
|