-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathusers.py
More file actions
40 lines (33 loc) · 1.27 KB
/
users.py
File metadata and controls
40 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import TYPE_CHECKING
from cloudfoundry_client.v3.entities import Entity, EntityManager
if TYPE_CHECKING:
from cloudfoundry_client.client import CloudFoundryClient
class UserManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(UserManager, self).__init__(target_endpoint, client, "/v3/users")
def create(
self,
user_info: str | tuple[str, str],
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data = {}
if isinstance(user_info, str):
data["guid"] = user_info
else:
username, origin = user_info
data["username"] = username
data["origin"] = origin
self._metadata(data, meta_labels, meta_annotations)
return super(UserManager, self)._create(data)
def update(
self,
guid: str,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data = {}
self._metadata(data, meta_labels, meta_annotations)
return super(UserManager, self)._update(guid, data)
def remove(self, guid: str) -> str | None:
return super(UserManager, self)._remove(guid)