Skip to content

Commit

Permalink
⬆️ upgraded zgw-consumers and removed zds-client from project
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Aug 14, 2024
1 parent a17b704 commit 3a91b18
Show file tree
Hide file tree
Showing 12 changed files with 2,329 additions and 2,599 deletions.
4,736 changes: 2,226 additions & 2,510 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 12 additions & 16 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
amqp==5.2.0
# via kombu
ape-pie==0.2.0
# via zgw-consumers
asgiref==3.7.2
# via
# django
Expand All @@ -32,7 +34,7 @@ celery==5.4.0
# flower
# notifications-api-common
# open-api-framework
certifi==2023.7.22
certifi==2024.7.4
# via
# django-simple-certmanager
# elastic-apm
Expand Down Expand Up @@ -60,7 +62,7 @@ coreapi==2.3.3
# via commonground-api-common
coreschema==0.0.4
# via coreapi
cryptography==41.0.7
cryptography==42.0.4
# via
# django-simple-certmanager
# josepy
Expand Down Expand Up @@ -150,7 +152,7 @@ django-solo==2.2.0
# mozilla-django-oidc-db
# notifications-api-common
# zgw-consumers
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
django-two-factor-auth[phonenumberslite,webauthn]==1.17.0
# via maykin-2fa
djangorestframework==3.15.2
# via
Expand Down Expand Up @@ -182,13 +184,13 @@ elastic-apm==6.23.0
# via open-api-framework
face==20.1.1
# via glom
faker==8.1.0
# via zgw-consumers
flower==2.0.1
# via open-api-framework
furl==2.1.3
# via -r requirements/base.in
gemma-zds-client==1.0.1
# via
# -r requirements/base.in
# ape-pie
gemma-zds-client==2.0.0
# via
# commonground-api-common
# notifications-api-common
Expand Down Expand Up @@ -255,7 +257,7 @@ pyjwt==2.4.0
# via
# commonground-api-common
# gemma-zds-client
pyopenssl==23.3.0
pyopenssl==24.0.0
# via
# django-simple-certmanager
# josepy
Expand All @@ -267,7 +269,6 @@ python-dateutil==2.9.0.post0
# via
# celery
# django-relativedelta
# faker
python-decouple==3.8
# via open-api-framework
python-dotenv==1.0.0
Expand All @@ -288,16 +289,14 @@ redis==3.5.3
# via django-redis
requests==2.32.3
# via
# ape-pie
# commonground-api-common
# coreapi
# django-log-outgoing-requests
# gemma-zds-client
# mozilla-django-oidc
# open-api-framework
# requests-mock
# zgw-consumers
requests-mock==1.8.0
# via zgw-consumers
sentry-sdk==2.12.0
# via open-api-framework
six==1.16.0
Expand All @@ -308,11 +307,8 @@ six==1.16.0
# orderedmultidict
# python-dateutil
# qrcode
# requests-mock
sqlparse==0.5.0
# via django
text-unidecode==1.3
# via faker
tornado==6.4.1
# via flower
typing-extensions==4.9.0
Expand Down Expand Up @@ -344,7 +340,7 @@ webencodings==0.5.1
# via bleach
wrapt==1.14.1
# via elastic-apm
zgw-consumers==0.27.0
zgw-consumers==0.29.0
# via
# notifications-api-common
# open-api-framework
Expand Down
35 changes: 17 additions & 18 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ amqp==5.2.0
# via
# -r requirements/base.txt
# kombu
ape-pie==0.2.0
# via
# -r requirements/base.txt
# zgw-consumers
asgiref==3.7.2
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -48,7 +52,7 @@ celery==5.4.0
# flower
# notifications-api-common
# open-api-framework
certifi==2023.7.22
certifi==2024.7.4
# via
# -r requirements/base.txt
# django-simple-certmanager
Expand Down Expand Up @@ -96,7 +100,7 @@ coreschema==0.0.4
# coreapi
coverage==4.5.4
# via -r requirements/test-tools.in
cryptography==41.0.7
cryptography==42.0.4
# via
# -r requirements/base.txt
# django-simple-certmanager
Expand Down Expand Up @@ -227,7 +231,7 @@ django-solo==2.2.0
# mozilla-django-oidc-db
# notifications-api-common
# zgw-consumers
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
django-two-factor-auth[phonenumberslite,webauthn]==1.17.0
# via
# -r requirements/base.txt
# maykin-2fa
Expand Down Expand Up @@ -284,19 +288,18 @@ face==20.1.1
factory-boy==3.2.0
# via -r requirements/test-tools.in
faker==8.1.0
# via
# -r requirements/base.txt
# factory-boy
# zgw-consumers
# via factory-boy
flower==2.0.1
# via
# -r requirements/base.txt
# open-api-framework
freezegun==1.1.0
# via -r requirements/test-tools.in
furl==2.1.3
# via -r requirements/base.txt
gemma-zds-client==1.0.1
# via
# -r requirements/base.txt
# ape-pie
gemma-zds-client==2.0.0
# via
# -r requirements/base.txt
# commonground-api-common
Expand Down Expand Up @@ -411,7 +414,7 @@ pyjwt==2.4.0
# -r requirements/base.txt
# commonground-api-common
# gemma-zds-client
pyopenssl==23.3.0
pyopenssl==24.0.0
# via
# -r requirements/base.txt
# django-simple-certmanager
Expand Down Expand Up @@ -463,6 +466,7 @@ redis==3.5.3
requests==2.32.3
# via
# -r requirements/base.txt
# ape-pie
# commonground-api-common
# coreapi
# django-log-outgoing-requests
Expand All @@ -472,10 +476,7 @@ requests==2.32.3
# requests-mock
# zgw-consumers
requests-mock==1.8.0
# via
# -r requirements/base.txt
# -r requirements/test-tools.in
# zgw-consumers
# via -r requirements/test-tools.in
sentry-sdk==2.12.0
# via
# -r requirements/base.txt
Expand All @@ -500,9 +501,7 @@ sqlparse==0.5.0
tblib==1.7.0
# via -r requirements/test-tools.in
text-unidecode==1.3
# via
# -r requirements/base.txt
# faker
# via faker
tornado==6.4.1
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -564,7 +563,7 @@ wrapt==1.14.1
# vcrpy
yarl==1.9.4
# via vcrpy
zgw-consumers==0.27.0
zgw-consumers==0.29.0
# via
# -r requirements/base.txt
# notifications-api-common
Expand Down
26 changes: 15 additions & 11 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ amqp==5.2.0
# via
# -r requirements/ci.txt
# kombu
ape-pie==0.2.0
# via
# -r requirements/ci.txt
# zgw-consumers
asgiref==3.7.2
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -62,7 +66,7 @@ celery==5.4.0
# flower
# notifications-api-common
# open-api-framework
certifi==2023.7.22
certifi==2024.7.4
# via
# -r requirements/ci.txt
# django-simple-certmanager
Expand Down Expand Up @@ -114,7 +118,7 @@ coreschema==0.0.4
# coreapi
coverage==4.5.4
# via -r requirements/ci.txt
cryptography==41.0.7
cryptography==42.0.4
# via
# -r requirements/ci.txt
# django-simple-certmanager
Expand Down Expand Up @@ -253,7 +257,7 @@ django-solo==2.2.0
# mozilla-django-oidc-db
# notifications-api-common
# zgw-consumers
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
django-two-factor-auth[phonenumberslite,webauthn]==1.17.0
# via
# -r requirements/ci.txt
# maykin-2fa
Expand Down Expand Up @@ -319,7 +323,6 @@ faker==8.1.0
# via
# -r requirements/ci.txt
# factory-boy
# zgw-consumers
flake8==7.0.0
# via -r requirements/dev.in
flower==2.0.1
Expand All @@ -329,8 +332,10 @@ flower==2.0.1
freezegun==1.1.0
# via -r requirements/ci.txt
furl==2.1.3
# via -r requirements/ci.txt
gemma-zds-client==1.0.1
# via
# -r requirements/ci.txt
# ape-pie
gemma-zds-client==2.0.0
# via
# -r requirements/ci.txt
# commonground-api-common
Expand Down Expand Up @@ -475,7 +480,7 @@ pyjwt==2.4.0
# -r requirements/ci.txt
# commonground-api-common
# gemma-zds-client
pyopenssl==23.3.0
pyopenssl==24.0.0
# via
# -r requirements/ci.txt
# django-simple-certmanager
Expand Down Expand Up @@ -532,6 +537,7 @@ redis==3.5.3
requests==2.32.3
# via
# -r requirements/ci.txt
# ape-pie
# commonground-api-common
# coreapi
# django-log-outgoing-requests
Expand All @@ -542,9 +548,7 @@ requests==2.32.3
# sphinx
# zgw-consumers
requests-mock==1.8.0
# via
# -r requirements/ci.txt
# zgw-consumers
# via -r requirements/ci.txt
sentry-sdk==2.12.0
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -673,7 +677,7 @@ yarl==1.9.4
# via
# -r requirements/ci.txt
# vcrpy
zgw-consumers==0.27.0
zgw-consumers==0.29.0
# via
# -r requirements/ci.txt
# notifications-api-common
Expand Down
11 changes: 6 additions & 5 deletions src/objects/api/validators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _

import requests
from rest_framework import serializers
from rest_framework.fields import get_attribute
from zds_client.client import ClientError
from zgw_consumers.client import build_client

from objects.core.utils import check_objecttype

Expand Down Expand Up @@ -104,14 +105,14 @@ def __call__(self, attrs, serializer):
if not geometry:
return

client = object_type.service.build_client()
client = build_client(object_type.service)
try:
response = client.retrieve("objecttype", url=object_type.url)
except ClientError as exc:
response = client.get(url=object_type.url)
except requests.RequestException as exc:
msg = f"Object type can not be retrieved: {exc.args[0]}"
raise ValidationError(msg)

allow_geometry = response.get("allowGeometry", True)
allow_geometry = response.json().get("allowGeometry", True)

if geometry and not allow_geometry:
raise serializers.ValidationError(self.message, code=self.code)
17 changes: 11 additions & 6 deletions src/objects/config/objecttypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests
from django_setup_configuration.configuration import BaseConfigurationStep
from django_setup_configuration.exceptions import SelfTestFailed
from zds_client.client import ClientError
from zgw_consumers.client import build_client
from zgw_consumers.constants import APITypes, AuthTypes
from zgw_consumers.models import Service

Expand Down Expand Up @@ -43,12 +43,17 @@ def test_configuration(self) -> None:
"""
This check depends on the configuration in Objecttypes
"""
client = Service.objects.get(
api_root=settings.OBJECTTYPES_API_ROOT
).build_client()
client = build_client(
Service.objects.get(api_root=settings.OBJECTTYPES_API_ROOT)
)
try:
client.list("objecttype")
except (requests.RequestException, ClientError) as exc:
response = client.get("objecttypes")
except requests.RequestException as exc:
raise SelfTestFailed(
"Could not Could not retrieve list of objecttypes from Objecttypes API."
) from exc

try:
response.json()
except requests.exceptions.JSONDecodeError:
raise SelfTestFailed(f"Object type version didn't have any data")
Loading

0 comments on commit 3a91b18

Please sign in to comment.