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