-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathdroplets.py
More file actions
57 lines (49 loc) · 2.01 KB
/
droplets.py
File metadata and controls
57 lines (49 loc) · 2.01 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
from typing import TYPE_CHECKING, Any
from cloudfoundry_client.v3.entities import EntityManager, Entity, ToOneRelationship
if TYPE_CHECKING:
from cloudfoundry_client.client import CloudFoundryClient
class DropletManager(EntityManager[Entity]):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(DropletManager, self).__init__(target_endpoint, client, "/v3/droplets")
def create(self,
app_guid: str,
process_types: dict[str, str] | None = None,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data: dict[str, Any] = {
"relationships": {
"app": ToOneRelationship(app_guid)
},
}
if process_types is not None:
data["process_types"] = process_types
self._metadata(data, meta_labels, meta_annotations)
return super(DropletManager, self)._create(data)
def copy(self,
droplet_guid: str,
app_guid: str,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data: dict[str, Any] = {
"relationships": {
"app": ToOneRelationship(app_guid)
},
}
self._metadata(data, meta_labels, meta_annotations)
url = EntityManager._get_url_with_encoded_params(
"%s%s" % (self.target_endpoint, self.entity_uri),
source_guid=droplet_guid
)
return self._post(url, data=data)
def update(self,
droplet_gid: str,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data: dict[str, Any] = {}
self._metadata(data, meta_labels, meta_annotations)
return super(DropletManager, self)._update(droplet_gid, data)
def remove(self, route_gid: str):
return super(DropletManager, self)._remove(route_gid)