-
Notifications
You must be signed in to change notification settings - Fork 6
/
_interface.py
122 lines (88 loc) · 3.23 KB
/
_interface.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright Least Authority Enterprises.
# See LICENSE for details.
"""
Explicit interface definitions for txkube.
"""
from zope.interface import Attribute, Interface
class IObject(Interface):
"""
``IObject`` providers model `Kubernetes objects
<https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#objects>`_.
"""
kind = Attribute(
"""The Kubernetes *kind* of this object. For example, ``u"Namespace"``."""
)
apiVersion = Attribute(
"""The Kubernetes *apiVersion* of this object. For example, ``u"v1"``."""
)
metadata = Attribute(
"""
The metadata for this object. As either ``ObjectMetadata`` or
``NamespacedObjectMetadata``.
"""
)
def serialize():
"""
Marshal this object to a JSON- and YAML-compatible object graph.
:return dict: A JSON-compatible representation of this object.
``kind`` and ``apiVersion`` may be omitted.
"""
class IKubernetes(Interface):
"""
An ``IKubernetes`` provider represents a particular Kubernetes deployment.
"""
base_url = Attribute(
"The root of the Kubernetes HTTP API for this deployment "
"(``twisted.python.url.URL``)."
)
credentials = Attribute(
"The credentials which will grant access to use the "
"deployment's API."
)
def client():
"""
Create a client which will interact with the Kubernetes deployment
represented by this object.
:return IKubernetesClient: The client.
"""
class IKubernetesClient(Interface):
"""
An ``IKubernetesClient`` provider allows access to the API of a particular
Kubernetes deployment.
"""
def list(kind):
"""
Retrieve objects of the given kind.
:param type kind: A model type representing the object kind to
retrieve. For example ``ConfigMap`` or ``Namespace``.
:return Deferred(ObjectList): A collection of the matching objects.
"""
def create(obj):
"""
Create a new object in the given namespace.
:param IObject obj: A description of the object to create.
:return Deferred(IObject): A description of the created object.
"""
def replace(obj):
"""
Replace an existing object with a new one.
:param IObject obj: The replacement object. An old object with the
same name in the same namespace (if applicable) will be replaced
with this one.
:return Deferred(IObject): A description of the created object.
"""
def get(obj):
"""
Get a single object.
:param IObject obj: A description of which object to get. The *kind*,
*namespace*, and *name* address the specific object to retrieve.
:return Deferred(IObject): A description of the retrieved object.
"""
def delete(obj):
"""
Delete a single object.
:param IObject obj: A description of which object to delete. The *kind*,
*namespace*, and *name* address the specific object to delete.
:return Deferred(None): The Deferred fires when the object has been
deleted.
"""