-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathisolation_segments.py
More file actions
59 lines (48 loc) · 2.52 KB
/
isolation_segments.py
File metadata and controls
59 lines (48 loc) · 2.52 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.v3.entities import EntityManager, Entity, ToManyRelationship
if TYPE_CHECKING:
from cloudfoundry_client.client import CloudFoundryClient
class IsolationSegmentManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(IsolationSegmentManager, self).__init__(target_endpoint, client, "/v3/isolation_segments")
def create(self, name: str, meta_labels: dict | None = None, meta_annotations: dict | None = None) -> Entity:
data = {"name": name}
self._metadata(data, meta_labels, meta_annotations)
return super(IsolationSegmentManager, self)._create(data)
def update(
self, isolation_segment_guid: str, name: str, meta_labels: dict | None = None, meta_annotations: dict | None = None
) -> Entity:
data = {"name": name}
self._metadata(data, meta_labels, meta_annotations)
return super(IsolationSegmentManager, self)._update(isolation_segment_guid, data)
def entitle_organizations(self, isolation_segment_guid: str, *org_guids: str) -> ToManyRelationship:
data = ToManyRelationship(*org_guids)
return ToManyRelationship.from_json_object(
super(IsolationSegmentManager, self)._post(
"%s%s/%s/relationships/organizations" % (self.target_endpoint, self.entity_uri, isolation_segment_guid), data=data
)
)
def list_entitled_organizations(
self,
isolation_segment_guid: str,
) -> ToManyRelationship:
return ToManyRelationship.from_json_object(
super(IsolationSegmentManager, self)._get(
"%s%s/%s/relationships/organizations" % (self.target_endpoint, self.entity_uri, isolation_segment_guid)
)
)
def list_entitled_spaces(
self,
isolation_segment_guid: str,
) -> ToManyRelationship:
return ToManyRelationship.from_json_object(
super(IsolationSegmentManager, self)._get(
"%s%s/%s/relationships/spaces" % (self.target_endpoint, self.entity_uri, isolation_segment_guid)
)
)
def revoke_organization(self, isolation_segment_guid: str, org_guid: str):
super(IsolationSegmentManager, self)._delete(
"%s%s/%s/relationships/organizations/%s" % (self.target_endpoint, self.entity_uri, isolation_segment_guid, org_guid)
)
def remove(self, isolation_segment_guid: str):
super(IsolationSegmentManager, self)._remove(isolation_segment_guid)