33
44from datamasque .client .base import BaseClient
55from datamasque .client .exceptions import DataMasqueApiError
6- from datamasque .client .models .discovery_config import DiscoveryConfigType
76from datamasque .client .models .discovery_config_library import DiscoveryConfigLibrary , DiscoveryConfigLibraryId
87
98logger = 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 )
0 commit comments