Skip to content

Commit d7010e6

Browse files
authored
Merge pull request #39 from datamasque/DM-4084-untyped-config-libraries
feat: Untyped discovery config libraries
2 parents b4187bb + 9f5520b commit d7010e6

7 files changed

Lines changed: 41 additions & 175 deletions

File tree

HISTORY.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
History
33
=======
44

5+
1.2.0 (2026-07-27)
6+
------------------
7+
8+
* Made discovery config libraries untyped, matching the DataMasque 3.26.14 server. A single
9+
library is now identified by ``(namespace, name)`` and may be imported by both database and
10+
file discovery configs. **Breaking:** removed the ``config_type`` field from
11+
``DiscoveryConfigLibrary`` and the ``config_type`` argument from
12+
``get_discovery_config_library_by_name``, ``create_or_update_discovery_config_library``, and
13+
``delete_discovery_config_library_by_name_if_exists``. Requires a 3.26.14 or later server.
14+
515
1.1.8 (2026-07-27)
616
------------------
717

datamasque/client/discovery_config_libraries.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from datamasque.client.base import BaseClient
55
from datamasque.client.exceptions import DataMasqueApiError
6-
from datamasque.client.models.discovery_config import DiscoveryConfigType
76
from datamasque.client.models.discovery_config_library import DiscoveryConfigLibrary, DiscoveryConfigLibraryId
87

98
logger = logging.getLogger(__name__)
@@ -31,14 +30,12 @@ def get_discovery_config_library(self, library_id: DiscoveryConfigLibraryId) ->
3130
response = self.make_request("GET", f"/api/discovery/config-libraries/{library_id}/")
3231
return DiscoveryConfigLibrary.model_validate(response.json())
3332

34-
def _get_discovery_config_library_id_by_name(
35-
self, name: str, config_type: DiscoveryConfigType, namespace: str
36-
) -> Optional[DiscoveryConfigLibraryId]:
33+
def _get_discovery_config_library_id_by_name(self, name: str, namespace: str) -> Optional[DiscoveryConfigLibraryId]:
3734
"""
38-
Returns the ID of the library with the given name, type, and namespace, or `None` if there is none.
35+
Returns the ID of the library with the given name and namespace, or `None` if there is none.
3936
4037
The listing is filtered by name to keep the response small;
41-
type and namespace are matched client-side,
38+
the namespace is matched client-side,
4239
since the API's namespace filter cannot select the default (empty) namespace.
4340
"""
4441

@@ -48,11 +45,7 @@ def _get_discovery_config_library_id_by_name(
4845
params={"name_exact": name},
4946
)
5047
entries = [DiscoveryConfigLibrary.model_validate(item) for item in response.json()]
51-
matches = [
52-
entry
53-
for entry in entries
54-
if entry.name == name and entry.namespace == namespace and entry.config_type is config_type
55-
]
48+
matches = [entry for entry in entries if entry.name == name and entry.namespace == namespace]
5649
if not matches:
5750
return None
5851

@@ -64,18 +57,15 @@ def _get_discovery_config_library_id_by_name(
6457

6558
return matches[0].id
6659

67-
def get_discovery_config_library_by_name(
68-
self, name: str, config_type: DiscoveryConfigType, namespace: str = ""
69-
) -> Optional[DiscoveryConfigLibrary]:
60+
def get_discovery_config_library_by_name(self, name: str, namespace: str = "") -> Optional[DiscoveryConfigLibrary]:
7061
"""
71-
Looks for a discovery config library matching the given name, type, and namespace (case-sensitive, exact match).
62+
Looks for a discovery config library matching the given name and namespace (case-sensitive, exact match).
7263
73-
Library names are unique per type within a namespace,
74-
so a type is required to identify a single library.
64+
Library names are unique within a namespace.
7565
Returns it (with full YAML content) if found, otherwise `None`.
7666
"""
7767

78-
library_id = self._get_discovery_config_library_id_by_name(name, config_type, namespace)
68+
library_id = self._get_discovery_config_library_id_by_name(name, namespace)
7969
if library_id is None:
8070
return None
8171

@@ -106,7 +96,6 @@ def update_discovery_config_library(self, library: DiscoveryConfigLibrary) -> Di
10696
10797
The library must have its `id` set (i.e., it must have been previously created or retrieved from the server)
10898
and its `yaml` content present.
109-
A library's `config_type` is fixed at creation and cannot be changed by an update.
11099
"""
111100

112101
if library.id is None:
@@ -129,12 +118,12 @@ def update_discovery_config_library(self, library: DiscoveryConfigLibrary) -> Di
129118

130119
def create_or_update_discovery_config_library(self, library: DiscoveryConfigLibrary) -> DiscoveryConfigLibrary:
131120
"""
132-
Creates the library, or updates the existing one with the same name, namespace, and config type.
121+
Creates the library, or updates the existing one with the same name and namespace.
133122
134123
Sets the library's `id` property.
135124
"""
136125

137-
library_id = self._get_discovery_config_library_id_by_name(library.name, library.config_type, library.namespace)
126+
library_id = self._get_discovery_config_library_id_by_name(library.name, library.namespace)
138127
if library_id is not None:
139128
library.id = library_id
140129
return self.update_discovery_config_library(library)
@@ -157,16 +146,15 @@ def delete_discovery_config_library_by_id_if_exists(
157146
self._delete_if_exists(f"/api/discovery/config-libraries/{library_id}/", params=params)
158147

159148
def delete_discovery_config_library_by_name_if_exists(
160-
self, name: str, config_type: DiscoveryConfigType, namespace: str = "", *, force: bool = False
149+
self, name: str, namespace: str = "", *, force: bool = False
161150
) -> None:
162151
"""
163-
Deletes the discovery config library with the given name, type, and namespace.
152+
Deletes the discovery config library with the given name and namespace.
164153
165-
Library names are unique per type within a namespace,
166-
so a type is required to identify a single library.
154+
Library names are unique within a namespace.
167155
No-op if no such library exists.
168156
"""
169157

170-
library_id = self._get_discovery_config_library_id_by_name(name, config_type, namespace)
158+
library_id = self._get_discovery_config_library_id_by_name(name, namespace)
171159
if library_id is not None:
172160
self.delete_discovery_config_library_by_id_if_exists(library_id, force=force)

datamasque/client/models/discovery_config_library.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from pydantic import BaseModel, ConfigDict, Field
55

6-
from datamasque.client.models.discovery_config import DiscoveryConfigType
76
from datamasque.client.models.status import ValidationStatus
87

98
DiscoveryConfigLibraryId = NewType("DiscoveryConfigLibraryId", str)
@@ -13,14 +12,13 @@ class DiscoveryConfigLibrary(BaseModel):
1312
"""
1413
Represents a named, namespaced, persisted YAML discovery config library.
1514
16-
Library names are unique per config type within a namespace,
17-
so a database and a file library may share a name.
15+
A library is untyped: the same library may be imported by both database and
16+
file discovery configs, and its name is unique within a namespace.
1817
"""
1918

2019
model_config = ConfigDict(extra="allow", populate_by_name=True)
2120

2221
name: str
23-
config_type: DiscoveryConfigType
2422
namespace: str = ""
2523
yaml: Optional[str] = Field(default=None, alias="config_yaml")
2624
# Server-populated read-only fields, excluded from request bodies.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "datamasque-python"
3-
version = "1.1.8"
3+
version = "1.2.0"
44
description = "Official Python client for the DataMasque data-masking API."
55
authors = [
66
{ name = "DataMasque Ltd" },

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.1.8
2+
current_version = 1.2.0
33
commit = True
44
tag = True
55

0 commit comments

Comments
 (0)