diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4760be..5108d9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: python-version: ${{ matrix.python }} - name: Bring up Alfresco - run: cd alfresco && docker-compose up -d + run: cd alfresco && docker compose up -d - name: Install dependencies run: pip install tox tox-gh-actions diff --git a/drc_cmis/client_builder.py b/drc_cmis/client_builder.py index ad4abc6..4e1df99 100644 --- a/drc_cmis/client_builder.py +++ b/drc_cmis/client_builder.py @@ -1,22 +1,9 @@ -from typing import Type, Union - -from django.conf import settings -from django.utils.module_loading import import_string - -from vng_api_common.models import APICredential -from zds_client.client import Client +from typing import Union from drc_cmis.browser.client import CMISDRCClient from drc_cmis.models import CMISConfig from drc_cmis.webservice.client import SOAPCMISClient -try: - from zgw_consumers.client import get_client_class -except (ImportError, RuntimeError): - - def get_client_class() -> Type[Client]: - return Client - def get_cmis_client() -> Union[CMISDRCClient, SOAPCMISClient]: """Build the CMIS client with the binding specified in the configuration""" @@ -25,21 +12,3 @@ def get_cmis_client() -> Union[CMISDRCClient, SOAPCMISClient]: return SOAPCMISClient() else: return CMISDRCClient() - - -def get_zds_client(url: str): - """ - Retrieve a ZDS Client instance for the given API URL. - - The client respects the setting ``CUSTOM_CLIENT_FETCHER`` as used by vng-api-common, - and will have the auth configured. - """ - Client = get_client_class() - default = Client.from_url(url) - - if getattr(settings, "CUSTOM_CLIENT_FETCHER", None): - client = import_string(settings.CUSTOM_CLIENT_FETCHER)(default.base_url) - return client - else: - default.auth = APICredential.get_auth(url) - return default diff --git a/drc_cmis/notifications.py b/drc_cmis/notifications.py deleted file mode 100644 index 986f3f4..0000000 --- a/drc_cmis/notifications.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Listen to the notifications that are send by the NRC -""" - -from vng_api_common.notifications.handlers import RoutingHandler, default - -from drc_cmis.client_builder import get_cmis_client, get_zds_client - - -class ZakenHandler: - def __init__(self): - self.cmis_client = get_cmis_client() - - def handle(self, data: dict) -> None: - if data.get("actie") == "create" and data.get("resource") == "zaak": - zaaktype_url = data.get("kenmerken", {}).get("zaaktype") - zaak_url = data.get("resource_url") - - if zaak_url and zaaktype_url: - self.create_zaak_folder(zaak_url, zaaktype_url) - - def create_zaak_folder(self, zaak_url: str, zaaktype_url: str, zaaktype_folder): - client = get_zds_client(zaaktype_url) - zaaktype_data = client.retrieve("zaaktype", url=zaaktype_url) - - client = get_zds_client(zaak_url) - zaak_data = client.retrieve("zaak", url=zaak_url) - self.cmis_client.get_or_create_zaak_folder(zaaktype_data, zaak_data) - - -default = RoutingHandler({"zaken": ZakenHandler()}, default=default)