-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathorganizations.py
More file actions
54 lines (43 loc) · 2.19 KB
/
organizations.py
File metadata and controls
54 lines (43 loc) · 2.19 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
from typing import TYPE_CHECKING
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(OrganizationManager, self).__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(OrganizationManager, self)._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(OrganizationManager, self)._update(guid, data)
def remove(self, guid: str, asynchronous: bool = True) -> str | None:
return super(OrganizationManager, self)._remove(guid, asynchronous)
def assign_default_isolation_segment(self, org_guid: str, iso_seg_guid: str) -> Entity:
return ToOneRelationship.from_json_object(
super(OrganizationManager, self)._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(OrganizationManager, self).get(guid, "relationships", "default_isolation_segment")
)
def get_default_domain(self, guid: str) -> Entity:
return super(OrganizationManager, self).get(guid, "domains", "default")
def get_usage_summary(self, guid: str) -> Entity:
return super(OrganizationManager, self).get(guid, "usage_summary")