-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathstacks.py
More file actions
42 lines (34 loc) · 1.49 KB
/
stacks.py
File metadata and controls
42 lines (34 loc) · 1.49 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
from typing import TYPE_CHECKING
from cloudfoundry_client.common_objects import Pagination
from cloudfoundry_client.v3.entities import EntityManager, Entity
if TYPE_CHECKING:
from cloudfoundry_client.client import CloudFoundryClient
class StackMananager(EntityManager[Entity]):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(StackMananager, self).__init__(target_endpoint, client, "/v3/stacks")
def create(
self,
name: str,
description: str | None = None,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data = {"name": name}
if description is not None:
data["description"] = description
self._metadata(data, meta_labels, meta_annotations)
return super(StackMananager, self)._create(data)
def update(
self,
stack_guid: str,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
) -> Entity:
data = {}
self._metadata(data, meta_labels, meta_annotations)
return super(StackMananager, self)._update(stack_guid, data)
def list_apps(self, stack_guid: str, **kwargs) -> Pagination[Entity]:
uri: str = "%s/%s/apps" % (self.entity_uri, stack_guid)
return super(StackMananager, self)._list(requested_path=uri, **kwargs)
def remove(self, stack_guid: str):
super(StackMananager, self)._remove(stack_guid)