crossplane-function-sdk-python 0.3.0__py3-none-any.whl → 0.4.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/function/__version__.py +1 -1
- crossplane/function/proto/v1/run_function.proto +326 -0
- crossplane/function/proto/v1/run_function_pb2.py +103 -0
- crossplane/function/proto/v1/run_function_pb2.pyi +232 -0
- crossplane/function/proto/v1/run_function_pb2_grpc.py +101 -0
- crossplane/function/proto/v1beta1/run_function.proto +72 -3
- crossplane/function/proto/v1beta1/run_function_pb2.py +59 -42
- crossplane/function/proto/v1beta1/run_function_pb2.pyi +44 -4
- crossplane/function/proto/v1beta1/run_function_pb2_grpc.py +35 -4
- crossplane/function/resource.py +4 -1
- crossplane/function/response.py +14 -14
- crossplane/function/runtime.py +35 -2
- {crossplane_function_sdk_python-0.3.0.dist-info → crossplane_function_sdk_python-0.4.0.dist-info}/METADATA +2 -1
- crossplane_function_sdk_python-0.4.0.dist-info/RECORD +17 -0
- crossplane_function_sdk_python-0.3.0.dist-info/RECORD +0 -13
- {crossplane_function_sdk_python-0.3.0.dist-info → crossplane_function_sdk_python-0.4.0.dist-info}/WHEEL +0 -0
- {crossplane_function_sdk_python-0.3.0.dist-info → crossplane_function_sdk_python-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from crossplane.function.proto.v1 import run_function_pb2 as crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2
|
|
7
|
+
|
|
8
|
+
GRPC_GENERATED_VERSION = '1.66.0'
|
|
9
|
+
GRPC_VERSION = grpc.__version__
|
|
10
|
+
_version_not_supported = False
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from grpc._utilities import first_version_is_lower
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ f' but the generated code in crossplane/function/proto/v1/run_function_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class FunctionRunnerServiceStub(object):
|
|
29
|
+
"""A FunctionRunnerService is a Composition Function.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, channel):
|
|
33
|
+
"""Constructor.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
channel: A grpc.Channel.
|
|
37
|
+
"""
|
|
38
|
+
self.RunFunction = channel.unary_unary(
|
|
39
|
+
'/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction',
|
|
40
|
+
request_serializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
|
41
|
+
response_deserializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
|
42
|
+
_registered_method=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class FunctionRunnerServiceServicer(object):
|
|
46
|
+
"""A FunctionRunnerService is a Composition Function.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def RunFunction(self, request, context):
|
|
50
|
+
"""RunFunction runs the Composition Function.
|
|
51
|
+
"""
|
|
52
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
53
|
+
context.set_details('Method not implemented!')
|
|
54
|
+
raise NotImplementedError('Method not implemented!')
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def add_FunctionRunnerServiceServicer_to_server(servicer, server):
|
|
58
|
+
rpc_method_handlers = {
|
|
59
|
+
'RunFunction': grpc.unary_unary_rpc_method_handler(
|
|
60
|
+
servicer.RunFunction,
|
|
61
|
+
request_deserializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.FromString,
|
|
62
|
+
response_serializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.SerializeToString,
|
|
63
|
+
),
|
|
64
|
+
}
|
|
65
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
66
|
+
'apiextensions.fn.proto.v1.FunctionRunnerService', rpc_method_handlers)
|
|
67
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
68
|
+
server.add_registered_method_handlers('apiextensions.fn.proto.v1.FunctionRunnerService', rpc_method_handlers)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# This class is part of an EXPERIMENTAL API.
|
|
72
|
+
class FunctionRunnerService(object):
|
|
73
|
+
"""A FunctionRunnerService is a Composition Function.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def RunFunction(request,
|
|
78
|
+
target,
|
|
79
|
+
options=(),
|
|
80
|
+
channel_credentials=None,
|
|
81
|
+
call_credentials=None,
|
|
82
|
+
insecure=False,
|
|
83
|
+
compression=None,
|
|
84
|
+
wait_for_ready=None,
|
|
85
|
+
timeout=None,
|
|
86
|
+
metadata=None):
|
|
87
|
+
return grpc.experimental.unary_unary(
|
|
88
|
+
request,
|
|
89
|
+
target,
|
|
90
|
+
'/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction',
|
|
91
|
+
crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
|
92
|
+
crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
|
93
|
+
options,
|
|
94
|
+
channel_credentials,
|
|
95
|
+
insecure,
|
|
96
|
+
call_credentials,
|
|
97
|
+
compression,
|
|
98
|
+
wait_for_ready,
|
|
99
|
+
timeout,
|
|
100
|
+
metadata,
|
|
101
|
+
_registered_method=True)
|
|
@@ -19,11 +19,12 @@ syntax = "proto3";
|
|
|
19
19
|
import "google/protobuf/struct.proto";
|
|
20
20
|
import "google/protobuf/duration.proto";
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
// https://github.com/crossplane/crossplane/tree/master/apis/apiextensions/fn/proto
|
|
22
|
+
// Generated from apiextensions/fn/proto/v1/run_function.proto by ../hack/duplicate_proto_type.sh. DO NOT EDIT.
|
|
23
|
+
|
|
25
24
|
package apiextensions.fn.proto.v1beta1;
|
|
26
25
|
|
|
26
|
+
option go_package = "github.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1beta1";
|
|
27
|
+
|
|
27
28
|
// A FunctionRunnerService is a Composition Function.
|
|
28
29
|
service FunctionRunnerService {
|
|
29
30
|
// RunFunction runs the Composition Function.
|
|
@@ -122,6 +123,10 @@ message RunFunctionResponse {
|
|
|
122
123
|
|
|
123
124
|
// Requirements that must be satisfied for this Function to run successfully.
|
|
124
125
|
Requirements requirements = 5;
|
|
126
|
+
|
|
127
|
+
// Status conditions to be applied to the composite resource. Conditions may also
|
|
128
|
+
// optionally be applied to the composite resource's associated claim.
|
|
129
|
+
repeated Condition conditions = 6;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
// RequestMeta contains metadata pertaining to a RunFunctionRequest.
|
|
@@ -140,11 +145,18 @@ message Requirements {
|
|
|
140
145
|
|
|
141
146
|
// ResourceSelector selects a group of resources, either by name or by label.
|
|
142
147
|
message ResourceSelector {
|
|
148
|
+
// API version of resources to select.
|
|
143
149
|
string api_version = 1;
|
|
150
|
+
|
|
151
|
+
// Kind of resources to select.
|
|
144
152
|
string kind = 2;
|
|
145
153
|
|
|
154
|
+
// Resources to match.
|
|
146
155
|
oneof match {
|
|
156
|
+
// Match the resource with this name.
|
|
147
157
|
string match_name = 3;
|
|
158
|
+
|
|
159
|
+
// Match all resources with these labels.
|
|
148
160
|
MatchLabels match_labels = 4;
|
|
149
161
|
}
|
|
150
162
|
}
|
|
@@ -237,6 +249,13 @@ message Result {
|
|
|
237
249
|
|
|
238
250
|
// Human-readable details about the result.
|
|
239
251
|
string message = 2;
|
|
252
|
+
|
|
253
|
+
// Optional PascalCase, machine-readable reason for this result. If omitted,
|
|
254
|
+
// the value will be ComposeResources.
|
|
255
|
+
optional string reason = 3;
|
|
256
|
+
|
|
257
|
+
// The resources this result targets.
|
|
258
|
+
optional Target target = 4;
|
|
240
259
|
}
|
|
241
260
|
|
|
242
261
|
// Severity of Function results.
|
|
@@ -257,3 +276,53 @@ enum Severity {
|
|
|
257
276
|
// with the composite resource.
|
|
258
277
|
SEVERITY_NORMAL = 3;
|
|
259
278
|
}
|
|
279
|
+
|
|
280
|
+
// Target of Function results and conditions.
|
|
281
|
+
enum Target {
|
|
282
|
+
// If the target is unspecified, the result targets the composite resource.
|
|
283
|
+
TARGET_UNSPECIFIED = 0;
|
|
284
|
+
|
|
285
|
+
// Target the composite resource. Results that target the composite resource
|
|
286
|
+
// should include detailed, advanced information.
|
|
287
|
+
TARGET_COMPOSITE = 1;
|
|
288
|
+
|
|
289
|
+
// Target the composite and the claim. Results that target the composite and
|
|
290
|
+
// the claim should include only end-user friendly information.
|
|
291
|
+
TARGET_COMPOSITE_AND_CLAIM = 2;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Status condition to be applied to the composite resource. Condition may also
|
|
295
|
+
// optionally be applied to the composite resource's associated claim. For
|
|
296
|
+
// detailed information on proper usage of status conditions, please see
|
|
297
|
+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties.
|
|
298
|
+
message Condition {
|
|
299
|
+
// Type of condition in PascalCase.
|
|
300
|
+
string type = 1;
|
|
301
|
+
|
|
302
|
+
// Status of the condition.
|
|
303
|
+
Status status = 2;
|
|
304
|
+
|
|
305
|
+
// Reason contains a programmatic identifier indicating the reason for the
|
|
306
|
+
// condition's last transition. Producers of specific condition types may
|
|
307
|
+
// define expected values and meanings for this field, and whether the values
|
|
308
|
+
// are considered a guaranteed API. The value should be a PascalCase string.
|
|
309
|
+
// This field may not be empty.
|
|
310
|
+
string reason = 3;
|
|
311
|
+
|
|
312
|
+
// Message is a human readable message indicating details about the
|
|
313
|
+
// transition. This may be an empty string.
|
|
314
|
+
optional string message = 4;
|
|
315
|
+
|
|
316
|
+
// The resources this condition targets.
|
|
317
|
+
optional Target target = 5;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
enum Status {
|
|
321
|
+
STATUS_CONDITION_UNSPECIFIED = 0;
|
|
322
|
+
|
|
323
|
+
STATUS_CONDITION_UNKNOWN = 1;
|
|
324
|
+
|
|
325
|
+
STATUS_CONDITION_TRUE = 2;
|
|
326
|
+
|
|
327
|
+
STATUS_CONDITION_FALSE = 3;
|
|
328
|
+
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
3
4
|
# source: crossplane/function/proto/v1beta1/run_function.proto
|
|
4
|
-
# Protobuf Python Version:
|
|
5
|
+
# Protobuf Python Version: 5.27.2
|
|
5
6
|
"""Generated protocol buffer code."""
|
|
6
7
|
from google.protobuf import descriptor as _descriptor
|
|
7
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
8
10
|
from google.protobuf import symbol_database as _symbol_database
|
|
9
11
|
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
5,
|
|
15
|
+
27,
|
|
16
|
+
2,
|
|
17
|
+
'',
|
|
18
|
+
'crossplane/function/proto/v1beta1/run_function.proto'
|
|
19
|
+
)
|
|
10
20
|
# @@protoc_insertion_point(imports)
|
|
11
21
|
|
|
12
22
|
_sym_db = _symbol_database.Default()
|
|
@@ -16,31 +26,36 @@ from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
|
|
16
26
|
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
|
|
17
27
|
|
|
18
28
|
|
|
19
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n4crossplane/function/proto/v1beta1/run_function.proto\x12\x1e\x61piextensions.fn.proto.v1beta1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1egoogle/protobuf/duration.proto\"\xb0\x05\n\x12RunFunctionRequest\x12\x39\n\x04meta\x18\x01 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.RequestMeta\x12\x37\n\x08observed\x18\x02 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12\x36\n\x07\x64\x65sired\x18\x03 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12+\n\x05input\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x88\x01\x01\x12-\n\x07\x63ontext\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x01\x88\x01\x01\x12_\n\x0f\x65xtra_resources\x18\x06 \x03(\x0b\x32\x46.apiextensions.fn.proto.v1beta1.RunFunctionRequest.ExtraResourcesEntry\x12X\n\x0b\x63redentials\x18\x07 \x03(\x0b\x32\x43.apiextensions.fn.proto.v1beta1.RunFunctionRequest.CredentialsEntry\x1a`\n\x13\x45xtraResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x01(\x0b\x32).apiextensions.fn.proto.v1beta1.Resources:\x02\x38\x01\x1a_\n\x10\x43redentialsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.Credentials:\x02\x38\x01\x42\x08\n\x06_inputB\n\n\x08_context\"b\n\x0b\x43redentials\x12I\n\x0f\x63redential_data\x18\x01 \x01(\x0b\x32..apiextensions.fn.proto.v1beta1.CredentialDataH\x00\x42\x08\n\x06source\"\x85\x01\n\x0e\x43redentialData\x12\x46\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x38.apiextensions.fn.proto.v1beta1.CredentialData.DataEntry\x1a+\n\tDataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"D\n\tResources\x12\x37\n\x05items\x18\x01 \x03(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource\"\
|
|
29
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n4crossplane/function/proto/v1beta1/run_function.proto\x12\x1e\x61piextensions.fn.proto.v1beta1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1egoogle/protobuf/duration.proto\"\xb0\x05\n\x12RunFunctionRequest\x12\x39\n\x04meta\x18\x01 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.RequestMeta\x12\x37\n\x08observed\x18\x02 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12\x36\n\x07\x64\x65sired\x18\x03 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12+\n\x05input\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x88\x01\x01\x12-\n\x07\x63ontext\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x01\x88\x01\x01\x12_\n\x0f\x65xtra_resources\x18\x06 \x03(\x0b\x32\x46.apiextensions.fn.proto.v1beta1.RunFunctionRequest.ExtraResourcesEntry\x12X\n\x0b\x63redentials\x18\x07 \x03(\x0b\x32\x43.apiextensions.fn.proto.v1beta1.RunFunctionRequest.CredentialsEntry\x1a`\n\x13\x45xtraResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x01(\x0b\x32).apiextensions.fn.proto.v1beta1.Resources:\x02\x38\x01\x1a_\n\x10\x43redentialsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.Credentials:\x02\x38\x01\x42\x08\n\x06_inputB\n\n\x08_context\"b\n\x0b\x43redentials\x12I\n\x0f\x63redential_data\x18\x01 \x01(\x0b\x32..apiextensions.fn.proto.v1beta1.CredentialDataH\x00\x42\x08\n\x06source\"\x85\x01\n\x0e\x43redentialData\x12\x46\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x38.apiextensions.fn.proto.v1beta1.CredentialData.DataEntry\x1a+\n\tDataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"D\n\tResources\x12\x37\n\x05items\x18\x01 \x03(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource\"\x80\x03\n\x13RunFunctionResponse\x12:\n\x04meta\x18\x01 \x01(\x0b\x32,.apiextensions.fn.proto.v1beta1.ResponseMeta\x12\x36\n\x07\x64\x65sired\x18\x02 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12\x37\n\x07results\x18\x03 \x03(\x0b\x32&.apiextensions.fn.proto.v1beta1.Result\x12-\n\x07\x63ontext\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x88\x01\x01\x12\x42\n\x0crequirements\x18\x05 \x01(\x0b\x32,.apiextensions.fn.proto.v1beta1.Requirements\x12=\n\nconditions\x18\x06 \x03(\x0b\x32).apiextensions.fn.proto.v1beta1.ConditionB\n\n\x08_context\"\x1a\n\x0bRequestMeta\x12\x0b\n\x03tag\x18\x01 \x01(\t\"\xd2\x01\n\x0cRequirements\x12Y\n\x0f\x65xtra_resources\x18\x01 \x03(\x0b\x32@.apiextensions.fn.proto.v1beta1.Requirements.ExtraResourcesEntry\x1ag\n\x13\x45xtraResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12?\n\x05value\x18\x02 \x01(\x0b\x32\x30.apiextensions.fn.proto.v1beta1.ResourceSelector:\x02\x38\x01\"\x99\x01\n\x10ResourceSelector\x12\x13\n\x0b\x61pi_version\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x14\n\nmatch_name\x18\x03 \x01(\tH\x00\x12\x43\n\x0cmatch_labels\x18\x04 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.MatchLabelsH\x00\x42\x07\n\x05match\"\x85\x01\n\x0bMatchLabels\x12G\n\x06labels\x18\x01 \x03(\x0b\x32\x37.apiextensions.fn.proto.v1beta1.MatchLabels.LabelsEntry\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"P\n\x0cResponseMeta\x12\x0b\n\x03tag\x18\x01 \x01(\t\x12+\n\x03ttl\x18\x02 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x88\x01\x01\x42\x06\n\x04_ttl\"\xe9\x01\n\x05State\x12;\n\tcomposite\x18\x01 \x01(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource\x12G\n\tresources\x18\x02 \x03(\x0b\x32\x34.apiextensions.fn.proto.v1beta1.State.ResourcesEntry\x1aZ\n\x0eResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05value\x18\x02 \x01(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource:\x02\x38\x01\"\x82\x02\n\x08Resource\x12)\n\x08resource\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12[\n\x12\x63onnection_details\x18\x02 \x03(\x0b\x32?.apiextensions.fn.proto.v1beta1.Resource.ConnectionDetailsEntry\x12\x34\n\x05ready\x18\x03 \x01(\x0e\x32%.apiextensions.fn.proto.v1beta1.Ready\x1a\x38\n\x16\x43onnectionDetailsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"\xbd\x01\n\x06Result\x12:\n\x08severity\x18\x01 \x01(\x0e\x32(.apiextensions.fn.proto.v1beta1.Severity\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x13\n\x06reason\x18\x03 \x01(\tH\x00\x88\x01\x01\x12;\n\x06target\x18\x04 \x01(\x0e\x32&.apiextensions.fn.proto.v1beta1.TargetH\x01\x88\x01\x01\x42\t\n\x07_reasonB\t\n\x07_target\"\xcb\x01\n\tCondition\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x36\n\x06status\x18\x02 \x01(\x0e\x32&.apiextensions.fn.proto.v1beta1.Status\x12\x0e\n\x06reason\x18\x03 \x01(\t\x12\x14\n\x07message\x18\x04 \x01(\tH\x00\x88\x01\x01\x12;\n\x06target\x18\x05 \x01(\x0e\x32&.apiextensions.fn.proto.v1beta1.TargetH\x01\x88\x01\x01\x42\n\n\x08_messageB\t\n\x07_target*?\n\x05Ready\x12\x15\n\x11READY_UNSPECIFIED\x10\x00\x12\x0e\n\nREADY_TRUE\x10\x01\x12\x0f\n\x0bREADY_FALSE\x10\x02*c\n\x08Severity\x12\x18\n\x14SEVERITY_UNSPECIFIED\x10\x00\x12\x12\n\x0eSEVERITY_FATAL\x10\x01\x12\x14\n\x10SEVERITY_WARNING\x10\x02\x12\x13\n\x0fSEVERITY_NORMAL\x10\x03*V\n\x06Target\x12\x16\n\x12TARGET_UNSPECIFIED\x10\x00\x12\x14\n\x10TARGET_COMPOSITE\x10\x01\x12\x1e\n\x1aTARGET_COMPOSITE_AND_CLAIM\x10\x02*\x7f\n\x06Status\x12 \n\x1cSTATUS_CONDITION_UNSPECIFIED\x10\x00\x12\x1c\n\x18STATUS_CONDITION_UNKNOWN\x10\x01\x12\x19\n\x15STATUS_CONDITION_TRUE\x10\x02\x12\x1a\n\x16STATUS_CONDITION_FALSE\x10\x03\x32\x91\x01\n\x15\x46unctionRunnerService\x12x\n\x0bRunFunction\x12\x32.apiextensions.fn.proto.v1beta1.RunFunctionRequest\x1a\x33.apiextensions.fn.proto.v1beta1.RunFunctionResponse\"\x00\x42\x46ZDgithub.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1beta1b\x06proto3')
|
|
20
30
|
|
|
21
31
|
_globals = globals()
|
|
22
32
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
23
33
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'crossplane.function.proto.v1beta1.run_function_pb2', _globals)
|
|
24
|
-
if _descriptor._USE_C_DESCRIPTORS
|
|
25
|
-
DESCRIPTOR.
|
|
26
|
-
_globals['
|
|
34
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
35
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
|
36
|
+
_globals['DESCRIPTOR']._serialized_options = b'ZDgithub.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1beta1'
|
|
37
|
+
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._loaded_options = None
|
|
27
38
|
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._serialized_options = b'8\001'
|
|
28
|
-
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY'].
|
|
39
|
+
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._loaded_options = None
|
|
29
40
|
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._serialized_options = b'8\001'
|
|
30
|
-
_globals['_CREDENTIALDATA_DATAENTRY'].
|
|
41
|
+
_globals['_CREDENTIALDATA_DATAENTRY']._loaded_options = None
|
|
31
42
|
_globals['_CREDENTIALDATA_DATAENTRY']._serialized_options = b'8\001'
|
|
32
|
-
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY'].
|
|
43
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._loaded_options = None
|
|
33
44
|
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_options = b'8\001'
|
|
34
|
-
_globals['_MATCHLABELS_LABELSENTRY'].
|
|
45
|
+
_globals['_MATCHLABELS_LABELSENTRY']._loaded_options = None
|
|
35
46
|
_globals['_MATCHLABELS_LABELSENTRY']._serialized_options = b'8\001'
|
|
36
|
-
_globals['_STATE_RESOURCESENTRY'].
|
|
47
|
+
_globals['_STATE_RESOURCESENTRY']._loaded_options = None
|
|
37
48
|
_globals['_STATE_RESOURCESENTRY']._serialized_options = b'8\001'
|
|
38
|
-
_globals['_RESOURCE_CONNECTIONDETAILSENTRY'].
|
|
49
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._loaded_options = None
|
|
39
50
|
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_options = b'8\001'
|
|
40
|
-
_globals['_READY']._serialized_start=
|
|
41
|
-
_globals['_READY']._serialized_end=
|
|
42
|
-
_globals['_SEVERITY']._serialized_start=
|
|
43
|
-
_globals['_SEVERITY']._serialized_end=
|
|
51
|
+
_globals['_READY']._serialized_start=3044
|
|
52
|
+
_globals['_READY']._serialized_end=3107
|
|
53
|
+
_globals['_SEVERITY']._serialized_start=3109
|
|
54
|
+
_globals['_SEVERITY']._serialized_end=3208
|
|
55
|
+
_globals['_TARGET']._serialized_start=3210
|
|
56
|
+
_globals['_TARGET']._serialized_end=3296
|
|
57
|
+
_globals['_STATUS']._serialized_start=3298
|
|
58
|
+
_globals['_STATUS']._serialized_end=3425
|
|
44
59
|
_globals['_RUNFUNCTIONREQUEST']._serialized_start=151
|
|
45
60
|
_globals['_RUNFUNCTIONREQUEST']._serialized_end=839
|
|
46
61
|
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._serialized_start=624
|
|
@@ -56,31 +71,33 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|
|
56
71
|
_globals['_RESOURCES']._serialized_start=1077
|
|
57
72
|
_globals['_RESOURCES']._serialized_end=1145
|
|
58
73
|
_globals['_RUNFUNCTIONRESPONSE']._serialized_start=1148
|
|
59
|
-
_globals['_RUNFUNCTIONRESPONSE']._serialized_end=
|
|
60
|
-
_globals['_REQUESTMETA']._serialized_start=
|
|
61
|
-
_globals['_REQUESTMETA']._serialized_end=
|
|
62
|
-
_globals['_REQUIREMENTS']._serialized_start=
|
|
63
|
-
_globals['_REQUIREMENTS']._serialized_end=
|
|
64
|
-
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_start=
|
|
65
|
-
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_end=
|
|
66
|
-
_globals['_RESOURCESELECTOR']._serialized_start=
|
|
67
|
-
_globals['_RESOURCESELECTOR']._serialized_end=
|
|
68
|
-
_globals['_MATCHLABELS']._serialized_start=
|
|
69
|
-
_globals['_MATCHLABELS']._serialized_end=
|
|
70
|
-
_globals['_MATCHLABELS_LABELSENTRY']._serialized_start=
|
|
71
|
-
_globals['_MATCHLABELS_LABELSENTRY']._serialized_end=
|
|
72
|
-
_globals['_RESPONSEMETA']._serialized_start=
|
|
73
|
-
_globals['_RESPONSEMETA']._serialized_end=
|
|
74
|
-
_globals['_STATE']._serialized_start=
|
|
75
|
-
_globals['_STATE']._serialized_end=
|
|
76
|
-
_globals['_STATE_RESOURCESENTRY']._serialized_start=
|
|
77
|
-
_globals['_STATE_RESOURCESENTRY']._serialized_end=
|
|
78
|
-
_globals['_RESOURCE']._serialized_start=
|
|
79
|
-
_globals['_RESOURCE']._serialized_end=
|
|
80
|
-
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_start=
|
|
81
|
-
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_end=
|
|
82
|
-
_globals['_RESULT']._serialized_start=
|
|
83
|
-
_globals['_RESULT']._serialized_end=
|
|
84
|
-
_globals['
|
|
85
|
-
_globals['
|
|
74
|
+
_globals['_RUNFUNCTIONRESPONSE']._serialized_end=1532
|
|
75
|
+
_globals['_REQUESTMETA']._serialized_start=1534
|
|
76
|
+
_globals['_REQUESTMETA']._serialized_end=1560
|
|
77
|
+
_globals['_REQUIREMENTS']._serialized_start=1563
|
|
78
|
+
_globals['_REQUIREMENTS']._serialized_end=1773
|
|
79
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_start=1670
|
|
80
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_end=1773
|
|
81
|
+
_globals['_RESOURCESELECTOR']._serialized_start=1776
|
|
82
|
+
_globals['_RESOURCESELECTOR']._serialized_end=1929
|
|
83
|
+
_globals['_MATCHLABELS']._serialized_start=1932
|
|
84
|
+
_globals['_MATCHLABELS']._serialized_end=2065
|
|
85
|
+
_globals['_MATCHLABELS_LABELSENTRY']._serialized_start=2020
|
|
86
|
+
_globals['_MATCHLABELS_LABELSENTRY']._serialized_end=2065
|
|
87
|
+
_globals['_RESPONSEMETA']._serialized_start=2067
|
|
88
|
+
_globals['_RESPONSEMETA']._serialized_end=2147
|
|
89
|
+
_globals['_STATE']._serialized_start=2150
|
|
90
|
+
_globals['_STATE']._serialized_end=2383
|
|
91
|
+
_globals['_STATE_RESOURCESENTRY']._serialized_start=2293
|
|
92
|
+
_globals['_STATE_RESOURCESENTRY']._serialized_end=2383
|
|
93
|
+
_globals['_RESOURCE']._serialized_start=2386
|
|
94
|
+
_globals['_RESOURCE']._serialized_end=2644
|
|
95
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_start=2588
|
|
96
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_end=2644
|
|
97
|
+
_globals['_RESULT']._serialized_start=2647
|
|
98
|
+
_globals['_RESULT']._serialized_end=2836
|
|
99
|
+
_globals['_CONDITION']._serialized_start=2839
|
|
100
|
+
_globals['_CONDITION']._serialized_end=3042
|
|
101
|
+
_globals['_FUNCTIONRUNNERSERVICE']._serialized_start=3428
|
|
102
|
+
_globals['_FUNCTIONRUNNERSERVICE']._serialized_end=3573
|
|
86
103
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -20,6 +20,19 @@ class Severity(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
|
20
20
|
SEVERITY_FATAL: _ClassVar[Severity]
|
|
21
21
|
SEVERITY_WARNING: _ClassVar[Severity]
|
|
22
22
|
SEVERITY_NORMAL: _ClassVar[Severity]
|
|
23
|
+
|
|
24
|
+
class Target(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
25
|
+
__slots__ = ()
|
|
26
|
+
TARGET_UNSPECIFIED: _ClassVar[Target]
|
|
27
|
+
TARGET_COMPOSITE: _ClassVar[Target]
|
|
28
|
+
TARGET_COMPOSITE_AND_CLAIM: _ClassVar[Target]
|
|
29
|
+
|
|
30
|
+
class Status(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
31
|
+
__slots__ = ()
|
|
32
|
+
STATUS_CONDITION_UNSPECIFIED: _ClassVar[Status]
|
|
33
|
+
STATUS_CONDITION_UNKNOWN: _ClassVar[Status]
|
|
34
|
+
STATUS_CONDITION_TRUE: _ClassVar[Status]
|
|
35
|
+
STATUS_CONDITION_FALSE: _ClassVar[Status]
|
|
23
36
|
READY_UNSPECIFIED: Ready
|
|
24
37
|
READY_TRUE: Ready
|
|
25
38
|
READY_FALSE: Ready
|
|
@@ -27,6 +40,13 @@ SEVERITY_UNSPECIFIED: Severity
|
|
|
27
40
|
SEVERITY_FATAL: Severity
|
|
28
41
|
SEVERITY_WARNING: Severity
|
|
29
42
|
SEVERITY_NORMAL: Severity
|
|
43
|
+
TARGET_UNSPECIFIED: Target
|
|
44
|
+
TARGET_COMPOSITE: Target
|
|
45
|
+
TARGET_COMPOSITE_AND_CLAIM: Target
|
|
46
|
+
STATUS_CONDITION_UNSPECIFIED: Status
|
|
47
|
+
STATUS_CONDITION_UNKNOWN: Status
|
|
48
|
+
STATUS_CONDITION_TRUE: Status
|
|
49
|
+
STATUS_CONDITION_FALSE: Status
|
|
30
50
|
|
|
31
51
|
class RunFunctionRequest(_message.Message):
|
|
32
52
|
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials")
|
|
@@ -86,18 +106,20 @@ class Resources(_message.Message):
|
|
|
86
106
|
def __init__(self, items: _Optional[_Iterable[_Union[Resource, _Mapping]]] = ...) -> None: ...
|
|
87
107
|
|
|
88
108
|
class RunFunctionResponse(_message.Message):
|
|
89
|
-
__slots__ = ("meta", "desired", "results", "context", "requirements")
|
|
109
|
+
__slots__ = ("meta", "desired", "results", "context", "requirements", "conditions")
|
|
90
110
|
META_FIELD_NUMBER: _ClassVar[int]
|
|
91
111
|
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
|
92
112
|
RESULTS_FIELD_NUMBER: _ClassVar[int]
|
|
93
113
|
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
|
94
114
|
REQUIREMENTS_FIELD_NUMBER: _ClassVar[int]
|
|
115
|
+
CONDITIONS_FIELD_NUMBER: _ClassVar[int]
|
|
95
116
|
meta: ResponseMeta
|
|
96
117
|
desired: State
|
|
97
118
|
results: _containers.RepeatedCompositeFieldContainer[Result]
|
|
98
119
|
context: _struct_pb2.Struct
|
|
99
120
|
requirements: Requirements
|
|
100
|
-
|
|
121
|
+
conditions: _containers.RepeatedCompositeFieldContainer[Condition]
|
|
122
|
+
def __init__(self, meta: _Optional[_Union[ResponseMeta, _Mapping]] = ..., desired: _Optional[_Union[State, _Mapping]] = ..., results: _Optional[_Iterable[_Union[Result, _Mapping]]] = ..., context: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., requirements: _Optional[_Union[Requirements, _Mapping]] = ..., conditions: _Optional[_Iterable[_Union[Condition, _Mapping]]] = ...) -> None: ...
|
|
101
123
|
|
|
102
124
|
class RequestMeta(_message.Message):
|
|
103
125
|
__slots__ = ("tag",)
|
|
@@ -184,9 +206,27 @@ class Resource(_message.Message):
|
|
|
184
206
|
def __init__(self, resource: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., connection_details: _Optional[_Mapping[str, bytes]] = ..., ready: _Optional[_Union[Ready, str]] = ...) -> None: ...
|
|
185
207
|
|
|
186
208
|
class Result(_message.Message):
|
|
187
|
-
__slots__ = ("severity", "message")
|
|
209
|
+
__slots__ = ("severity", "message", "reason", "target")
|
|
188
210
|
SEVERITY_FIELD_NUMBER: _ClassVar[int]
|
|
189
211
|
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
212
|
+
REASON_FIELD_NUMBER: _ClassVar[int]
|
|
213
|
+
TARGET_FIELD_NUMBER: _ClassVar[int]
|
|
190
214
|
severity: Severity
|
|
191
215
|
message: str
|
|
192
|
-
|
|
216
|
+
reason: str
|
|
217
|
+
target: Target
|
|
218
|
+
def __init__(self, severity: _Optional[_Union[Severity, str]] = ..., message: _Optional[str] = ..., reason: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
|
219
|
+
|
|
220
|
+
class Condition(_message.Message):
|
|
221
|
+
__slots__ = ("type", "status", "reason", "message", "target")
|
|
222
|
+
TYPE_FIELD_NUMBER: _ClassVar[int]
|
|
223
|
+
STATUS_FIELD_NUMBER: _ClassVar[int]
|
|
224
|
+
REASON_FIELD_NUMBER: _ClassVar[int]
|
|
225
|
+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
226
|
+
TARGET_FIELD_NUMBER: _ClassVar[int]
|
|
227
|
+
type: str
|
|
228
|
+
status: Status
|
|
229
|
+
reason: str
|
|
230
|
+
message: str
|
|
231
|
+
target: Target
|
|
232
|
+
def __init__(self, type: _Optional[str] = ..., status: _Optional[_Union[Status, str]] = ..., reason: _Optional[str] = ..., message: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
2
|
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
3
|
import grpc
|
|
4
|
+
import warnings
|
|
4
5
|
|
|
5
6
|
from crossplane.function.proto.v1beta1 import run_function_pb2 as crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2
|
|
6
7
|
|
|
8
|
+
GRPC_GENERATED_VERSION = '1.66.0'
|
|
9
|
+
GRPC_VERSION = grpc.__version__
|
|
10
|
+
_version_not_supported = False
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from grpc._utilities import first_version_is_lower
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ f' but the generated code in crossplane/function/proto/v1beta1/run_function_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
7
27
|
|
|
8
28
|
class FunctionRunnerServiceStub(object):
|
|
9
29
|
"""A FunctionRunnerService is a Composition Function.
|
|
@@ -19,7 +39,7 @@ class FunctionRunnerServiceStub(object):
|
|
|
19
39
|
'/apiextensions.fn.proto.v1beta1.FunctionRunnerService/RunFunction',
|
|
20
40
|
request_serializer=crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
|
21
41
|
response_deserializer=crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
|
22
|
-
)
|
|
42
|
+
_registered_method=True)
|
|
23
43
|
|
|
24
44
|
|
|
25
45
|
class FunctionRunnerServiceServicer(object):
|
|
@@ -45,6 +65,7 @@ def add_FunctionRunnerServiceServicer_to_server(servicer, server):
|
|
|
45
65
|
generic_handler = grpc.method_handlers_generic_handler(
|
|
46
66
|
'apiextensions.fn.proto.v1beta1.FunctionRunnerService', rpc_method_handlers)
|
|
47
67
|
server.add_generic_rpc_handlers((generic_handler,))
|
|
68
|
+
server.add_registered_method_handlers('apiextensions.fn.proto.v1beta1.FunctionRunnerService', rpc_method_handlers)
|
|
48
69
|
|
|
49
70
|
|
|
50
71
|
# This class is part of an EXPERIMENTAL API.
|
|
@@ -63,8 +84,18 @@ class FunctionRunnerService(object):
|
|
|
63
84
|
wait_for_ready=None,
|
|
64
85
|
timeout=None,
|
|
65
86
|
metadata=None):
|
|
66
|
-
return grpc.experimental.unary_unary(
|
|
87
|
+
return grpc.experimental.unary_unary(
|
|
88
|
+
request,
|
|
89
|
+
target,
|
|
90
|
+
'/apiextensions.fn.proto.v1beta1.FunctionRunnerService/RunFunction',
|
|
67
91
|
crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
|
68
92
|
crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
|
69
|
-
options,
|
|
70
|
-
|
|
93
|
+
options,
|
|
94
|
+
channel_credentials,
|
|
95
|
+
insecure,
|
|
96
|
+
call_credentials,
|
|
97
|
+
compression,
|
|
98
|
+
wait_for_ready,
|
|
99
|
+
timeout,
|
|
100
|
+
metadata,
|
|
101
|
+
_registered_method=True)
|
crossplane/function/resource.py
CHANGED
|
@@ -42,7 +42,10 @@ def struct_to_dict(s: structpb.Struct) -> dict:
|
|
|
42
42
|
protobuf struct. This function makes it possible to convert resources to a
|
|
43
43
|
dictionary.
|
|
44
44
|
"""
|
|
45
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
k: (struct_to_dict(v) if isinstance(v, structpb.Struct) else v)
|
|
47
|
+
for k, v in s.items()
|
|
48
|
+
}
|
|
46
49
|
|
|
47
50
|
|
|
48
51
|
@dataclasses.dataclass
|
crossplane/function/response.py
CHANGED
|
@@ -18,16 +18,16 @@ import datetime
|
|
|
18
18
|
|
|
19
19
|
from google.protobuf import duration_pb2 as durationpb
|
|
20
20
|
|
|
21
|
-
import crossplane.function.proto.
|
|
21
|
+
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
|
22
22
|
|
|
23
23
|
"""The default TTL for which a RunFunctionResponse may be cached."""
|
|
24
24
|
DEFAULT_TTL = datetime.timedelta(minutes=1)
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def to(
|
|
28
|
-
req:
|
|
28
|
+
req: fnv1.RunFunctionRequest,
|
|
29
29
|
ttl: datetime.timedelta = DEFAULT_TTL,
|
|
30
|
-
) ->
|
|
30
|
+
) -> fnv1.RunFunctionResponse:
|
|
31
31
|
"""Create a response to the supplied request.
|
|
32
32
|
|
|
33
33
|
Args:
|
|
@@ -42,38 +42,38 @@ def to(
|
|
|
42
42
|
"""
|
|
43
43
|
dttl = durationpb.Duration()
|
|
44
44
|
dttl.FromTimedelta(ttl)
|
|
45
|
-
return
|
|
46
|
-
meta=
|
|
45
|
+
return fnv1.RunFunctionResponse(
|
|
46
|
+
meta=fnv1.ResponseMeta(tag=req.meta.tag, ttl=dttl),
|
|
47
47
|
desired=req.desired,
|
|
48
48
|
context=req.context,
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def normal(rsp:
|
|
52
|
+
def normal(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
|
53
53
|
"""Add a normal result to the response."""
|
|
54
54
|
rsp.results.append(
|
|
55
|
-
|
|
56
|
-
severity=
|
|
55
|
+
fnv1.Result(
|
|
56
|
+
severity=fnv1.SEVERITY_NORMAL,
|
|
57
57
|
message=message,
|
|
58
58
|
)
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
def warning(rsp:
|
|
62
|
+
def warning(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
|
63
63
|
"""Add a warning result to the response."""
|
|
64
64
|
rsp.results.append(
|
|
65
|
-
|
|
66
|
-
severity=
|
|
65
|
+
fnv1.Result(
|
|
66
|
+
severity=fnv1.SEVERITY_WARNING,
|
|
67
67
|
message=message,
|
|
68
68
|
)
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def fatal(rsp:
|
|
72
|
+
def fatal(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
|
73
73
|
"""Add a fatal result to the response."""
|
|
74
74
|
rsp.results.append(
|
|
75
|
-
|
|
76
|
-
severity=
|
|
75
|
+
fnv1.Result(
|
|
76
|
+
severity=fnv1.SEVERITY_FATAL,
|
|
77
77
|
message=message,
|
|
78
78
|
)
|
|
79
79
|
)
|