crossplane-function-pythonic 0.6.3__py3-none-any.whl → 0.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crossplane/pythonic/__about__.py +1 -3
- crossplane/pythonic/auto_ready.py +31 -22
- crossplane/pythonic/command.py +31 -24
- crossplane/pythonic/composite.py +589 -386
- crossplane/pythonic/function.py +61 -40
- crossplane/pythonic/grpc.py +4 -3
- crossplane/pythonic/main.py +7 -3
- crossplane/pythonic/packages.py +27 -19
- crossplane/pythonic/proto/v1/run_function_pb2.pyi +1121 -255
- crossplane/pythonic/proto/v1/run_function_pb2_grpc.py +1 -1
- crossplane/pythonic/proto/v1/run_function_pb2_grpc.pyi +64 -0
- crossplane/pythonic/protobuf.py +346 -196
- crossplane/pythonic/render.py +206 -81
- crossplane/pythonic/version.py +1 -1
- {crossplane_function_pythonic-0.6.3.dist-info → crossplane_function_pythonic-0.7.0.dist-info}/METADATA +4 -4
- crossplane_function_pythonic-0.7.0.dist-info/RECORD +22 -0
- {crossplane_function_pythonic-0.6.3.dist-info → crossplane_function_pythonic-0.7.0.dist-info}/WHEEL +1 -1
- crossplane/pythonic/diff.py +0 -880
- crossplane_function_pythonic-0.6.3.dist-info/RECORD +0 -22
- {crossplane_function_pythonic-0.6.3.dist-info → crossplane_function_pythonic-0.7.0.dist-info}/entry_points.txt +0 -0
crossplane/pythonic/composite.py
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import logging
|
|
3
|
+
import types
|
|
4
|
+
import typing
|
|
5
|
+
from typing import cast
|
|
2
6
|
|
|
3
7
|
from google.protobuf.duration_pb2 import Duration
|
|
4
8
|
|
|
@@ -8,58 +12,63 @@ from . import (
|
|
|
8
12
|
)
|
|
9
13
|
from .proto.v1 import run_function_pb2 as fnv1
|
|
10
14
|
|
|
11
|
-
_notset =
|
|
15
|
+
_notset = sentinel("_notset")
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
class ConnectionSecret:
|
|
15
|
-
def __get__(self, composite, objtype=None):
|
|
19
|
+
def __get__(self, composite: BaseComposite, objtype=None) -> protobuf.Value:
|
|
16
20
|
if composite.crossplane_v1:
|
|
17
21
|
return composite.spec.writeConnectionSecretToRef
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
secret = protobuf.Map()
|
|
22
|
+
if not composite._connectionSecret:
|
|
23
|
+
composite._connectionSecret = protobuf.Map()
|
|
21
24
|
for key, value in composite.request.input.writeConnectionSecretToRef:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return secret
|
|
25
|
+
composite._connectionSecret[key] = value
|
|
26
|
+
return composite._connectionSecret
|
|
25
27
|
|
|
26
|
-
def __set__(
|
|
28
|
+
def __set__(
|
|
29
|
+
self, composite: BaseComposite, values: typing.Mapping | protobuf.Value
|
|
30
|
+
) -> None:
|
|
27
31
|
if composite.crossplane_v1:
|
|
28
32
|
if values != composite.spec.writeConnectionSecretToRef:
|
|
29
33
|
raise NotImplementedError(
|
|
30
34
|
"Connection Secret cannot be set in Crossplane V1"
|
|
31
35
|
)
|
|
32
36
|
return
|
|
33
|
-
|
|
34
|
-
for
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
composite._connectionSecret = protobuf.Map()
|
|
38
|
+
for entry in values:
|
|
39
|
+
if isinstance(entry, str):
|
|
40
|
+
composite._connectionSecret[entry] = values[entry]
|
|
41
|
+
elif isinstance(entry, (tuple, list)):
|
|
42
|
+
composite._connectionSecret[entry[0]] = entry[1]
|
|
37
43
|
|
|
38
44
|
|
|
39
45
|
class Connection:
|
|
40
|
-
def __get__(self, composite, objtype=None):
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
def __get__(self, composite: BaseComposite, objtype=None) -> _Connection:
|
|
47
|
+
if not composite._connection:
|
|
48
|
+
composite._connection = _Connection(composite)
|
|
49
|
+
return composite._connection
|
|
50
|
+
|
|
51
|
+
def __set__(
|
|
52
|
+
self, composite: BaseComposite, values: typing.Mapping | protobuf.Value
|
|
53
|
+
) -> None:
|
|
48
54
|
connection = self.__get__(composite)
|
|
49
55
|
connection()
|
|
50
|
-
for
|
|
51
|
-
|
|
56
|
+
for entry in values:
|
|
57
|
+
if isinstance(entry, str):
|
|
58
|
+
connection[entry] = values[entry]
|
|
59
|
+
elif isinstance(entry, (tuple, list)):
|
|
60
|
+
connection[entry[0]] = entry[1]
|
|
52
61
|
|
|
53
62
|
|
|
54
63
|
class TTL:
|
|
55
|
-
def __get__(self, composite, objtype=None):
|
|
56
|
-
if composite.response.meta.ttl.nanos:
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
64
|
+
def __get__(self, composite: BaseComposite, objtype=None) -> int | float:
|
|
65
|
+
if composite.response.meta.ttl.nanos == 0:
|
|
66
|
+
return int(composite.response.meta.ttl.seconds)
|
|
67
|
+
return float(composite.response.meta.ttl.seconds) + (
|
|
68
|
+
float(composite.response.meta.ttl.nanos) / 1000000000.0
|
|
69
|
+
)
|
|
61
70
|
|
|
62
|
-
def __set__(self, composite, ttl):
|
|
71
|
+
def __set__(self, composite: BaseComposite, ttl: float) -> None:
|
|
63
72
|
if isinstance(ttl, int):
|
|
64
73
|
composite.response.meta.ttl.seconds = ttl
|
|
65
74
|
composite.response.meta.ttl.nanos = 0
|
|
@@ -76,27 +85,46 @@ class TTL:
|
|
|
76
85
|
|
|
77
86
|
|
|
78
87
|
class Ready:
|
|
79
|
-
def __get__(
|
|
80
|
-
|
|
88
|
+
def __get__(
|
|
89
|
+
self, composite: BaseComposite, objtype=None
|
|
90
|
+
) -> bool | protobuf.Value | None:
|
|
91
|
+
if composite._ready is not None:
|
|
81
92
|
return composite._ready
|
|
82
|
-
if
|
|
93
|
+
if (
|
|
94
|
+
cast(protobuf.Message, composite.desired._parent).ready
|
|
95
|
+
== fnv1.Ready.READY_TRUE
|
|
96
|
+
):
|
|
83
97
|
return True
|
|
84
|
-
if
|
|
98
|
+
if (
|
|
99
|
+
cast(protobuf.Message, composite.desired._parent).ready
|
|
100
|
+
== fnv1.Ready.READY_FALSE
|
|
101
|
+
):
|
|
85
102
|
return False
|
|
86
103
|
return None
|
|
87
104
|
|
|
88
|
-
def __set__(self, composite, ready):
|
|
105
|
+
def __set__(self, composite: BaseComposite, ready: protobuf.Value | bool | None):
|
|
89
106
|
composite._ready = ready
|
|
90
107
|
if ready:
|
|
91
|
-
|
|
108
|
+
cast(
|
|
109
|
+
protobuf.Message, composite.desired._parent
|
|
110
|
+
).ready = fnv1.Ready.READY_TRUE
|
|
92
111
|
elif ready is None:
|
|
93
|
-
|
|
112
|
+
cast(
|
|
113
|
+
protobuf.Message, composite.desired._parent
|
|
114
|
+
).ready = fnv1.Ready.READY_UNSPECIFIED
|
|
94
115
|
else:
|
|
95
|
-
|
|
116
|
+
cast(
|
|
117
|
+
protobuf.Message, composite.desired._parent
|
|
118
|
+
).ready = fnv1.Ready.READY_FALSE
|
|
96
119
|
|
|
97
120
|
|
|
98
121
|
class BaseComposite:
|
|
99
|
-
def __init__(
|
|
122
|
+
def __init__(
|
|
123
|
+
self,
|
|
124
|
+
crossplane_v1: bool,
|
|
125
|
+
request: fnv1.RunFunctionRequest,
|
|
126
|
+
logger: logging.Logger,
|
|
127
|
+
) -> None:
|
|
100
128
|
self.crossplane_v1 = crossplane_v1
|
|
101
129
|
self.request = protobuf.Message(
|
|
102
130
|
None, "request", request.DESCRIPTOR, request, "Function Request"
|
|
@@ -114,213 +142,255 @@ class BaseComposite:
|
|
|
114
142
|
self.response = protobuf.Message(
|
|
115
143
|
None, "response", response.DESCRIPTOR, response
|
|
116
144
|
)
|
|
117
|
-
self.logger = logger
|
|
118
|
-
self.capabilities = Capabilities(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
self.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
self.
|
|
125
|
-
self.
|
|
126
|
-
self.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
self.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
self.
|
|
134
|
-
self.
|
|
135
|
-
self.
|
|
136
|
-
self.
|
|
137
|
-
self.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
self.logger: logging.Logger = logger
|
|
146
|
+
self.capabilities: Capabilities = Capabilities(
|
|
147
|
+
cast(protobuf.RepeatedMessage, self.request.meta.capabilities)
|
|
148
|
+
)
|
|
149
|
+
self.parameters: protobuf.Value = cast(
|
|
150
|
+
protobuf.Value, self.request.input.parameters
|
|
151
|
+
)
|
|
152
|
+
self.credentials: Credentials = Credentials(self.request)
|
|
153
|
+
self.context: protobuf.Value = cast(protobuf.Value, self.response.context)
|
|
154
|
+
self.environment: protobuf.Value = self.context[
|
|
155
|
+
"apiextensions.crossplane.io/environment"
|
|
156
|
+
]
|
|
157
|
+
self.requireds: Requireds = Requireds(self)
|
|
158
|
+
self.watched: RequiredResource = self.requireds[
|
|
159
|
+
"ops.crossplane.io/watched-resource"
|
|
160
|
+
][0]
|
|
161
|
+
self.schemas: Schemas = Schemas(self)
|
|
162
|
+
self.resources: Resources = Resources(self)
|
|
163
|
+
self.autoReady: bool = True
|
|
164
|
+
self.usages: bool = False
|
|
165
|
+
self.unknownsFatal: bool = False
|
|
166
|
+
|
|
167
|
+
observed: protobuf.Message = cast(
|
|
168
|
+
protobuf.Message, self.request.observed.composite
|
|
169
|
+
)
|
|
170
|
+
desired: protobuf.Message = cast(
|
|
171
|
+
protobuf.Message, self.response.desired.composite
|
|
172
|
+
)
|
|
173
|
+
self.observed: protobuf.Value = cast(protobuf.Value, observed.resource)
|
|
174
|
+
self.desired: protobuf.Value = cast(protobuf.Value, desired.resource)
|
|
175
|
+
self.apiVersion: protobuf.Value = cast(protobuf.Value, self.observed.apiVersion)
|
|
176
|
+
self.kind: protobuf.Value = self.observed.kind
|
|
177
|
+
self.metadata: protobuf.Value = self.observed.metadata
|
|
178
|
+
self.spec: protobuf.Value = self.observed.spec
|
|
179
|
+
self.status: protobuf.Value = self.desired.status
|
|
180
|
+
self.output: protobuf.Value = cast(protobuf.Value, self.response.output)
|
|
181
|
+
self.conditions: Conditions = Conditions(observed, self.response)
|
|
182
|
+
self.results: Results = Results(self.response)
|
|
183
|
+
|
|
184
|
+
self._connectionSecret: protobuf.Value | None = None
|
|
185
|
+
self._connection: _Connection | None = None
|
|
186
|
+
self._ready: protobuf.Value | bool | None = None
|
|
187
|
+
|
|
188
|
+
ttl: TTL = TTL()
|
|
189
|
+
connectionSecret: ConnectionSecret = ConnectionSecret()
|
|
190
|
+
connection: Connection = Connection()
|
|
191
|
+
ready: Ready = Ready()
|
|
192
|
+
|
|
193
|
+
async def compose(self) -> None:
|
|
151
194
|
raise NotImplementedError()
|
|
152
195
|
|
|
153
196
|
|
|
154
197
|
class Capabilities:
|
|
155
|
-
def __init__(self, capabilities):
|
|
156
|
-
self._capabilities = capabilities
|
|
198
|
+
def __init__(self, capabilities: protobuf.RepeatedMessage):
|
|
199
|
+
self._capabilities: protobuf.RepeatedMessage = capabilities
|
|
157
200
|
|
|
158
201
|
def __bool__(self):
|
|
159
202
|
return fnv1.CAPABILITY_CAPABILITIES in self._capabilities
|
|
160
203
|
|
|
161
204
|
@property
|
|
162
|
-
def requireds(self):
|
|
205
|
+
def requireds(self) -> bool | None:
|
|
163
206
|
return (
|
|
164
207
|
fnv1.CAPABILITY_REQUIRED_RESOURCES in self._capabilities if self else None
|
|
165
208
|
)
|
|
166
209
|
|
|
167
210
|
@property
|
|
168
|
-
def credentials(self):
|
|
211
|
+
def credentials(self) -> bool | None:
|
|
169
212
|
return fnv1.CAPABILITY_CREDENTIALS in self._capabilities if self else None
|
|
170
213
|
|
|
171
214
|
@property
|
|
172
|
-
def conditions(self):
|
|
215
|
+
def conditions(self) -> bool | None:
|
|
173
216
|
return fnv1.CAPABILITY_CONDITIONS in self._capabilities if self else None
|
|
174
217
|
|
|
175
218
|
@property
|
|
176
|
-
def schemas(self):
|
|
219
|
+
def schemas(self) -> bool | None:
|
|
177
220
|
return fnv1.CAPABILITY_REQUIRED_SCHEMAS in self._capabilities if self else None
|
|
178
221
|
|
|
179
222
|
|
|
180
223
|
class Credentials:
|
|
181
|
-
|
|
182
|
-
self.__dict__["_request"] = request
|
|
224
|
+
_request: protobuf.Message
|
|
183
225
|
|
|
184
|
-
def
|
|
226
|
+
def __init__(self, request: protobuf.Message):
|
|
227
|
+
self._request: protobuf.Message = request
|
|
228
|
+
|
|
229
|
+
def __getattr__(self, key: protobuf.TypeString) -> Credential:
|
|
185
230
|
return self[key]
|
|
186
231
|
|
|
187
|
-
def __getitem__(self, key):
|
|
188
|
-
return Credential(self._request.credentials[key])
|
|
232
|
+
def __getitem__(self, key: protobuf.TypeString) -> Credential:
|
|
233
|
+
return Credential(cast(protobuf.Message, self._request.credentials[key]))
|
|
189
234
|
|
|
190
|
-
def __bool__(self):
|
|
191
|
-
return bool(self
|
|
235
|
+
def __bool__(self) -> bool:
|
|
236
|
+
return bool(len(self))
|
|
192
237
|
|
|
193
|
-
def __len__(self):
|
|
238
|
+
def __len__(self) -> int:
|
|
194
239
|
return len(self._request.credentials)
|
|
195
240
|
|
|
196
|
-
def __contains__(self, key):
|
|
241
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
197
242
|
return key in self._request.credentials
|
|
198
243
|
|
|
199
|
-
def __iter__(self):
|
|
244
|
+
def __iter__(self) -> typing.Generator[tuple[str, Credential]]:
|
|
200
245
|
for key, resource in self._request.credentials:
|
|
201
246
|
yield key, self[key]
|
|
202
247
|
|
|
203
248
|
|
|
204
249
|
class Credential:
|
|
205
|
-
def __init__(self, credential):
|
|
206
|
-
self.
|
|
250
|
+
def __init__(self, credential: protobuf.Message):
|
|
251
|
+
self._credential: protobuf.Message = credential
|
|
207
252
|
|
|
208
|
-
def __getattr__(self, key):
|
|
253
|
+
def __getattr__(self, key: protobuf.TypeString) -> str:
|
|
209
254
|
return self[key]
|
|
210
255
|
|
|
211
|
-
def __getitem__(self, key):
|
|
212
|
-
return self._credential.credential_data.data[key]
|
|
256
|
+
def __getitem__(self, key: protobuf.TypeString) -> str:
|
|
257
|
+
return str(self._credential.credential_data.data[key])
|
|
213
258
|
|
|
214
|
-
def __bool__(self):
|
|
215
|
-
return bool(self
|
|
259
|
+
def __bool__(self) -> bool:
|
|
260
|
+
return bool(len(self))
|
|
216
261
|
|
|
217
|
-
def __len__(self):
|
|
262
|
+
def __len__(self) -> int:
|
|
218
263
|
return len(self._credential.credential_data.data)
|
|
219
264
|
|
|
220
|
-
def __contains__(self, key):
|
|
265
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
221
266
|
return key in self._credential.credential_data.data
|
|
222
267
|
|
|
223
|
-
def __iter__(self):
|
|
268
|
+
def __iter__(self) -> typing.Generator[tuple[str, str]]:
|
|
224
269
|
for key, resource in self._credential.credential_data.data:
|
|
225
270
|
yield key, self[key]
|
|
226
271
|
|
|
227
272
|
|
|
228
273
|
class Resources:
|
|
229
|
-
def __init__(self, composite):
|
|
230
|
-
self.
|
|
231
|
-
self.
|
|
274
|
+
def __init__(self, composite: BaseComposite):
|
|
275
|
+
self._composite: BaseComposite = composite
|
|
276
|
+
self._cache: dict[protobuf.TypeString, Resource] = {}
|
|
232
277
|
|
|
233
|
-
def __getattr__(self, key):
|
|
278
|
+
def __getattr__(self, key: protobuf.TypeString) -> Resource:
|
|
234
279
|
return self[key]
|
|
235
280
|
|
|
236
|
-
def __getitem__(self, key):
|
|
281
|
+
def __getitem__(self, key: protobuf.TypeString) -> Resource:
|
|
237
282
|
resource = self._cache.get(key)
|
|
238
283
|
if not resource:
|
|
239
284
|
resource = Resource(self._composite, key)
|
|
240
285
|
self._cache[key] = resource
|
|
241
286
|
return resource
|
|
242
287
|
|
|
243
|
-
def __bool__(self):
|
|
244
|
-
return bool(self
|
|
288
|
+
def __bool__(self) -> bool:
|
|
289
|
+
return bool(len(self))
|
|
245
290
|
|
|
246
|
-
def __len__(self):
|
|
291
|
+
def __len__(self) -> int:
|
|
247
292
|
return len(self._composite.response.desired.resources)
|
|
248
293
|
|
|
249
|
-
def __contains__(self, key):
|
|
294
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
250
295
|
return key in self._composite.response.desired.resources
|
|
251
296
|
|
|
252
|
-
def __iter__(self):
|
|
297
|
+
def __iter__(self) -> typing.Generator[tuple[str, Resource]]:
|
|
253
298
|
for name, resource in self._composite.response.desired.resources:
|
|
254
299
|
yield name, self[name]
|
|
255
300
|
|
|
256
|
-
def __setattr__(
|
|
257
|
-
self
|
|
301
|
+
def __setattr__(
|
|
302
|
+
self,
|
|
303
|
+
key: protobuf.TypeString,
|
|
304
|
+
resource: typing.Mapping | protobuf.Value,
|
|
305
|
+
) -> None:
|
|
306
|
+
if key in ("_composite", "_cache"):
|
|
307
|
+
self.__dict__[str(key)] = resource
|
|
308
|
+
else:
|
|
309
|
+
self[key] = resource
|
|
258
310
|
|
|
259
|
-
def __setitem__(
|
|
311
|
+
def __setitem__(
|
|
312
|
+
self,
|
|
313
|
+
key: protobuf.TypeString,
|
|
314
|
+
resource: typing.Mapping | protobuf.Value,
|
|
315
|
+
) -> None:
|
|
260
316
|
self._composite.response.desired.resources[key].resource = resource
|
|
261
317
|
self._cache.pop(key, None)
|
|
262
318
|
|
|
263
|
-
def __delattr__(self, key):
|
|
319
|
+
def __delattr__(self, key: protobuf.TypeString) -> None:
|
|
264
320
|
del self[key]
|
|
265
321
|
|
|
266
|
-
def __delitem__(self, key):
|
|
322
|
+
def __delitem__(self, key: protobuf.TypeString) -> None:
|
|
267
323
|
if key in self._composite.response.desired.resources:
|
|
268
324
|
del self._composite.response.desired.resources[key]
|
|
269
325
|
self._cache.pop(key, None)
|
|
270
326
|
|
|
271
327
|
|
|
272
328
|
class Resource:
|
|
273
|
-
def __init__(
|
|
274
|
-
self
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
self.
|
|
279
|
-
self.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
329
|
+
def __init__(
|
|
330
|
+
self,
|
|
331
|
+
composite: BaseComposite,
|
|
332
|
+
name: protobuf.TypeString,
|
|
333
|
+
):
|
|
334
|
+
self._composite: BaseComposite = composite
|
|
335
|
+
self.name: protobuf.TypeString = name
|
|
336
|
+
observed: protobuf.Message = cast(
|
|
337
|
+
protobuf.Message, composite.request.observed.resources[name]
|
|
338
|
+
)
|
|
339
|
+
desired: protobuf.Message = cast(
|
|
340
|
+
protobuf.Message, composite.response.desired.resources[name]
|
|
341
|
+
)
|
|
342
|
+
self.observed: protobuf.Value = cast(protobuf.Value, observed.resource)
|
|
343
|
+
self.desired: protobuf.Value = cast(protobuf.Value, desired.resource)
|
|
344
|
+
self.conditions: Conditions = Conditions(observed)
|
|
345
|
+
self.connection: protobuf.MapMessage = cast(
|
|
346
|
+
protobuf.MapMessage, observed.connection_details
|
|
347
|
+
)
|
|
348
|
+
self.autoReady: bool | None = None
|
|
349
|
+
self.usages: bool | None = None
|
|
350
|
+
self.unknownsFatal: bool | None = None
|
|
285
351
|
|
|
286
352
|
def __call__(
|
|
287
|
-
self,
|
|
288
|
-
|
|
353
|
+
self,
|
|
354
|
+
kind: str | _notset = _notset,
|
|
355
|
+
apiVersion: str | _notset = _notset,
|
|
356
|
+
namespace: str | _notset = _notset,
|
|
357
|
+
name: str | _notset = _notset,
|
|
358
|
+
) -> typing.Self:
|
|
289
359
|
self.desired()
|
|
290
|
-
if kind
|
|
360
|
+
if kind is not _notset:
|
|
291
361
|
# Allow for apiVersion in the first arg and kind in the second arg
|
|
292
362
|
if "/" in kind or kind == "v1":
|
|
293
|
-
if apiVersion
|
|
363
|
+
if apiVersion is not _notset:
|
|
294
364
|
self.kind = apiVersion
|
|
295
365
|
apiVersion = kind
|
|
296
366
|
else:
|
|
297
367
|
self.kind = kind
|
|
298
|
-
if apiVersion
|
|
368
|
+
if apiVersion is not _notset:
|
|
299
369
|
self.apiVersion = apiVersion
|
|
300
|
-
if namespace
|
|
370
|
+
if namespace is not _notset:
|
|
301
371
|
self.metadata.namespace = namespace
|
|
302
|
-
if name
|
|
372
|
+
if name is not _notset:
|
|
303
373
|
self.metadata.name = name
|
|
304
374
|
return self
|
|
305
375
|
|
|
306
376
|
@property
|
|
307
|
-
def apiVersion(self):
|
|
377
|
+
def apiVersion(self) -> protobuf.Value:
|
|
308
378
|
return self.desired.apiVersion
|
|
309
379
|
|
|
310
380
|
@apiVersion.setter
|
|
311
|
-
def apiVersion(self, apiVersion):
|
|
381
|
+
def apiVersion(self, apiVersion: protobuf.TypeString) -> None:
|
|
312
382
|
self.desired.apiVersion = apiVersion
|
|
313
383
|
|
|
314
384
|
@property
|
|
315
|
-
def kind(self):
|
|
385
|
+
def kind(self) -> protobuf.Value:
|
|
316
386
|
return self.desired.kind
|
|
317
387
|
|
|
318
388
|
@kind.setter
|
|
319
|
-
def kind(self, kind):
|
|
389
|
+
def kind(self, kind: protobuf.TypeString) -> None:
|
|
320
390
|
self.desired.kind = kind
|
|
321
391
|
|
|
322
392
|
@property
|
|
323
|
-
def externalName(self):
|
|
393
|
+
def externalName(self) -> protobuf.Value:
|
|
324
394
|
name = self.metadata.annotations["crossplane.io/external-name"]
|
|
325
395
|
if not name:
|
|
326
396
|
name = self.observed.metadata.annotations["crossplane.io/external-name"]
|
|
@@ -329,52 +399,58 @@ class Resource:
|
|
|
329
399
|
return name
|
|
330
400
|
|
|
331
401
|
@externalName.setter
|
|
332
|
-
def externalName(self, name):
|
|
402
|
+
def externalName(self, name: protobuf.TypeString) -> None:
|
|
333
403
|
self.metadata.annotations["crossplane.io/external-name"] = name
|
|
334
404
|
|
|
335
405
|
@property
|
|
336
|
-
def metadata(self):
|
|
406
|
+
def metadata(self) -> protobuf.Value:
|
|
337
407
|
return self.desired.metadata
|
|
338
408
|
|
|
339
409
|
@metadata.setter
|
|
340
|
-
def metadata(self, metadata):
|
|
410
|
+
def metadata(self, metadata: typing.Mapping | protobuf.Value) -> None:
|
|
341
411
|
self.desired.metadata = metadata
|
|
342
412
|
|
|
343
413
|
@property
|
|
344
|
-
def spec(self):
|
|
414
|
+
def spec(self) -> protobuf.Value:
|
|
345
415
|
return self.desired.spec
|
|
346
416
|
|
|
347
417
|
@spec.setter
|
|
348
|
-
def spec(self, spec):
|
|
418
|
+
def spec(self, spec: typing.Mapping | protobuf.Value) -> None:
|
|
349
419
|
self.desired.spec = spec
|
|
350
420
|
|
|
351
421
|
# Used by Secret:v1
|
|
352
422
|
@property
|
|
353
|
-
def type(self):
|
|
423
|
+
def type(self) -> protobuf.Value:
|
|
354
424
|
return self.desired.type
|
|
355
425
|
|
|
356
426
|
@type.setter
|
|
357
|
-
def type(self, type):
|
|
427
|
+
def type(self, type: str | protobuf.Value) -> None:
|
|
358
428
|
self.desired.type = type
|
|
359
429
|
|
|
360
430
|
@property
|
|
361
|
-
def data(self):
|
|
431
|
+
def data(self) -> protobuf.Value:
|
|
362
432
|
return self.desired.data
|
|
363
433
|
|
|
364
434
|
@data.setter
|
|
365
|
-
def data(self, data):
|
|
435
|
+
def data(self, data: typing.Mapping | protobuf.Value) -> None:
|
|
366
436
|
self.desired.data = data
|
|
367
437
|
|
|
368
438
|
@property
|
|
369
|
-
def status(self):
|
|
439
|
+
def status(self) -> protobuf.Value:
|
|
370
440
|
return self.observed.status
|
|
371
441
|
|
|
372
442
|
@property
|
|
373
|
-
def ready(self):
|
|
443
|
+
def ready(self) -> protobuf.Value | bool | None:
|
|
374
444
|
if not hasattr(self, "_ready"):
|
|
375
|
-
if
|
|
445
|
+
if (
|
|
446
|
+
cast(protobuf.Message, self.desired._parent).ready
|
|
447
|
+
== fnv1.Ready.READY_TRUE
|
|
448
|
+
):
|
|
376
449
|
self._ready = True
|
|
377
|
-
elif
|
|
450
|
+
elif (
|
|
451
|
+
cast(protobuf.Message, self.desired._parent).ready
|
|
452
|
+
== fnv1.Ready.READY_FALSE
|
|
453
|
+
):
|
|
378
454
|
self._ready = False
|
|
379
455
|
else:
|
|
380
456
|
self._ready = None
|
|
@@ -384,21 +460,25 @@ class Resource:
|
|
|
384
460
|
ready = auto_ready.resource_ready(self)
|
|
385
461
|
if ready:
|
|
386
462
|
self._ready = ready
|
|
387
|
-
|
|
463
|
+
cast(
|
|
464
|
+
protobuf.Message, self.desired._parent
|
|
465
|
+
).ready = fnv1.Ready.READY_TRUE
|
|
388
466
|
return self._ready
|
|
389
467
|
|
|
390
468
|
@ready.setter
|
|
391
|
-
def ready(self, ready):
|
|
469
|
+
def ready(self, ready: protobuf.Value | bool | None) -> None:
|
|
392
470
|
self._ready = ready
|
|
393
471
|
if ready:
|
|
394
|
-
self.desired._parent.ready = fnv1.Ready.READY_TRUE
|
|
472
|
+
cast(protobuf.Message, self.desired._parent).ready = fnv1.Ready.READY_TRUE
|
|
395
473
|
elif ready is None:
|
|
396
|
-
|
|
474
|
+
cast(
|
|
475
|
+
protobuf.Message, self.desired._parent
|
|
476
|
+
).ready = fnv1.Ready.READY_UNSPECIFIED
|
|
397
477
|
else:
|
|
398
|
-
self.desired._parent.ready = fnv1.Ready.READY_FALSE
|
|
478
|
+
cast(protobuf.Message, self.desired._parent).ready = fnv1.Ready.READY_FALSE
|
|
399
479
|
|
|
400
|
-
def setReadyCondition(self, type="Ready"):
|
|
401
|
-
condition = self.conditions[type]
|
|
480
|
+
def setReadyCondition(self, type: str = "Ready"):
|
|
481
|
+
condition: Condition = self.conditions[type]
|
|
402
482
|
if condition.status:
|
|
403
483
|
self.ready = self.observed.metadata.name
|
|
404
484
|
else:
|
|
@@ -408,46 +488,53 @@ class Resource:
|
|
|
408
488
|
else:
|
|
409
489
|
self.ready = self.status[error]
|
|
410
490
|
|
|
411
|
-
def addDependency(
|
|
491
|
+
def addDependency(
|
|
492
|
+
self,
|
|
493
|
+
resource: Resource,
|
|
494
|
+
field: protobuf.FieldMessage | protobuf.Value | None | _notset = _notset,
|
|
495
|
+
):
|
|
496
|
+
dependency: protobuf.FieldMessage | protobuf.Value | bool | None = None
|
|
412
497
|
if field is _notset:
|
|
413
|
-
|
|
414
|
-
if
|
|
415
|
-
|
|
416
|
-
if
|
|
417
|
-
|
|
418
|
-
resource.ready =
|
|
498
|
+
dependency = resource.ready
|
|
499
|
+
if dependency is None:
|
|
500
|
+
dependency = auto_ready.resource_ready(resource)
|
|
501
|
+
if dependency is None:
|
|
502
|
+
dependency = False
|
|
503
|
+
resource.ready = dependency
|
|
419
504
|
elif field is None:
|
|
420
|
-
field =
|
|
421
|
-
|
|
505
|
+
field = _notset
|
|
506
|
+
else:
|
|
507
|
+
dependency = field
|
|
508
|
+
if not isinstance(dependency, (protobuf.FieldMessage, protobuf.Value)):
|
|
422
509
|
if field:
|
|
423
|
-
|
|
510
|
+
dependency = resource.observed.metadata.name
|
|
424
511
|
else:
|
|
425
512
|
if not resource.observed.metadata.name:
|
|
426
|
-
|
|
513
|
+
dependency = resource.observed.metadata.name
|
|
427
514
|
else:
|
|
428
|
-
|
|
429
|
-
self.metadata.annotations[f"pythonic.dependency/{resource.name}"] =
|
|
515
|
+
dependency = resource.status.notReady
|
|
516
|
+
self.metadata.annotations[f"pythonic.dependency/{resource.name}"] = dependency
|
|
430
517
|
|
|
431
518
|
|
|
432
519
|
class Requireds:
|
|
433
|
-
def __init__(self, composite):
|
|
434
|
-
self._composite = composite
|
|
435
|
-
self._cache = {}
|
|
520
|
+
def __init__(self, composite: BaseComposite):
|
|
521
|
+
self._composite: BaseComposite = composite
|
|
522
|
+
self._cache: dict[protobuf.TypeString, RequiredResources] = {}
|
|
436
523
|
|
|
437
|
-
def __getattr__(self, key):
|
|
524
|
+
def __getattr__(self, key: protobuf.TypeString) -> RequiredResources:
|
|
438
525
|
return self[key]
|
|
439
526
|
|
|
440
|
-
def __getitem__(self, key):
|
|
527
|
+
def __getitem__(self, key: protobuf.TypeString) -> RequiredResources:
|
|
441
528
|
required = self._cache.get(key)
|
|
442
529
|
if not required:
|
|
443
530
|
required = RequiredResources(self._composite, key)
|
|
444
531
|
self._cache[key] = required
|
|
445
532
|
return required
|
|
446
533
|
|
|
447
|
-
def __bool__(self):
|
|
534
|
+
def __bool__(self) -> bool:
|
|
448
535
|
return bool(len(self))
|
|
449
536
|
|
|
450
|
-
def __len__(self):
|
|
537
|
+
def __len__(self) -> int:
|
|
451
538
|
names = set()
|
|
452
539
|
if self._composite.crossplane_v1:
|
|
453
540
|
for name, resource in self._composite.request.extra_resources:
|
|
@@ -461,7 +548,7 @@ class Requireds:
|
|
|
461
548
|
names.add(name)
|
|
462
549
|
return len(names)
|
|
463
550
|
|
|
464
|
-
def __contains__(self, key):
|
|
551
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
465
552
|
if self._composite.crossplane_v1:
|
|
466
553
|
if key in self._composite.request.extra_resources:
|
|
467
554
|
return True
|
|
@@ -474,8 +561,8 @@ class Requireds:
|
|
|
474
561
|
return True
|
|
475
562
|
return False
|
|
476
563
|
|
|
477
|
-
def __iter__(self):
|
|
478
|
-
names = set()
|
|
564
|
+
def __iter__(self) -> typing.Generator[tuple[str, RequiredResources]]:
|
|
565
|
+
names: set[str] = set()
|
|
479
566
|
if self._composite.crossplane_v1:
|
|
480
567
|
for name, resource in self._composite.request.extra_resources:
|
|
481
568
|
names.add(name)
|
|
@@ -491,81 +578,97 @@ class Requireds:
|
|
|
491
578
|
|
|
492
579
|
|
|
493
580
|
class RequiredResources:
|
|
494
|
-
def __init__(
|
|
581
|
+
def __init__(
|
|
582
|
+
self,
|
|
583
|
+
composite: BaseComposite,
|
|
584
|
+
name: protobuf.TypeString,
|
|
585
|
+
):
|
|
495
586
|
self.name = name
|
|
496
587
|
if composite.crossplane_v1:
|
|
497
|
-
self._selector =
|
|
498
|
-
|
|
588
|
+
self._selector: protobuf.MapMessage = cast(
|
|
589
|
+
protobuf.MapMessage,
|
|
590
|
+
composite.response.requirements.extra_resources[name],
|
|
591
|
+
)
|
|
592
|
+
self._resources: protobuf.MapMessage = cast(
|
|
593
|
+
protobuf.MapMessage, composite.request.extra_resources[name]
|
|
594
|
+
)
|
|
499
595
|
else:
|
|
500
|
-
self._selector =
|
|
501
|
-
|
|
502
|
-
|
|
596
|
+
self._selector: protobuf.MapMessage = cast(
|
|
597
|
+
protobuf.MapMessage, composite.response.requirements.resources[name]
|
|
598
|
+
)
|
|
599
|
+
self._resources: protobuf.MapMessage = cast(
|
|
600
|
+
protobuf.MapMessage, composite.request.required_resources[name]
|
|
601
|
+
)
|
|
602
|
+
self._cache: dict[int, RequiredResource] = {}
|
|
503
603
|
|
|
504
604
|
def __call__(
|
|
505
605
|
self,
|
|
506
|
-
kind=_notset,
|
|
507
|
-
apiVersion=_notset,
|
|
508
|
-
namespace=_notset,
|
|
509
|
-
name=_notset,
|
|
510
|
-
labels=_notset,
|
|
511
|
-
):
|
|
606
|
+
kind: str | _notset = _notset,
|
|
607
|
+
apiVersion: str | _notset = _notset,
|
|
608
|
+
namespace: str | _notset = _notset,
|
|
609
|
+
name: str | _notset = _notset,
|
|
610
|
+
labels: typing.Mapping[str, str] | _notset = _notset,
|
|
611
|
+
) -> typing.Self:
|
|
512
612
|
self._selector()
|
|
513
|
-
if kind
|
|
613
|
+
if kind is not _notset:
|
|
514
614
|
# Allow for apiVersion in the first arg and kind in the second arg
|
|
515
615
|
if "/" in kind or kind == "v1":
|
|
516
|
-
if apiVersion
|
|
616
|
+
if apiVersion is not _notset:
|
|
517
617
|
self.kind = apiVersion
|
|
518
618
|
apiVersion = kind
|
|
519
619
|
else:
|
|
520
620
|
self.kind = kind
|
|
521
|
-
if apiVersion
|
|
621
|
+
if apiVersion is not _notset:
|
|
522
622
|
self.apiVersion = apiVersion
|
|
523
|
-
if namespace
|
|
623
|
+
if namespace is not _notset:
|
|
524
624
|
self.namespace = namespace
|
|
525
|
-
if name
|
|
625
|
+
if name is not _notset:
|
|
526
626
|
self.matchName = name
|
|
527
|
-
if labels
|
|
627
|
+
if labels is not _notset:
|
|
528
628
|
self.matchLabels = labels
|
|
529
629
|
return self
|
|
530
630
|
|
|
531
631
|
@property
|
|
532
|
-
def apiVersion(self):
|
|
632
|
+
def apiVersion(self) -> protobuf.FieldMessage:
|
|
533
633
|
return self._selector.api_version
|
|
534
634
|
|
|
535
635
|
@apiVersion.setter
|
|
536
|
-
def apiVersion(self, apiVersion):
|
|
636
|
+
def apiVersion(self, apiVersion: protobuf.TypeString):
|
|
537
637
|
self._selector.api_version = apiVersion
|
|
538
638
|
|
|
539
639
|
@property
|
|
540
|
-
def kind(self):
|
|
640
|
+
def kind(self) -> protobuf.FieldMessage:
|
|
541
641
|
return self._selector.kind
|
|
542
642
|
|
|
543
643
|
@kind.setter
|
|
544
|
-
def kind(self, kind):
|
|
644
|
+
def kind(self, kind: protobuf.TypeString):
|
|
545
645
|
self._selector.kind = kind
|
|
546
646
|
|
|
547
647
|
@property
|
|
548
|
-
def namespace(self):
|
|
648
|
+
def namespace(self) -> protobuf.FieldMessage:
|
|
549
649
|
return self._selector.namespace
|
|
550
650
|
|
|
551
651
|
@namespace.setter
|
|
552
|
-
def namespace(self, namespace):
|
|
652
|
+
def namespace(self, namespace: protobuf.TypeString):
|
|
553
653
|
self._selector.namespace = namespace
|
|
554
654
|
|
|
555
655
|
@property
|
|
556
|
-
def matchName(self):
|
|
656
|
+
def matchName(self) -> protobuf.FieldMessage:
|
|
557
657
|
return self._selector.match_name
|
|
558
658
|
|
|
559
659
|
@matchName.setter
|
|
560
|
-
def matchName(self, name):
|
|
660
|
+
def matchName(self, name: protobuf.TypeString):
|
|
561
661
|
self._selector.match_name = name
|
|
562
662
|
|
|
563
663
|
@property
|
|
564
|
-
def matchLabels(self):
|
|
664
|
+
def matchLabels(self) -> protobuf.MapMessage:
|
|
565
665
|
return self._selector.match_labels.labels
|
|
566
666
|
|
|
567
667
|
@matchLabels.setter
|
|
568
|
-
def matchLabels(
|
|
668
|
+
def matchLabels(
|
|
669
|
+
self,
|
|
670
|
+
labels: typing.Mapping[str, str] | protobuf.Value | None,
|
|
671
|
+
):
|
|
569
672
|
self._selector.match_labels.labels()
|
|
570
673
|
if labels:
|
|
571
674
|
for entry in labels:
|
|
@@ -574,62 +677,67 @@ class RequiredResources:
|
|
|
574
677
|
elif isinstance(entry, (list, tuple)):
|
|
575
678
|
self._selector.match_labels.labels[entry[0]] = entry[1]
|
|
576
679
|
|
|
577
|
-
def __getitem__(self, ix):
|
|
680
|
+
def __getitem__(self, ix: int) -> RequiredResource:
|
|
578
681
|
resource = self._cache.get(ix)
|
|
579
682
|
if not resource:
|
|
580
683
|
resource = RequiredResource(self.name, ix, self._resources.items[ix])
|
|
581
684
|
self._cache[ix] = resource
|
|
582
685
|
return resource
|
|
583
686
|
|
|
584
|
-
def __bool__(self):
|
|
585
|
-
return bool(self
|
|
687
|
+
def __bool__(self) -> bool:
|
|
688
|
+
return bool(len(self))
|
|
586
689
|
|
|
587
|
-
def __len__(self):
|
|
690
|
+
def __len__(self) -> int:
|
|
588
691
|
return len(self._resources.items)
|
|
589
692
|
|
|
590
|
-
def __iter__(self):
|
|
693
|
+
def __iter__(self) -> typing.Generator[RequiredResource]:
|
|
591
694
|
for ix in range(len(self)):
|
|
592
695
|
yield self[ix]
|
|
593
696
|
|
|
594
697
|
|
|
595
698
|
class RequiredResource:
|
|
596
|
-
def __init__(
|
|
597
|
-
self
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
self.
|
|
603
|
-
self.
|
|
604
|
-
self.
|
|
605
|
-
self.
|
|
606
|
-
self.
|
|
607
|
-
self.
|
|
608
|
-
self.
|
|
609
|
-
|
|
610
|
-
|
|
699
|
+
def __init__(
|
|
700
|
+
self,
|
|
701
|
+
name: protobuf.TypeString,
|
|
702
|
+
ix: int,
|
|
703
|
+
resource: protobuf.Message,
|
|
704
|
+
):
|
|
705
|
+
self.name: protobuf.TypeString = name
|
|
706
|
+
self.ix: int = ix
|
|
707
|
+
self.observed: protobuf.Value = cast(protobuf.Value, resource.resource)
|
|
708
|
+
self.apiVersion: protobuf.Value = self.observed.apiVersion
|
|
709
|
+
self.kind: protobuf.Value = self.observed.kind
|
|
710
|
+
self.metadata: protobuf.Value = self.observed.metadata
|
|
711
|
+
self.spec: protobuf.Value = self.observed.spec
|
|
712
|
+
self.type: protobuf.Value = self.observed.type
|
|
713
|
+
self.data: protobuf.Value = self.observed.data
|
|
714
|
+
self.status: protobuf.Value = self.observed.status
|
|
715
|
+
self.conditions: Conditions = Conditions(resource)
|
|
716
|
+
self.connection: protobuf.MapMessage = self.observed.connection_details
|
|
717
|
+
|
|
718
|
+
def __bool__(self) -> bool:
|
|
611
719
|
return bool(self.observed)
|
|
612
720
|
|
|
613
721
|
|
|
614
722
|
class Schemas:
|
|
615
|
-
def __init__(self, composite):
|
|
616
|
-
self._composite = composite
|
|
617
|
-
self._cache = {}
|
|
723
|
+
def __init__(self, composite: BaseComposite):
|
|
724
|
+
self._composite: BaseComposite = composite
|
|
725
|
+
self._cache: dict[protobuf.TypeString, Schema] = {}
|
|
618
726
|
|
|
619
|
-
def __getattr__(self, key):
|
|
727
|
+
def __getattr__(self, key: protobuf.TypeString) -> Schema:
|
|
620
728
|
return self[key]
|
|
621
729
|
|
|
622
|
-
def __getitem__(self, key):
|
|
623
|
-
schema = self._cache.get(key)
|
|
730
|
+
def __getitem__(self, key: protobuf.TypeString) -> Schema:
|
|
731
|
+
schema: Schema | None = self._cache.get(key)
|
|
624
732
|
if not schema:
|
|
625
733
|
schema = Schema(self._composite, key)
|
|
626
734
|
self._cache[key] = schema
|
|
627
735
|
return schema
|
|
628
736
|
|
|
629
|
-
def __bool__(self):
|
|
737
|
+
def __bool__(self) -> bool:
|
|
630
738
|
return bool(len(self))
|
|
631
739
|
|
|
632
|
-
def __len__(self):
|
|
740
|
+
def __len__(self) -> int:
|
|
633
741
|
names = set()
|
|
634
742
|
for name, schema in self._composite.request.required_schemas:
|
|
635
743
|
names.add(name)
|
|
@@ -637,13 +745,13 @@ class Schemas:
|
|
|
637
745
|
names.add(name)
|
|
638
746
|
return len(names)
|
|
639
747
|
|
|
640
|
-
def __contains__(self, key):
|
|
748
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
641
749
|
if key in self._composite.request.required_schemas:
|
|
642
750
|
return True
|
|
643
751
|
return key in self._composite.response.requirements.schemas
|
|
644
752
|
|
|
645
|
-
def __iter__(self):
|
|
646
|
-
names = set()
|
|
753
|
+
def __iter__(self) -> typing.Generator[tuple[str, Schema]]:
|
|
754
|
+
names: set[str] = set()
|
|
647
755
|
for name, schema in self._composite.request.required_schemas:
|
|
648
756
|
names.add(name)
|
|
649
757
|
for name, selector in self._composite.response.requirements.schemas:
|
|
@@ -653,106 +761,128 @@ class Schemas:
|
|
|
653
761
|
|
|
654
762
|
|
|
655
763
|
class Schema:
|
|
656
|
-
def __init__(
|
|
657
|
-
self
|
|
658
|
-
|
|
659
|
-
|
|
764
|
+
def __init__(
|
|
765
|
+
self,
|
|
766
|
+
composite: BaseComposite,
|
|
767
|
+
name: protobuf.TypeString,
|
|
768
|
+
):
|
|
769
|
+
self.name: protobuf.TypeString = name
|
|
770
|
+
self._selector: protobuf.Message = cast(
|
|
771
|
+
protobuf.Message, composite.response.requirements.schemas[name]
|
|
772
|
+
)
|
|
773
|
+
self._schema: protobuf.Value = cast(
|
|
774
|
+
protobuf.Value, composite.request.required_schemas[name].openapi_v3
|
|
775
|
+
)
|
|
660
776
|
|
|
661
|
-
def __call__(
|
|
777
|
+
def __call__(
|
|
778
|
+
self, kind: str | _notset = _notset, apiVersion: str | _notset = _notset
|
|
779
|
+
) -> typing.Self:
|
|
662
780
|
self._selector()
|
|
663
|
-
if kind
|
|
781
|
+
if kind is not _notset:
|
|
664
782
|
# Allow for apiVersion in the first arg and kind in the second arg
|
|
665
783
|
if "/" in kind or kind == "v1":
|
|
666
|
-
if apiVersion
|
|
784
|
+
if apiVersion is not _notset:
|
|
667
785
|
self.kind = apiVersion
|
|
668
786
|
apiVersion = kind
|
|
669
787
|
else:
|
|
670
788
|
self.kind = kind
|
|
671
|
-
if apiVersion
|
|
789
|
+
if apiVersion is not _notset:
|
|
672
790
|
self.apiVersion = apiVersion
|
|
673
791
|
return self
|
|
674
792
|
|
|
675
793
|
@property
|
|
676
|
-
def apiVersion(self):
|
|
677
|
-
return self._selector.api_version
|
|
794
|
+
def apiVersion(self) -> protobuf.FieldMessage:
|
|
795
|
+
return cast(protobuf.FieldMessage, self._selector.api_version)
|
|
678
796
|
|
|
679
797
|
@apiVersion.setter
|
|
680
|
-
def apiVersion(self, apiVersion):
|
|
798
|
+
def apiVersion(self, apiVersion: protobuf.TypeString) -> None:
|
|
681
799
|
self._selector.api_version = apiVersion
|
|
682
800
|
|
|
683
801
|
@property
|
|
684
|
-
def kind(self):
|
|
685
|
-
return self._selector.kind
|
|
802
|
+
def kind(self) -> protobuf.FieldMessage:
|
|
803
|
+
return cast(protobuf.FieldMessage, self._selector.kind)
|
|
686
804
|
|
|
687
805
|
@kind.setter
|
|
688
|
-
def kind(self, kind):
|
|
806
|
+
def kind(self, kind: protobuf.TypeString) -> None:
|
|
689
807
|
self._selector.kind = kind
|
|
690
808
|
|
|
691
|
-
def __enter__(self):
|
|
809
|
+
def __enter__(self) -> typing.Self:
|
|
692
810
|
return self
|
|
693
811
|
|
|
694
|
-
def __exit__(
|
|
812
|
+
def __exit__(
|
|
813
|
+
self,
|
|
814
|
+
exc_type: type[BaseException] | None,
|
|
815
|
+
exc_value: BaseException | None,
|
|
816
|
+
traceback: types.TracebackType | None,
|
|
817
|
+
) -> None:
|
|
695
818
|
pass
|
|
696
819
|
|
|
697
|
-
def __aenter__(self):
|
|
820
|
+
def __aenter__(self) -> typing.Self:
|
|
698
821
|
return self
|
|
699
822
|
|
|
700
|
-
def __aexit__(
|
|
823
|
+
def __aexit__(
|
|
824
|
+
self,
|
|
825
|
+
exc_type: type[BaseException] | None,
|
|
826
|
+
exc_value: BaseException | None,
|
|
827
|
+
traceback: types.TracebackType | None,
|
|
828
|
+
):
|
|
701
829
|
pass
|
|
702
830
|
|
|
703
|
-
def __getattr__(self, key):
|
|
831
|
+
def __getattr__(self, key: protobuf.TypeString) -> protobuf.Value:
|
|
704
832
|
return self[key]
|
|
705
833
|
|
|
706
|
-
def __getitem__(self, key):
|
|
834
|
+
def __getitem__(self, key: protobuf.TypeString) -> protobuf.Value:
|
|
707
835
|
return self._schema[key]
|
|
708
836
|
|
|
709
|
-
def __bool__(self):
|
|
710
|
-
return bool(self
|
|
837
|
+
def __bool__(self) -> bool:
|
|
838
|
+
return bool(len(self))
|
|
711
839
|
|
|
712
|
-
def __len__(self):
|
|
840
|
+
def __len__(self) -> int:
|
|
713
841
|
return len(self._schema)
|
|
714
842
|
|
|
715
|
-
def __contains__(self, item):
|
|
843
|
+
def __contains__(self, item: protobuf.TypeString) -> bool:
|
|
716
844
|
return item in self._schema
|
|
717
845
|
|
|
718
|
-
def __iter__(self):
|
|
846
|
+
def __iter__(self) -> typing.Generator[str, protobuf.Value]:
|
|
719
847
|
yield from self._schema
|
|
720
848
|
|
|
721
|
-
def __hash__(self):
|
|
849
|
+
def __hash__(self) -> int:
|
|
722
850
|
return hash(self._schema)
|
|
723
851
|
|
|
724
|
-
def __eq__(self, other):
|
|
852
|
+
def __eq__(self, other: object) -> bool:
|
|
725
853
|
if isinstance(other, Schema):
|
|
726
854
|
other = other._schema
|
|
727
855
|
return self._schema == other
|
|
728
856
|
|
|
729
|
-
def __str__(self):
|
|
857
|
+
def __str__(self) -> str:
|
|
730
858
|
return str(self._schema)
|
|
731
859
|
|
|
732
|
-
def __format__(self, spec="yaml"):
|
|
860
|
+
def __format__(self, spec: str = "yaml") -> str:
|
|
733
861
|
return format(self._schema, spec)
|
|
734
862
|
|
|
735
863
|
|
|
736
864
|
class Conditions:
|
|
737
|
-
def __init__(
|
|
738
|
-
self.
|
|
739
|
-
|
|
865
|
+
def __init__(
|
|
866
|
+
self, observed: protobuf.Message, response: protobuf.Message | None = None
|
|
867
|
+
):
|
|
868
|
+
self._observed: protobuf.Message = observed
|
|
869
|
+
self._response: protobuf.Message | None = response
|
|
740
870
|
|
|
741
|
-
def __getattr__(self, type):
|
|
871
|
+
def __getattr__(self, type: str) -> Condition:
|
|
742
872
|
return self[type]
|
|
743
873
|
|
|
744
|
-
def __getitem__(self, type):
|
|
874
|
+
def __getitem__(self, type: str) -> Condition:
|
|
745
875
|
return Condition(self, type)
|
|
746
876
|
|
|
747
|
-
def __bool__(self):
|
|
748
|
-
if self._response is not None and self._response.conditions:
|
|
877
|
+
def __bool__(self) -> bool:
|
|
878
|
+
if self._response is not None and len(self._response.conditions):
|
|
749
879
|
return True
|
|
750
|
-
return bool(self
|
|
880
|
+
return bool(len(self))
|
|
751
881
|
|
|
752
|
-
def __len__(self):
|
|
882
|
+
def __len__(self) -> int:
|
|
753
883
|
return len(self._types())
|
|
754
884
|
|
|
755
|
-
def __iter__(self):
|
|
885
|
+
def __iter__(self) -> typing.Generator[Condition]:
|
|
756
886
|
for type in self._types():
|
|
757
887
|
yield self[type]
|
|
758
888
|
|
|
@@ -769,14 +899,14 @@ class Conditions:
|
|
|
769
899
|
|
|
770
900
|
|
|
771
901
|
class Condition(protobuf.ProtobufValue):
|
|
772
|
-
def __init__(self, conditions, type):
|
|
773
|
-
self._conditions = conditions
|
|
774
|
-
self.type = type
|
|
902
|
+
def __init__(self, conditions: Conditions, type: str):
|
|
903
|
+
self._conditions: Conditions = conditions
|
|
904
|
+
self.type: str = type
|
|
775
905
|
|
|
776
906
|
@property
|
|
777
|
-
def _protobuf_value(self):
|
|
907
|
+
def _protobuf_value(self) -> dict[str, protobuf.FieldMessage | str]:
|
|
778
908
|
status = self.status
|
|
779
|
-
value = {
|
|
909
|
+
value: dict[str, protobuf.FieldMessage | str] = {
|
|
780
910
|
"type": self.type,
|
|
781
911
|
"status": "Unknown" if status is None else str(status),
|
|
782
912
|
"reason": self.reason or "",
|
|
@@ -787,21 +917,27 @@ class Condition(protobuf.ProtobufValue):
|
|
|
787
917
|
value["lastTransitionTime"] = time.isoformat().replace("+00:00", "Z")
|
|
788
918
|
return value
|
|
789
919
|
|
|
790
|
-
def __call__(
|
|
791
|
-
self
|
|
792
|
-
|
|
920
|
+
def __call__(
|
|
921
|
+
self,
|
|
922
|
+
reason: protobuf.TypeString | _notset = _notset,
|
|
923
|
+
message: protobuf.TypeString | _notset = _notset,
|
|
924
|
+
status: bool | protobuf.Value | None | _notset = _notset,
|
|
925
|
+
claim: bool | protobuf.Value | None | _notset = _notset,
|
|
926
|
+
) -> typing.Self:
|
|
927
|
+
self._ensure_condition()
|
|
928
|
+
if reason is not _notset:
|
|
793
929
|
self.reason = reason
|
|
794
|
-
if message
|
|
930
|
+
if message is not _notset:
|
|
795
931
|
self.message = message
|
|
796
|
-
if status
|
|
932
|
+
if status is not _notset:
|
|
797
933
|
self.status = status
|
|
798
|
-
if claim
|
|
934
|
+
if claim is not _notset:
|
|
799
935
|
self.claim = claim
|
|
800
936
|
return self
|
|
801
937
|
|
|
802
938
|
@property
|
|
803
|
-
def status(self):
|
|
804
|
-
condition = self.
|
|
939
|
+
def status(self) -> bool | None:
|
|
940
|
+
condition = self._get_condition()
|
|
805
941
|
if condition:
|
|
806
942
|
if condition.status in (fnv1.Status.STATUS_CONDITION_TRUE, "True", True):
|
|
807
943
|
return True
|
|
@@ -810,8 +946,8 @@ class Condition(protobuf.ProtobufValue):
|
|
|
810
946
|
return None
|
|
811
947
|
|
|
812
948
|
@status.setter
|
|
813
|
-
def status(self, status):
|
|
814
|
-
condition = self.
|
|
949
|
+
def status(self, status: bool | protobuf.Value | None) -> None:
|
|
950
|
+
condition = self._ensure_condition()
|
|
815
951
|
if status:
|
|
816
952
|
condition.status = fnv1.Status.STATUS_CONDITION_TRUE
|
|
817
953
|
elif status == None:
|
|
@@ -822,29 +958,29 @@ class Condition(protobuf.ProtobufValue):
|
|
|
822
958
|
condition.status = fnv1.Status.STATUS_CONDITION_FALSE
|
|
823
959
|
|
|
824
960
|
@property
|
|
825
|
-
def reason(self):
|
|
826
|
-
condition = self.
|
|
961
|
+
def reason(self) -> protobuf.FieldMessage | None:
|
|
962
|
+
condition = self._get_condition()
|
|
827
963
|
if condition:
|
|
828
|
-
return condition.reason
|
|
964
|
+
return cast(protobuf.FieldMessage, condition.reason)
|
|
829
965
|
return None
|
|
830
966
|
|
|
831
967
|
@reason.setter
|
|
832
|
-
def reason(self, reason):
|
|
833
|
-
self.
|
|
968
|
+
def reason(self, reason: protobuf.TypeString) -> None:
|
|
969
|
+
self._ensure_condition().reason = reason
|
|
834
970
|
|
|
835
971
|
@property
|
|
836
|
-
def message(self):
|
|
837
|
-
condition = self.
|
|
972
|
+
def message(self) -> protobuf.FieldMessage | None:
|
|
973
|
+
condition = self._get_condition()
|
|
838
974
|
if condition:
|
|
839
|
-
return condition.message
|
|
975
|
+
return cast(protobuf.FieldMessage, condition.message)
|
|
840
976
|
return None
|
|
841
977
|
|
|
842
978
|
@message.setter
|
|
843
|
-
def message(self, message):
|
|
844
|
-
self.
|
|
979
|
+
def message(self, message: protobuf.TypeString) -> None:
|
|
980
|
+
self._ensure_condition().message = message
|
|
845
981
|
|
|
846
982
|
@property
|
|
847
|
-
def lastTransitionTime(self):
|
|
983
|
+
def lastTransitionTime(self) -> datetime.datetime | None:
|
|
848
984
|
for observed in self._conditions._observed.resource.status.conditions:
|
|
849
985
|
if observed.type == self.type:
|
|
850
986
|
time = observed.lastTransitionTime
|
|
@@ -853,13 +989,16 @@ class Condition(protobuf.ProtobufValue):
|
|
|
853
989
|
return None
|
|
854
990
|
|
|
855
991
|
@property
|
|
856
|
-
def claim(self):
|
|
857
|
-
condition = self.
|
|
858
|
-
return
|
|
992
|
+
def claim(self) -> bool:
|
|
993
|
+
condition = self._get_condition()
|
|
994
|
+
return (
|
|
995
|
+
bool(condition)
|
|
996
|
+
and condition.target == fnv1.Target.TARGET_COMPOSITE_AND_CLAIM
|
|
997
|
+
)
|
|
859
998
|
|
|
860
999
|
@claim.setter
|
|
861
|
-
def claim(self, claim):
|
|
862
|
-
condition = self.
|
|
1000
|
+
def claim(self, claim: bool | protobuf.Value | None) -> None:
|
|
1001
|
+
condition = self._ensure_condition()
|
|
863
1002
|
if claim:
|
|
864
1003
|
condition.target = fnv1.Target.TARGET_COMPOSITE_AND_CLAIM
|
|
865
1004
|
elif claim == None or (isinstance(claim, protobuf.Value) and claim._isUnknown):
|
|
@@ -867,146 +1006,196 @@ class Condition(protobuf.ProtobufValue):
|
|
|
867
1006
|
else:
|
|
868
1007
|
condition.target = fnv1.Target.TARGET_COMPOSITE
|
|
869
1008
|
|
|
870
|
-
def
|
|
1009
|
+
def _get_condition(self, ensure: bool = False) -> protobuf.Message | None:
|
|
871
1010
|
if self._conditions._response is not None:
|
|
872
1011
|
for condition in self._conditions._response.conditions:
|
|
873
1012
|
if condition.type == self.type:
|
|
874
1013
|
return condition
|
|
875
|
-
if not
|
|
1014
|
+
if not ensure:
|
|
876
1015
|
for observed in self._conditions._observed.resource.status.conditions:
|
|
877
1016
|
if observed.type == self.type:
|
|
878
1017
|
return observed
|
|
879
|
-
|
|
1018
|
+
return None
|
|
1019
|
+
|
|
1020
|
+
def _ensure_condition(self) -> protobuf.Message:
|
|
1021
|
+
condition = self._get_condition(True)
|
|
1022
|
+
if condition:
|
|
1023
|
+
return condition
|
|
880
1024
|
if self._conditions._response is None:
|
|
881
1025
|
raise ValueError("Condition is read only")
|
|
882
1026
|
condition = fnv1.Condition()
|
|
883
1027
|
condition.type = self.type
|
|
884
|
-
|
|
1028
|
+
self._conditions._response.conditions.append(condition)
|
|
1029
|
+
return cast(protobuf.Message, self._conditions._response.conditions[-1])
|
|
885
1030
|
|
|
886
1031
|
|
|
887
1032
|
class Results:
|
|
888
|
-
def __init__(self, response):
|
|
889
|
-
self._results =
|
|
1033
|
+
def __init__(self, response: protobuf.Message):
|
|
1034
|
+
self._results: protobuf.RepeatedMessage = cast(
|
|
1035
|
+
protobuf.RepeatedMessage, response.results
|
|
1036
|
+
)
|
|
890
1037
|
|
|
891
|
-
def info(
|
|
892
|
-
|
|
1038
|
+
def info(
|
|
1039
|
+
self,
|
|
1040
|
+
reason: protobuf.TypeString | _notset = _notset,
|
|
1041
|
+
message: protobuf.TypeString | _notset = _notset,
|
|
1042
|
+
claim: bool | protobuf.Value | None | _notset = _notset,
|
|
1043
|
+
) -> Result:
|
|
1044
|
+
self._results.append()
|
|
1045
|
+
result = Result(self._results[-1])
|
|
893
1046
|
result.info = True
|
|
894
|
-
if reason
|
|
1047
|
+
if reason is not _notset:
|
|
895
1048
|
result.reason = reason
|
|
896
|
-
if message
|
|
1049
|
+
if message is not _notset:
|
|
897
1050
|
result.message = message
|
|
898
|
-
if claim
|
|
1051
|
+
if claim is not _notset:
|
|
899
1052
|
result.claim = claim
|
|
900
1053
|
return result
|
|
901
1054
|
|
|
902
|
-
def warning(
|
|
903
|
-
|
|
1055
|
+
def warning(
|
|
1056
|
+
self,
|
|
1057
|
+
reason: protobuf.TypeString | _notset = _notset,
|
|
1058
|
+
message: protobuf.TypeString | _notset = _notset,
|
|
1059
|
+
claim: bool | protobuf.Value | None | _notset = _notset,
|
|
1060
|
+
) -> Result:
|
|
1061
|
+
self._results.append()
|
|
1062
|
+
result = Result(self._results[-1])
|
|
904
1063
|
result.warning = True
|
|
905
|
-
if reason
|
|
1064
|
+
if reason is not _notset:
|
|
906
1065
|
result.reason = reason
|
|
907
|
-
if message
|
|
1066
|
+
if message is not _notset:
|
|
908
1067
|
result.message = message
|
|
909
|
-
if claim
|
|
1068
|
+
if claim is not _notset:
|
|
910
1069
|
result.claim = claim
|
|
911
1070
|
return result
|
|
912
1071
|
|
|
913
|
-
def fatal(
|
|
914
|
-
|
|
1072
|
+
def fatal(
|
|
1073
|
+
self,
|
|
1074
|
+
reason: protobuf.TypeString | _notset = _notset,
|
|
1075
|
+
message: protobuf.TypeString | _notset = _notset,
|
|
1076
|
+
claim: bool | protobuf.Value | None | _notset = _notset,
|
|
1077
|
+
) -> Result:
|
|
1078
|
+
self._results.append()
|
|
1079
|
+
result = Result(self._results[-1])
|
|
915
1080
|
result.fatal = True
|
|
916
|
-
if reason
|
|
1081
|
+
if reason is not _notset:
|
|
917
1082
|
result.reason = reason
|
|
918
|
-
if message
|
|
1083
|
+
if message is not _notset:
|
|
919
1084
|
result.message = message
|
|
920
|
-
if claim
|
|
1085
|
+
if claim is not _notset:
|
|
921
1086
|
result.claim = claim
|
|
922
1087
|
return result
|
|
923
1088
|
|
|
924
|
-
def __bool__(self):
|
|
925
|
-
return len(self)
|
|
1089
|
+
def __bool__(self) -> bool:
|
|
1090
|
+
return bool(len(self))
|
|
926
1091
|
|
|
927
|
-
def __len__(self):
|
|
1092
|
+
def __len__(self) -> int:
|
|
928
1093
|
return len(self._results)
|
|
929
1094
|
|
|
930
|
-
def __getitem__(self, key):
|
|
1095
|
+
def __getitem__(self, key: int) -> Result:
|
|
931
1096
|
if key >= len(self._results):
|
|
932
1097
|
return Result()
|
|
933
1098
|
return Result(self._results[key])
|
|
934
1099
|
|
|
935
|
-
def __iter__(self):
|
|
1100
|
+
def __iter__(self) -> typing.Generator[Result]:
|
|
936
1101
|
for ix in range(len(self._results)):
|
|
937
1102
|
yield self[ix]
|
|
938
1103
|
|
|
939
1104
|
|
|
940
1105
|
class Result:
|
|
941
|
-
def __init__(self, result=None):
|
|
942
|
-
self._result = result
|
|
1106
|
+
def __init__(self, result: protobuf.Message | None = None):
|
|
1107
|
+
self._result: protobuf.Message | None = result
|
|
943
1108
|
|
|
944
|
-
def __bool__(self):
|
|
1109
|
+
def __bool__(self) -> bool:
|
|
945
1110
|
return self._result is not None
|
|
946
1111
|
|
|
947
1112
|
@property
|
|
948
|
-
def info(self):
|
|
949
|
-
return
|
|
1113
|
+
def info(self) -> bool:
|
|
1114
|
+
return (
|
|
1115
|
+
self._result is not None
|
|
1116
|
+
and self._result.severity == fnv1.Severity.SEVERITY_NORMAL
|
|
1117
|
+
)
|
|
950
1118
|
|
|
951
1119
|
@info.setter
|
|
952
|
-
def info(self, info):
|
|
953
|
-
if
|
|
1120
|
+
def info(self, info: bool | protobuf.Value | protobuf.FieldMessage | None) -> None:
|
|
1121
|
+
if self._result is not None:
|
|
954
1122
|
if info:
|
|
955
1123
|
self._result.severity = fnv1.Severity.SEVERITY_NORMAL
|
|
956
1124
|
else:
|
|
957
1125
|
self._result.severity = fnv1.Severity.SEVERITY_UNSPECIFIED
|
|
958
1126
|
|
|
959
1127
|
@property
|
|
960
|
-
def warning(self):
|
|
961
|
-
return
|
|
1128
|
+
def warning(self) -> bool:
|
|
1129
|
+
return (
|
|
1130
|
+
self._result is not None
|
|
1131
|
+
and self._result.severity == fnv1.Severity.SEVERITY_WARNING
|
|
1132
|
+
)
|
|
962
1133
|
|
|
963
1134
|
@warning.setter
|
|
964
|
-
def warning(
|
|
965
|
-
|
|
1135
|
+
def warning(
|
|
1136
|
+
self, warning: bool | protobuf.Value | protobuf.FieldMessage | None
|
|
1137
|
+
) -> None:
|
|
1138
|
+
if self._result is not None:
|
|
966
1139
|
if warning:
|
|
967
1140
|
self._result.severity = fnv1.Severity.SEVERITY_WARNING
|
|
968
1141
|
else:
|
|
969
1142
|
self._result.severity = fnv1.Severity.SEVERITY_NORMAL
|
|
970
1143
|
|
|
971
1144
|
@property
|
|
972
|
-
def fatal(self):
|
|
973
|
-
return
|
|
1145
|
+
def fatal(self) -> bool:
|
|
1146
|
+
return (
|
|
1147
|
+
self._result is not None
|
|
1148
|
+
and self._result.severity == fnv1.Severity.SEVERITY_FATAL
|
|
1149
|
+
)
|
|
974
1150
|
|
|
975
1151
|
@fatal.setter
|
|
976
|
-
def fatal(
|
|
977
|
-
|
|
1152
|
+
def fatal(
|
|
1153
|
+
self, fatal: bool | protobuf.Value | protobuf.FieldMessage | None
|
|
1154
|
+
) -> None:
|
|
1155
|
+
if self._result is not None:
|
|
978
1156
|
if fatal:
|
|
979
1157
|
self._result.severity = fnv1.Severity.SEVERITY_FATAL
|
|
980
1158
|
else:
|
|
981
1159
|
self._result.severity = fnv1.Severity.SEVERITY_NORMAL
|
|
982
1160
|
|
|
983
1161
|
@property
|
|
984
|
-
def reason(self):
|
|
985
|
-
return
|
|
1162
|
+
def reason(self) -> protobuf.FieldMessage | None:
|
|
1163
|
+
return (
|
|
1164
|
+
cast(protobuf.FieldMessage, self._result.reason)
|
|
1165
|
+
if self._result is not None
|
|
1166
|
+
else None
|
|
1167
|
+
)
|
|
986
1168
|
|
|
987
1169
|
@reason.setter
|
|
988
|
-
def reason(self, reason):
|
|
989
|
-
if
|
|
1170
|
+
def reason(self, reason: protobuf.TypeString):
|
|
1171
|
+
if self._result is not None:
|
|
990
1172
|
self._result.reason = reason
|
|
991
1173
|
|
|
992
1174
|
@property
|
|
993
|
-
def message(self):
|
|
994
|
-
return
|
|
1175
|
+
def message(self) -> protobuf.FieldMessage | None:
|
|
1176
|
+
return (
|
|
1177
|
+
cast(protobuf.FieldMessage, self._result.message)
|
|
1178
|
+
if self._result is not None
|
|
1179
|
+
else None
|
|
1180
|
+
)
|
|
995
1181
|
|
|
996
1182
|
@message.setter
|
|
997
|
-
def message(self, message):
|
|
998
|
-
if
|
|
1183
|
+
def message(self, message: protobuf.TypeString):
|
|
1184
|
+
if self._result is not None:
|
|
999
1185
|
self._result.message = message
|
|
1000
1186
|
|
|
1001
1187
|
@property
|
|
1002
|
-
def claim(self):
|
|
1188
|
+
def claim(self) -> bool:
|
|
1003
1189
|
return (
|
|
1004
|
-
|
|
1190
|
+
self._result is not None
|
|
1191
|
+
and self._result.target == fnv1.Target.TARGET_COMPOSITE_AND_CLAIM
|
|
1005
1192
|
)
|
|
1006
1193
|
|
|
1007
1194
|
@claim.setter
|
|
1008
|
-
def claim(
|
|
1009
|
-
|
|
1195
|
+
def claim(
|
|
1196
|
+
self, claim: bool | protobuf.Value | protobuf.FieldMessage | None
|
|
1197
|
+
) -> None:
|
|
1198
|
+
if self._result is not None:
|
|
1010
1199
|
if claim:
|
|
1011
1200
|
self._result.target = fnv1.Target.TARGET_COMPOSITE_AND_CLAIM
|
|
1012
1201
|
elif claim == None or (
|
|
@@ -1018,42 +1207,45 @@ class Result:
|
|
|
1018
1207
|
|
|
1019
1208
|
|
|
1020
1209
|
class _Connection:
|
|
1021
|
-
def __init__(self, composite):
|
|
1022
|
-
self.
|
|
1023
|
-
|
|
1024
|
-
def _set_attribute(self, key, value):
|
|
1025
|
-
self.__dict__[key] = value
|
|
1210
|
+
def __init__(self, composite: BaseComposite):
|
|
1211
|
+
self._composite: BaseComposite = composite
|
|
1026
1212
|
|
|
1027
1213
|
@property
|
|
1028
|
-
def _resource_name(self):
|
|
1214
|
+
def _resource_name(self) -> protobuf.Value | str:
|
|
1029
1215
|
return self._composite.connectionSecret.resourceName or "connection-secret"
|
|
1030
1216
|
|
|
1031
1217
|
@property
|
|
1032
|
-
def observed(self):
|
|
1033
|
-
return
|
|
1218
|
+
def observed(self) -> protobuf.MapMessage:
|
|
1219
|
+
return cast(
|
|
1220
|
+
protobuf.MapMessage,
|
|
1221
|
+
self._composite.request.observed.composite.connection_details,
|
|
1222
|
+
)
|
|
1034
1223
|
|
|
1035
|
-
def __getattr__(self, key):
|
|
1224
|
+
def __getattr__(self, key: protobuf.TypeString) -> protobuf.FieldMessage:
|
|
1036
1225
|
return self[key]
|
|
1037
1226
|
|
|
1038
|
-
def __getitem__(self, key):
|
|
1039
|
-
return
|
|
1227
|
+
def __getitem__(self, key: protobuf.TypeString) -> protobuf.FieldMessage:
|
|
1228
|
+
return cast(
|
|
1229
|
+
protobuf.FieldMessage,
|
|
1230
|
+
self._composite.response.desired.composite.connection_details[key],
|
|
1231
|
+
)
|
|
1040
1232
|
|
|
1041
|
-
def __bool__(self):
|
|
1042
|
-
return bool(self
|
|
1233
|
+
def __bool__(self) -> bool:
|
|
1234
|
+
return bool(len(self))
|
|
1043
1235
|
|
|
1044
|
-
def __len__(self):
|
|
1236
|
+
def __len__(self) -> int:
|
|
1045
1237
|
return len(self._composite.response.desired.composite.connection_details)
|
|
1046
1238
|
|
|
1047
|
-
def __contains__(self, key):
|
|
1239
|
+
def __contains__(self, key: protobuf.TypeString) -> bool:
|
|
1048
1240
|
return key in self._composite.response.desired.composite.connection_details
|
|
1049
1241
|
|
|
1050
|
-
def __iter__(self):
|
|
1242
|
+
def __iter__(self) -> typing.Generator[tuple[str, protobuf.FieldMessage]]:
|
|
1051
1243
|
yield from self._composite.response.desired.composite.connection_details
|
|
1052
1244
|
|
|
1053
|
-
def __str__(self):
|
|
1245
|
+
def __str__(self) -> str:
|
|
1054
1246
|
return format(self)
|
|
1055
1247
|
|
|
1056
|
-
def __format__(self, spec="yaml"):
|
|
1248
|
+
def __format__(self, spec: str = "yaml") -> str:
|
|
1057
1249
|
return format(
|
|
1058
1250
|
self._composite.response.desired.composite.connection_details, spec
|
|
1059
1251
|
)
|
|
@@ -1066,10 +1258,21 @@ class _Connection:
|
|
|
1066
1258
|
for key, value in kwargs.items():
|
|
1067
1259
|
self[key] = value
|
|
1068
1260
|
|
|
1069
|
-
def __setattr__(
|
|
1070
|
-
self
|
|
1261
|
+
def __setattr__(
|
|
1262
|
+
self,
|
|
1263
|
+
key: protobuf.TypeString,
|
|
1264
|
+
value: protobuf.TypeString,
|
|
1265
|
+
) -> None:
|
|
1266
|
+
if key == "_composite":
|
|
1267
|
+
self.__dict__[str(key)] = value
|
|
1268
|
+
else:
|
|
1269
|
+
self[key] = value
|
|
1071
1270
|
|
|
1072
|
-
def __setitem__(
|
|
1271
|
+
def __setitem__(
|
|
1272
|
+
self,
|
|
1273
|
+
key: protobuf.TypeString,
|
|
1274
|
+
value: protobuf.TypeString,
|
|
1275
|
+
) -> None:
|
|
1073
1276
|
if not isinstance(value, str):
|
|
1074
1277
|
if value is None:
|
|
1075
1278
|
return
|
|
@@ -1098,10 +1301,10 @@ class _Connection:
|
|
|
1098
1301
|
secret.type = "connection.crossplane.io/v1alpha1"
|
|
1099
1302
|
secret.data[key] = protobuf.B64Encode(value)
|
|
1100
1303
|
|
|
1101
|
-
def __delattr__(self, key):
|
|
1304
|
+
def __delattr__(self, key: protobuf.TypeString):
|
|
1102
1305
|
del self[key]
|
|
1103
1306
|
|
|
1104
|
-
def __delitem__(self, key):
|
|
1307
|
+
def __delitem__(self, key: protobuf.TypeString):
|
|
1105
1308
|
del self._composite.response.desired.composite.connection_details[key]
|
|
1106
1309
|
if self._composite.crossplane_v1:
|
|
1107
1310
|
return
|