forked from cloudfoundry-community/cf-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganizations.py
More file actions
59 lines (47 loc) · 2.24 KB
/
organizations.py
File metadata and controls
59 lines (47 loc) · 2.24 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from typing import TYPE_CHECKING
from cloudfoundry_client.common_objects import Pagination
from cloudfoundry_client.v3.entities import EntityManager, Entity, ToOneRelationship
if TYPE_CHECKING:
from cloudfoundry_client.client import CloudFoundryClient
class OrganizationManager(EntityManager[Entity]):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super().__init__(target_endpoint, client, "/v3/organizations")
def create(
self, name: str, suspended: bool, meta_labels: dict | None = None, meta_annotations: dict | None = None
) -> Entity:
data = {"name": name, "suspended": suspended}
self._metadata(data, meta_labels, meta_annotations)
return super()._create(data)
def update(
self,
guid: str,
name: str,
suspended: bool | None = None,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data = {"name": name}
if suspended is not None:
data["suspended"] = suspended
self._metadata(data, meta_labels, meta_annotations)
return super()._update(guid, data)
def remove(self, guid: str, asynchronous: bool = True) -> str | None:
return super()._remove(guid, asynchronous)
def assign_default_isolation_segment(self, org_guid: str, iso_seg_guid: str) -> Entity:
return ToOneRelationship.from_json_object(
super()._patch(
"%s%s/%s/relationships/default_isolation_segment" % (self.target_endpoint, self.entity_uri, org_guid),
data=ToOneRelationship(iso_seg_guid),
)
)
def get_default_isolation_segment(self, guid: str) -> ToOneRelationship:
return ToOneRelationship.from_json_object(
super().get(guid, "relationships", "default_isolation_segment")
)
def list_domains(self, guid: str, **kwargs) -> Pagination[Entity]:
uri: str = "%s/%s/domains" % (self.entity_uri, guid)
return super()._list(requested_path=uri, **kwargs)
def get_default_domain(self, guid: str) -> Entity:
return super().get(guid, "domains", "default")
def get_usage_summary(self, guid: str) -> Entity:
return super().get(guid, "usage_summary")