Skip to content

Commit

Permalink
Merge pull request open-formulieren#3834 from open-formulieren/chore/…
Browse files Browse the repository at this point in the history
…remove-zgw-consumers-ext

Remove zgw consumers ext
  • Loading branch information
sergei-maertens authored Jan 31, 2024
2 parents a0698d7 + d628c8d commit beb9c7c
Show file tree
Hide file tree
Showing 55 changed files with 81 additions and 527 deletions.
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"http://docs.djangoproject.com/en/3.2/",
"http://docs.djangoproject.com/en/3.2/_objects/",
),
"zgw_consumers": (
"https://zgw-consumers.readthedocs.io/en/latest/",
None,
),
}

# -- Options for HTML output -------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions docs/developers/backend/api-clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Such a factory must implemented the :class:`ape_pie.ConfigAdapter` protocol.

Some examples that can serve as a reference:

* :class:`zgw_consumers_ext.ape_pie.ServiceClientFactory`
* :class:`zgw_consumers.client.ServiceConfigAdapter`
* :class:`soap.client.session_factory.SessionFactory`
* :class:`stuf.service_client_factory.ServiceClientFactory`

Expand All @@ -61,8 +61,9 @@ Reference
ZGW-consumers (JSON-based/RESTful services)
-------------------------------------------

.. automodule:: zgw_consumers_ext.api_client
:members:
See the `zgw-consumers`_ documentation.

.. _zgw-consumers: https://zgw-consumers.readthedocs.io/en/latest/

Zeep (SOAP client)
------------------
Expand Down
12 changes: 9 additions & 3 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@ factory-boy==3.0.1
# via
# -r requirements/test-tools.in
# django-simple-certmanager
# zgw-consumers
faker==7.0.1
# via factory-boy
# via
# factory-boy
# zgw-consumers
flake8==6.0.0
# via -r requirements/test-tools.in
flower==1.2.0
Expand Down Expand Up @@ -812,7 +815,9 @@ requests-file==1.5.1
# -r requirements/base.txt
# zeep
requests-mock==1.8.0
# via -r requirements/test-tools.in
# via
# -r requirements/test-tools.in
# zgw-consumers
requests-oauthlib==1.3.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -1036,10 +1041,11 @@ zeep==4.2.1
# via
# -c requirements/base.txt
# -r requirements/base.txt
zgw-consumers==0.28.0
zgw-consumers[testutils]==0.28.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# -r requirements/test-tools.in
zopfli==0.2.3
# via
# -c requirements/base.txt
Expand Down
6 changes: 5 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,13 @@ factory-boy==3.0.1
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-simple-certmanager
# zgw-consumers
faker==7.0.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# factory-boy
# zgw-consumers
flake8==6.0.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -947,6 +949,7 @@ requests-mock==1.8.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# ddt-api-calls
# zgw-consumers
requests-oauthlib==1.3.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -1237,10 +1240,11 @@ zeep==4.2.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
zgw-consumers==0.28.0
zgw-consumers[testutils]==0.28.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# zgw-consumers
zopfli==0.2.3
# via
# -c requirements/ci.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/extensions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ oauthlib==3.2.2
# via
# -r requirements/base.txt
# requests-oauthlib
open-forms-ext-haalcentraal-hr==0.2.0
open-forms-ext-haalcentraal-hr==0.3.0
# via -r requirements/extensions.in
open-forms-ext-token-exchange==0.4.0
# via -r requirements/extensions.in
Expand Down
1 change: 1 addition & 0 deletions requirements/test-tools.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pep8
pytest # documentation tests
hypothesis # property-based testing
vcrpy # record HTTP fixtures
zgw-consumers[testutils]

# Code formatting
black
Expand Down
6 changes: 2 additions & 4 deletions src/openforms/appointments/contrib/qmatic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import pytz
from ape_pie.client import APIClient
from dateutil.parser import isoparse
from zgw_consumers.client import build_client
from zgw_consumers.models import Service

from zgw_consumers_ext.api_client import ServiceClientFactory

from .exceptions import QmaticException
from .models import QmaticConfig

Expand Down Expand Up @@ -79,8 +78,7 @@ def QmaticClient() -> "Client":
if (service := config.service) is None:
raise NoServiceConfigured("No Qmatic service defined, aborting!")
assert isinstance(service, Service)
service_client_factory = ServiceClientFactory(service)
return Client.configure_from(service_client_factory)
return build_client(service, client_factory=Client)


def startswith_version(url: str) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions src/openforms/appointments/contrib/qmatic/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import factory
from zgw_consumers.constants import APITypes

from zgw_consumers_ext.tests.factories import ServiceFactory as _ServiceFactory
from zgw_consumers.test.factories import ServiceFactory as _ServiceFactory

from ..models import QmaticConfig

Expand Down
6 changes: 2 additions & 4 deletions src/openforms/contrib/brk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import requests
from typing_extensions import NotRequired

from zgw_consumers_ext.api_client import ServiceClientFactory
from zgw_consumers.client import build_client

from ..hal_client import HALClient
from .models import BRKConfig
Expand All @@ -21,8 +20,7 @@ def get_client() -> "BRKClient":
assert isinstance(config, BRKConfig)
if not (service := config.service):
raise NoServiceConfigured("No BRK service configured!")
service_client_factory = ServiceClientFactory(service)
return BRKClient.configure_from(service_client_factory)
return build_client(service, client_factory=BRKClient)


class SearchParams(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/brk/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from unittest.mock import patch

from zgw_consumers.constants import APITypes, AuthTypes
from zgw_consumers.test.factories import ServiceFactory

from openforms.contrib.brk.models import BRKConfig
from zgw_consumers_ext.tests.factories import ServiceFactory

TEST_FILES = Path(__file__).parent.resolve() / "files"
BRK_API_KEY = os.getenv("BRK_API_KEY", "placeholder_key")
Expand Down
3 changes: 2 additions & 1 deletion src/openforms/contrib/haal_centraal/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any

from zgw_consumers.client import build_client

from openforms.authentication.constants import AuthAttribute
from openforms.config.models import GlobalConfiguration
from openforms.submissions.models import Submission
from zgw_consumers_ext.api_client import build_client

from ..constants import DEFAULT_HC_BRP_PERSONEN_GEBRUIKER_HEADER
from ..models import BRPPersonenRequestOptions, HaalCentraalConfig
Expand Down
3 changes: 1 addition & 2 deletions src/openforms/contrib/haal_centraal/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from factory.django import DjangoModelFactory
from simple_certmanager.constants import CertificateTypes
from zgw_consumers.constants import AuthTypes

from zgw_consumers_ext.tests.factories import ServiceFactory
from zgw_consumers.test.factories import ServiceFactory

from ..constants import BRPVersions
from ..models import HaalCentraalConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import requests_mock
from glom import glom
from zgw_consumers.test.factories import ServiceFactory

from openforms.authentication.constants import AuthAttribute
from openforms.authentication.utils import store_registrator_details
from openforms.config.models import GlobalConfiguration
from openforms.submissions.tests.factories import SubmissionFactory
from zgw_consumers_ext.tests.factories import ServiceFactory

from ..clients import get_brp_client
from ..constants import DEFAULT_HC_BRP_PERSONEN_GEBRUIKER_HEADER, BRPVersions
Expand Down
8 changes: 3 additions & 5 deletions src/openforms/contrib/kadaster/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from zgw_consumers_ext.api_client import ServiceClientFactory
from zgw_consumers.client import build_client

from ..models import KadasterApiConfig
from .bag import BAGClient
Expand All @@ -14,14 +14,12 @@ def get_locatieserver_client() -> LocatieServerClient:
assert isinstance(config, KadasterApiConfig)
# model field is not nullable because a default is configured
assert (service := config.search_service)
service_client_factory = ServiceClientFactory(service)
return LocatieServerClient.configure_from(service_client_factory)
return build_client(service, client_factory=LocatieServerClient)


def get_bag_client() -> BAGClient:
config = KadasterApiConfig.get_solo()
assert isinstance(config, KadasterApiConfig)
if not (service := config.bag_service):
raise NoServiceConfigured("No BAG service configured!")
service_client_factory = ServiceClientFactory(service)
return BAGClient.configure_from(service_client_factory)
return build_client(service, client_factory=BAGClient)
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from django.utils.translation import gettext_lazy as _

import requests_mock
from zgw_consumers.test.factories import ServiceFactory

from openforms.submissions.tests.factories import SubmissionFactory
from openforms.submissions.tests.mixins import SubmissionsMixin
from zgw_consumers_ext.tests.factories import ServiceFactory

from ..clients.bag import AddressResult
from ..models import KadasterApiConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from zgw_consumers.test.factories import ServiceFactory

from openforms.submissions.tests.factories import SubmissionFactory
from openforms.submissions.tests.mixins import SubmissionsMixin
from zgw_consumers_ext.tests.factories import ServiceFactory

from ..models import KadasterApiConfig

Expand Down
3 changes: 1 addition & 2 deletions src/openforms/contrib/kadaster/tests/test_bag_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import requests
import requests_mock

from zgw_consumers_ext.tests.factories import ServiceFactory
from zgw_consumers.test.factories import ServiceFactory

from ..clients import get_bag_client
from ..models import KadasterApiConfig
Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/kadaster/tests/test_config_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from django.test import SimpleTestCase

import requests_mock
from zgw_consumers.test.factories import ServiceFactory

from openforms.plugins.exceptions import InvalidPluginConfiguration
from zgw_consumers_ext.tests.factories import ServiceFactory

from ..config_check import BAGCheck, LocatieServerCheck
from ..models import KadasterApiConfig
Expand Down
5 changes: 2 additions & 3 deletions src/openforms/contrib/kvk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import elasticapm
import requests
from zgw_consumers.client import build_client

from openforms.contrib.hal_client import HALClient
from zgw_consumers_ext.api_client import ServiceClientFactory

from .api_models.basisprofiel import BasisProfiel
from .models import KVKConfig
Expand All @@ -22,8 +22,7 @@ def get_client() -> "KVKClient":
assert isinstance(config, KVKConfig)
if not (service := config.service):
raise NoServiceConfigured("No KVK service configured!")
service_client_factory = ServiceClientFactory(service)
return KVKClient.configure_from(service_client_factory)
return build_client(service, client_factory=KVKClient)


class SearchParams(TypedDict, total=False):
Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/kvk/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from simple_certmanager.constants import CertificateTypes
from simple_certmanager.test.factories import CertificateFactory
from zgw_consumers.constants import APITypes, AuthTypes
from zgw_consumers.test.factories import ServiceFactory

from openforms.contrib.kvk.models import KVKConfig
from zgw_consumers_ext.tests.factories import ServiceFactory

TEST_FILES = Path(__file__).parent.resolve() / "files"

Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/objects_api/clients/objects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from zgw_consumers_ext.api_client import NLXClient
from zgw_consumers.nlx import NLXClient

CRS_HEADERS = {"Content-Crs": "EPSG:4326"}

Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/zgw/clients/catalogi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable

from zgw_consumers_ext.api_client import NLXClient
from zgw_consumers.nlx import NLXClient

from .utils import pagination_helper

Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/zgw/clients/documenten.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.core.files.base import ContentFile

from zgw_consumers_ext.api_client import NLXClient
from zgw_consumers.nlx import NLXClient

from .utils import get_today

Expand Down
2 changes: 1 addition & 1 deletion src/openforms/contrib/zgw/clients/zaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.utils import timezone

from zgw_consumers_ext.api_client import NLXClient
from zgw_consumers.nlx import NLXClient

from .catalogi import CatalogiClient
from .utils import get_today
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.utils.translation import gettext as _

import requests_mock
from zgw_consumers.test.factories import ServiceFactory

from openforms.authentication.constants import AuthAttribute
from openforms.contrib.haal_centraal.models import HaalCentraalConfig
Expand All @@ -16,7 +17,6 @@
from stuf.constants import EndpointType
from stuf.stuf_bg.models import StufBGConfig
from stuf.tests.factories import StufServiceFactory
from zgw_consumers_ext.tests.factories import ServiceFactory

from ..constants import FamilyMembersDataAPIChoices
from ..haal_centraal import get_np_family_members_haal_centraal
Expand Down
2 changes: 1 addition & 1 deletion src/openforms/forms/tests/variables/test_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from zgw_consumers.constants import APITypes, AuthTypes
from zgw_consumers.test.factories import ServiceFactory

from openforms.accounts.tests.factories import (
StaffUserFactory,
Expand All @@ -29,7 +30,6 @@
)
from openforms.variables.models import ServiceFetchConfiguration
from openforms.variables.tests.factories import ServiceFetchConfigurationFactory
from zgw_consumers_ext.tests.factories import ServiceFactory


@override_settings(LANGUAGE_CODE="en")
Expand Down
Loading

0 comments on commit beb9c7c

Please sign in to comment.