33from __future__ import annotations
44
55from collections .abc import AsyncIterable
6- from typing import Any , Protocol , overload
7-
8- from kubernetes .client import V1PriorityClass , V1ResourceQuota
6+ from typing import Protocol
97
108from renku_data_services .k8s .constants import ClusterId
119from renku_data_services .k8s .models import (
12- ClusterScopedK8sObject ,
1310 DeletePropagationPolicy ,
1411 K8sObject ,
1512 K8sObjectFilter ,
1613 K8sObjectMeta ,
14+ K8sPatch ,
15+ K8sPatches ,
16+ K8sPriorityClass ,
17+ K8sResourceQuota ,
1718 K8sSecret ,
1819)
1920
@@ -22,28 +23,24 @@ class ResourceQuotaClient(Protocol):
2223 """Methods to manipulate ResourceQuota kubernetes resources."""
2324
2425 def list_resource_quota (
25- self , namespace : str , label_selector : dict [str , str ], cluster_id : ClusterId
26- ) -> AsyncIterable [V1ResourceQuota ]:
26+ self , label_selector : dict [str , str ], cluster_id : ClusterId
27+ ) -> AsyncIterable [K8sResourceQuota ]:
2728 """List resource quotas."""
2829 ...
2930
30- async def read_resource_quota (self , name : str , namespace : str , cluster_id : ClusterId ) -> V1ResourceQuota :
31+ async def read_resource_quota (self , name : str , cluster_id : ClusterId ) -> K8sResourceQuota :
3132 """Get a resource quota."""
3233 ...
3334
34- async def create_resource_quota (
35- self , namespace : str , body : V1ResourceQuota , cluster_id : ClusterId
36- ) -> V1ResourceQuota :
35+ async def create_resource_quota (self , quota : K8sPatch , cluster_id : ClusterId ) -> K8sResourceQuota :
3736 """Create a resource quota."""
3837 ...
3938
40- async def delete_resource_quota (self , name : str , namespace : str , cluster_id : ClusterId ) -> None :
39+ async def delete_resource_quota (self , name : str , cluster_id : ClusterId ) -> None :
4140 """Delete a resource quota."""
4241 ...
4342
44- async def patch_resource_quota (
45- self , name : str , namespace : str , body : V1ResourceQuota , cluster_id : ClusterId
46- ) -> V1ResourceQuota :
43+ async def patch_resource_quota (self , name : str , patch : K8sPatches , cluster_id : ClusterId ) -> K8sResourceQuota :
4744 """Update a resource quota."""
4845 ...
4946
@@ -59,7 +56,7 @@ async def create_secret(self, secret: K8sSecret) -> K8sSecret:
5956 """Create a secret."""
6057 ...
6158
62- async def patch_secret (self , secret : K8sObjectMeta , patch : dict [ str , Any ] | list [ dict [ str , Any ]] ) -> K8sSecret :
59+ async def patch_secret (self , secret : K8sObjectMeta , patch : K8sPatches ) -> K8sSecret :
6360 """Patch an existing secret."""
6461 ...
6562
@@ -71,18 +68,17 @@ async def delete_secret(self, secret: K8sObjectMeta) -> None:
7168class PriorityClassClient (Protocol ):
7269 """Methods to manipulate kubernetes Priority Class resources."""
7370
74- async def create_priority_class (self , body : V1PriorityClass , cluster_id : ClusterId ) -> V1PriorityClass :
71+ async def create_priority_class (self , priority_class : K8sPriorityClass ) -> K8sPriorityClass :
7572 """Create a priority class."""
7673 ...
7774
78- async def read_priority_class (self , name : str , cluster_id : ClusterId ) -> V1PriorityClass | None :
75+ async def read_priority_class (self , meta : K8sObjectMeta ) -> K8sPriorityClass | None :
7976 """Retrieve a priority class."""
8077 ...
8178
8279 async def delete_priority_class (
8380 self ,
84- name : str ,
85- cluster_id : ClusterId ,
81+ meta : K8sObjectMeta ,
8682 propagation_policy : DeletePropagationPolicy = DeletePropagationPolicy .foreground ,
8783 ) -> None :
8884 """Delete a priority class."""
@@ -92,17 +88,11 @@ async def delete_priority_class(
9288class K8sClient (Protocol ):
9389 """Methods to manipulate resources on a Kubernetes cluster."""
9490
95- @overload
96- async def create (self , obj : K8sObject , refresh : bool ) -> K8sObject : ...
97- @overload
98- async def create (self , obj : ClusterScopedK8sObject , refresh : bool ) -> ClusterScopedK8sObject : ...
99- async def create (
100- self , obj : K8sObject | ClusterScopedK8sObject , refresh : bool
101- ) -> K8sObject | ClusterScopedK8sObject :
91+ async def create (self , obj : K8sObject , refresh : bool ) -> K8sObject :
10292 """Create the k8s object."""
10393 ...
10494
105- async def patch (self , meta : K8sObjectMeta , patch : dict [ str , Any ] | list [ dict [ str , Any ]] ) -> K8sObject :
95+ async def patch (self , meta : K8sObjectMeta , patch : K8sPatches ) -> K8sObject :
10696 """Patch a k8s object.
10797
10898 If the patch is a list we assume that we have a rfc6902 json patch like
0 commit comments