Skip to content

Commit

Permalink
Merge pull request #89 from maykinmedia/refactor/remove-zds-client-usage
Browse files Browse the repository at this point in the history
Delete zds-client usage
  • Loading branch information
sergei-maertens authored Mar 26, 2024
2 parents 323f50a + 50429dd commit cff5c29
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 697 deletions.
66 changes: 66 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,72 @@
Changes
=======

0.32.0 (2024-03-??)
-------------------

The hard dependency on gemma-zds-client client is now optional.

This is another important step towards a 1.0 version. gemma-zds-client usage is still
supported through the legacy subpackage. Additionally, it was decided that the
``zgw_consumers.api_models`` package will still be part of 1.0, but it will be deprecated
and removed in 2.0.

**💥 Breaking changes**

* The helpers in ``zgw_consumers.service`` (except for ``pagination_helper``) are
removed. If you need these, you can safely copy the
`0.31.0 service <https://github.com/maykinmedia/zgw-consumers/blob/0.31.0/zgw_consumers/service.py>`_
implementation.

* The zaaktype field mixin (``ListZaaktypenMixin``) for the admin is removed. If you
need this, we recommend writing your own version based on ``ape-pie``. You can of
course use the `0.31.0 admin <https://github.com/maykinmedia/zgw-consumers/blob/0.31.0/zgw_consumers/admin_fields.py>`_
implementation for inspiration.

* Removed the manager method ``Service.objects.get_client_for``. For the time being you
can use ``Service.get_client`` instead, which is a drop-in replacement. Note however
that this class method is deprecated and will be removed in 1.0. We recommend
migrating to ``ape-pie``:

.. code-block:: python
from requests import Session
from zgw_consumers.client import build_client
service = Service.get_service(some_resource_url)
client: Session = build_client(service)
* The gemma-zds-client is now an optional dependency. If you still make use of the
``zgw_consumers.legacy`` package, update your dependencies to include the new
dependency group, e.g. ``zgw-consumers[zds-client]``.

**🗑️ Deprecations**

* All code that is processing an OpenAPI specification in some form is deprecated. This
includes:

- ``zgw_consumers.cache``
- ``zgw_consumers.legacy``
- ``zgw_consumers.test.component_generation``
- ``zgw_consumers.test.schema_mock``

* Code built on top of gemma-zds-client is deprecated and will be removed in 1.0:

- ``zgw_consumers.models.Service.build_client``
- ``zgw_consumers.models.Service.get_client``
- ``zgw_consumers.models.Service.get_auth_header``

**Cleanups**

* gemma-zds-client is no longer a hard dependency. Users that don't use the
``zgw_consumers.legacy`` package can safely remove the ``gemma-zds-client`` package.

* The ``Service`` (and ``RestAPIService`` abstract base) model requirement of either
providing ``oas`` (URL) or ``oas_file`` is relaxed - opt-in via the new transitional
setting ``ZGW_CONSUMERS_IGNORE_OAS_FIELDS = True``. Note that this excludes these
fields from the admin UI and bypasses the validation that a mutually exclusive value
must be provided.

0.31.0 (2024-03-15)
-------------------

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../CHANGELOG.rst
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ can still leverage the utilities offered by ZGW Consumers.
drf
testing
reference
changelog

Indices and tables
==================
Expand Down
7 changes: 7 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ Constructing an OpenAPI 3 client with the legacy client
*******************************************************

.. deprecated:: 0.28.x

The legacy client is deprecated and will be removed in the next major release.

You also need to install the extra ``zds-client``:

.. code-block:: bash
pip install zgw-consumers[zds-client]
From a service, you can construct a :class:`zds_client.client.Client`
instance which is driven by the API schema. There are two common scenario's:

Expand Down
13 changes: 12 additions & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ default.

**General**

``ZGW_CONSUMERS_IGNORE_OAS_FIELDS``
If set to ``True``, the OAS URL/file fields in the admin are hidden/ignored. Keep
the default value of ``False`` when you still make use of ``zgw_consumers.legacy``.

``ZGW_CONSUMERS_OAS_CACHE``
Which cache alias to use from ``settings.CACHES``. OpenAPI specifications are cached
here after fetching them over HTTP. Defaults to
``django.core.cache.DEFAULT_CACHE_ALIAS``.

.. deprecated:: 0.31.x
Support for gemma-zds-client and thus OpenAPI schemas is deprecated and will
be removed in 1.0.

``ZGW_CONSUMERS_CLIENT_CLASS``
A dotted python path to the client class to use when building clients from services.
This class must implement the interface of :class:`zds_client.client.Client`. Defaults to
Expand All @@ -23,12 +31,15 @@ default.
The ``ZGWClient`` is deprecated and will be removed in the next major release. Instead,
use the new :class:`ape_pie.client.APIClient` or :class:`zgw_consumers.nlx.NLXClient`.


``ZGW_CONSUMERS_TEST_SCHEMA_DIRS``
A list of directories where OpenAPI schemas can be found. Used by
``zgw_consumers.test.mock_service_oas_get`` for mocking OpenAPI schema fetching
in your tests.

.. deprecated:: 0.31.x
Support for gemma-zds-client and thus OpenAPI schemas is deprecated and will
be removed in 1.0.

**NLX support**

``NLX_OUTWAY_TIMEOUT``
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ dependencies = [
"django>=3.2",
"django-relativedelta>=2.0.0",
"django-solo",
"gemma-zds-client>=2.0.0",
"django-simple-certmanager>=1.4.1",
"requests",
"ape-pie",
"typing_extensions>=4.5.0",
"PyJWT>=2.0.0",
]

[project.urls]
Expand All @@ -50,11 +51,15 @@ db = [
drf = [
"djangorestframework",
]
zds-client = [
"gemma-zds-client>=2.0.0",
]
# These are not the test requirements! They are extras to be installed when making use of `zgw_consumers.test`
testutils = [
"Faker>=0.7.0",
"factory-boy",
"requests-mock",
"pyyaml",
]
tests = [
"django-redis",
Expand Down
14 changes: 0 additions & 14 deletions testapp/admin.py

This file was deleted.

46 changes: 46 additions & 0 deletions testapp/migrations/0005_delete_zgwconfig_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 4.2.10 on 2024-03-25 03:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("testapp", "0004_zgwconfig"),
]

operations = [
migrations.DeleteModel(
name="ZgwConfig",
),
migrations.RemoveConstraint(
model_name="case",
name="testapp_case__casetype_api_and__casetype_relative_filled",
),
migrations.AddConstraint(
model_name="case",
constraint=models.CheckConstraint(
check=models.Q(
models.Q(
("_casetype_api__isnull", True),
models.Q(
("_casetype_relative__isnull", True),
("_casetype_relative", ""),
_connector="OR",
),
),
models.Q(
models.Q(("_casetype_api__isnull", True), _negated=True),
models.Q(
("_casetype_relative__isnull", True),
("_casetype_relative", ""),
_connector="OR",
_negated=True,
),
),
_connector="OR",
),
name="testapp_case__casetype_api_and__casetype_relative_filled",
),
),
]
8 changes: 0 additions & 8 deletions testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@ class Case(models.Model):
blank=True,
null=True,
)


class ZgwConfig(models.Model):
zaaktype = models.URLField(
"zaaktype",
max_length=1000,
blank=True,
)
Loading

0 comments on commit cff5c29

Please sign in to comment.