function-sdk-rust 0.3.0

A Rust SDK for writing Crossplane composition functions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
// This file is @generated by prost-build.
/// A RunFunctionRequest requests that the function be run.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RunFunctionRequest {
    /// Metadata pertaining to this request.
    #[prost(message, optional, tag = "1")]
    pub meta: ::core::option::Option<RequestMeta>,
    /// The observed state prior to invocation of a function pipeline. State passed
    /// to each function is fresh as of the time the pipeline was invoked, not as
    /// of the time each function was invoked.
    #[prost(message, optional, tag = "2")]
    pub observed: ::core::option::Option<State>,
    /// Desired state according to a function pipeline. The state passed to a
    /// particular function may have been accumulated by previous functions in the
    /// pipeline.
    ///
    /// Note that the desired state must be a partial object with only the fields
    /// that this function (and its predecessors in the pipeline) wants to have set
    /// in the object. Copying a non-partial observed state to desired is most
    /// likely not what you want to do. Leaving out fields that had been returned
    /// as desired before will result in them being deleted from the objects in the
    /// cluster.
    #[prost(message, optional, tag = "3")]
    pub desired: ::core::option::Option<State>,
    /// Optional input specific to this function invocation. A JSON representation
    /// of the 'input' block of the relevant entry in a function pipeline.
    #[prost(message, optional, tag = "4")]
    pub input: ::core::option::Option<::pbjson_types::Struct>,
    /// Optional context. Crossplane may pass arbitrary contextual information to a
    /// function. A function may also return context in its RunFunctionResponse,
    /// and that context will be passed to subsequent functions. Crossplane
    /// discards all context returned by the last function in the pipeline.
    #[prost(message, optional, tag = "5")]
    pub context: ::core::option::Option<::pbjson_types::Struct>,
    /// Optional resources that the function specified in its requirements. Note
    /// that resources is a map to Resources, plural. The map key corresponds to
    /// the key in a RunFunctionResponse's requirements.extra_resources field. If a
    /// function requested extra resources that did not exist, Crossplane sets
    /// the map key to an empty Resources message to indicate that it attempted to
    /// satisfy the request. This field is only populated when the function uses
    /// extra_resources in its requirements.
    ///
    /// Deprecated: Use required_resources instead.
    #[prost(map = "string, message", tag = "6")]
    pub extra_resources: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        Resources,
    >,
    /// Optional credentials that this function may use to communicate with an
    /// external system.
    #[prost(map = "string, message", tag = "7")]
    pub credentials: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        Credentials,
    >,
    /// Optional resources that the function specified in its requirements. Note
    /// that resources is a map to Resources, plural. The map key corresponds to
    /// the key in a RunFunctionResponse's requirements.resources field. If a
    /// function requested required resources that did not exist, Crossplane sets
    /// the map key to an empty Resources message to indicate that it attempted to
    /// satisfy the request. This field is only populated when the function uses
    /// resources in its requirements.
    #[prost(map = "string, message", tag = "8")]
    pub required_resources: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        Resources,
    >,
    /// Optional schemas that the function specified in its requirements. The map
    /// key corresponds to the key in a RunFunctionResponse's requirements.schemas
    /// field. If a function requested a schema that could not be found, Crossplane
    /// sets the map key to an empty Schema message to indicate that it attempted
    /// to satisfy the request.
    #[prost(map = "string, message", tag = "9")]
    pub required_schemas: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        Schema,
    >,
}
/// Credentials that a function may use to communicate with an external system.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Credentials {
    /// Source of the credentials.
    #[prost(oneof = "credentials::Source", tags = "1")]
    pub source: ::core::option::Option<credentials::Source>,
}
/// Nested message and enum types in `Credentials`.
pub mod credentials {
    /// Source of the credentials.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Source {
        /// Credential data loaded by Crossplane, for example from a Secret.
        #[prost(message, tag = "1")]
        CredentialData(super::CredentialData),
    }
}
/// CredentialData loaded by Crossplane, for example from a Secret.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CredentialData {
    #[prost(map = "string, bytes", tag = "1")]
    pub data: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
}
/// Resources represents the state of several Crossplane resources.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Resources {
    #[prost(message, repeated, tag = "1")]
    pub items: ::prost::alloc::vec::Vec<Resource>,
}
/// A RunFunctionResponse contains the result of a function run.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RunFunctionResponse {
    /// Metadata pertaining to this response.
    #[prost(message, optional, tag = "1")]
    pub meta: ::core::option::Option<ResponseMeta>,
    /// Desired state according to a function pipeline. functions may add desired
    /// state, and may mutate or delete any part of the desired state they are
    /// concerned with. A function must pass through any part of the desired state
    /// that it is not concerned with.
    ///
    /// Note that the desired state must be a partial object with only the fields
    /// that this function (and its predecessors in the pipeline) wants to have set
    /// in the object. Copying a non-partial observed state to desired is most
    /// likely not what you want to do. Leaving out fields that had been returned
    /// as desired before will result in them being deleted from the objects in the
    /// cluster.
    #[prost(message, optional, tag = "2")]
    pub desired: ::core::option::Option<State>,
    /// Results of the function run. Results are used for observability purposes.
    #[prost(message, repeated, tag = "3")]
    pub results: ::prost::alloc::vec::Vec<Result>,
    /// Optional context to be passed to the next function in the pipeline as part
    /// of the RunFunctionRequest. Dropped on the last function in the pipeline.
    #[prost(message, optional, tag = "4")]
    pub context: ::core::option::Option<::pbjson_types::Struct>,
    /// Requirements that must be satisfied for this function to run successfully.
    #[prost(message, optional, tag = "5")]
    pub requirements: ::core::option::Option<Requirements>,
    /// Status conditions to be applied to the XR. Conditions may also optionally
    /// be applied to the XR's associated claim.
    ///
    /// Conditions are only used for composition. They're ignored by Operations.
    #[prost(message, repeated, tag = "6")]
    pub conditions: ::prost::alloc::vec::Vec<Condition>,
    /// Optional output specific to this function invocation.
    ///
    /// Only Operations use function output. XRs will discard any function output.
    #[prost(message, optional, tag = "7")]
    pub output: ::core::option::Option<::pbjson_types::Struct>,
}
/// RequestMeta contains metadata pertaining to a RunFunctionRequest.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RequestMeta {
    /// An opaque string identifying a request. Requests with identical tags will
    /// be otherwise identical.
    #[prost(string, tag = "1")]
    pub tag: ::prost::alloc::string::String,
    /// Capabilities supported by this version of Crossplane. Functions may use
    /// this to determine whether Crossplane will honor certain fields in their
    /// response, or populate certain fields in their request.
    #[prost(enumeration = "Capability", repeated, tag = "2")]
    pub capabilities: ::prost::alloc::vec::Vec<i32>,
}
/// Requirements that must be satisfied for a function to run successfully.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Requirements {
    /// Resources that this function requires. The map key uniquely identifies the
    /// group of resources.
    ///
    /// Deprecated: Use resources instead.
    #[prost(map = "string, message", tag = "1")]
    pub extra_resources: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ResourceSelector,
    >,
    /// Resources that this function requires. The map key uniquely identifies the
    /// group of resources.
    #[prost(map = "string, message", tag = "2")]
    pub resources: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ResourceSelector,
    >,
    /// Schemas that this function requires. The map key uniquely identifies the
    /// schema request.
    #[prost(map = "string, message", tag = "3")]
    pub schemas: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        SchemaSelector,
    >,
}
/// SchemaSelector identifies a resource kind whose OpenAPI schema is requested.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SchemaSelector {
    /// API version of the resource kind, e.g. "example.org/v1".
    #[prost(string, tag = "1")]
    pub api_version: ::prost::alloc::string::String,
    /// Kind of resource, e.g. "MyResource".
    #[prost(string, tag = "2")]
    pub kind: ::prost::alloc::string::String,
}
/// Schema represents the OpenAPI schema for a resource kind.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schema {
    /// The OpenAPI v3 schema of the resource kind as unstructured JSON.
    /// For CRDs this is the spec.versions\[\].schema.openAPIV3Schema field.
    /// Empty if Crossplane could not find a schema for the requested kind.
    #[prost(message, optional, tag = "1")]
    pub openapi_v3: ::core::option::Option<::pbjson_types::Struct>,
}
/// ResourceSelector selects a group of resources, either by name or by label.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceSelector {
    /// API version of resources to select.
    #[prost(string, tag = "1")]
    pub api_version: ::prost::alloc::string::String,
    /// Kind of resources to select.
    #[prost(string, tag = "2")]
    pub kind: ::prost::alloc::string::String,
    /// Match resources in this namespace. Omit namespace to match cluster scoped
    /// resources, or to match namespaced resources by labels across all
    /// namespaces.
    #[prost(string, optional, tag = "5")]
    pub namespace: ::core::option::Option<::prost::alloc::string::String>,
    /// Resources to match.
    #[prost(oneof = "resource_selector::Match", tags = "3, 4")]
    pub r#match: ::core::option::Option<resource_selector::Match>,
}
/// Nested message and enum types in `ResourceSelector`.
pub mod resource_selector {
    /// Resources to match.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Match {
        /// Match the resource with this name.
        #[prost(string, tag = "3")]
        MatchName(::prost::alloc::string::String),
        /// Match all resources with these labels.
        #[prost(message, tag = "4")]
        MatchLabels(super::MatchLabels),
    }
}
/// MatchLabels defines a set of labels to match resources against.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MatchLabels {
    #[prost(map = "string, string", tag = "1")]
    pub labels: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::string::String,
    >,
}
/// ResponseMeta contains metadata pertaining to a RunFunctionResponse.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ResponseMeta {
    /// An opaque string identifying the content of the request. Must match the
    /// meta.tag of the corresponding RunFunctionRequest.
    #[prost(string, tag = "1")]
    pub tag: ::prost::alloc::string::String,
    /// Time-to-live of this response. Crossplane will call the function again when
    /// the TTL expires. Crossplane may cache the response to avoid calling the
    /// function again until the TTL expires.
    #[prost(message, optional, tag = "2")]
    pub ttl: ::core::option::Option<::pbjson_types::Duration>,
}
/// State of the XR (XR) and any resources.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct State {
    /// The state of the XR (XR).
    #[prost(message, optional, tag = "1")]
    pub composite: ::core::option::Option<Resource>,
    /// The state of any other resources. In composition functions these are the
    /// composed resources. In operation functions they're arbitrary resources that
    /// the operation wants to create or update.
    #[prost(map = "string, message", tag = "2")]
    pub resources: ::std::collections::HashMap<::prost::alloc::string::String, Resource>,
}
/// A Resource represents the state of a Kubernetes resource.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Resource {
    /// The JSON representation of the resource.
    ///
    /// * Crossplane will set this field in a RunFunctionRequest to the entire
    ///   observed state of a resource - including its metadata, spec, and status.
    ///
    /// * A function should set this field in a RunFunctionRequest to communicate
    ///   the desired state of the resource.
    ///
    /// * A function may only specify the desired status of a XR - not its metadata
    ///   or spec. A function should not return desired metadata or spec for a XR.
    ///   This will be ignored.
    ///
    /// * A function may not specify the desired status of any other resource -
    ///   e.g. composed resources. It may only specify their metadata and spec.
    ///   Status will be ignored.
    #[prost(message, optional, tag = "1")]
    pub resource: ::core::option::Option<::pbjson_types::Struct>,
    /// The resource's connection details.
    ///
    /// * Crossplane will set this field in a RunFunctionRequest to communicate the
    ///   the observed connection details of a composite or composed resource.
    ///
    /// * A function should set this field in a RunFunctionResponse to indicate the
    ///   desired connection details of legacy XRs. For modern XRs, this will be ignored.
    ///
    /// * A function should not set this field in a RunFunctionResponse to indicate
    ///   the desired connection details of a composed resource. This will be
    ///   ignored.
    ///
    /// Connection details are only used for composition. They're ignored by
    /// Operations.
    #[prost(map = "string, bytes", tag = "2")]
    pub connection_details: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
    /// Ready indicates whether the resource should be considered ready.
    ///
    /// * Crossplane will never set this field in a RunFunctionRequest.
    ///
    /// * A function should set this field to READY_TRUE in a RunFunctionResponse
    ///   to indicate that a desired resource is ready.
    ///
    /// * A function should set this field to READY_TRUE in a RunFunctionResponse
    ///   to indicate that a desired XR is ready. This overwrites the standard
    ///   readiness detection that determines the ready state of the composite by the
    ///   ready state of the composed resources.
    ///
    /// Ready is only used for composition. It's ignored by Operations.
    #[prost(enumeration = "Ready", tag = "3")]
    pub ready: i32,
}
/// A Result of running a function.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Result {
    /// Severity of this result.
    #[prost(enumeration = "Severity", tag = "1")]
    pub severity: i32,
    /// Human-readable details about the result.
    #[prost(string, tag = "2")]
    pub message: ::prost::alloc::string::String,
    /// Optional PascalCase, machine-readable reason for this result. If omitted,
    /// the value will be ComposeResources.
    #[prost(string, optional, tag = "3")]
    pub reason: ::core::option::Option<::prost::alloc::string::String>,
    /// The resources this result targets.
    #[prost(enumeration = "Target", optional, tag = "4")]
    pub target: ::core::option::Option<i32>,
}
/// Status condition to be applied to the XR. Condition may also optionally be
/// applied to the XR's associated claim. For detailed information on proper
/// usage of status conditions, please see
/// <https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties.>
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Condition {
    /// Type of condition in PascalCase.
    #[prost(string, tag = "1")]
    pub r#type: ::prost::alloc::string::String,
    /// Status of the condition.
    #[prost(enumeration = "Status", tag = "2")]
    pub status: i32,
    /// Reason contains a programmatic identifier indicating the reason for the
    /// condition's last transition. Producers of specific condition types may
    /// define expected values and meanings for this field, and whether the values
    /// are considered a guaranteed API. The value should be a PascalCase string.
    /// This field may not be empty.
    #[prost(string, tag = "3")]
    pub reason: ::prost::alloc::string::String,
    /// Message is a human readable message indicating details about the
    /// transition. This may be an empty string.
    #[prost(string, optional, tag = "4")]
    pub message: ::core::option::Option<::prost::alloc::string::String>,
    /// The resources this condition targets.
    #[prost(enumeration = "Target", optional, tag = "5")]
    pub target: ::core::option::Option<i32>,
}
/// Capability indicates that Crossplane supports a particular feature.
/// Functions can check for capabilities to determine whether Crossplane will
/// honor a particular request or response field.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Capability {
    Unspecified = 0,
    /// Crossplane sends capabilities in RequestMeta. If this capability is
    /// present, the function knows that if another capability is absent, it's
    /// because Crossplane doesn't support it (not because Crossplane predates
    /// capability advertisement). Added in Crossplane v2.2.
    Capabilities = 1,
    /// Crossplane supports the requirements.resources field. Functions can return
    /// resource requirements and Crossplane will fetch the requested resources and
    /// return them in required_resources. Added in Crossplane v1.15.
    RequiredResources = 2,
    /// Crossplane supports the credentials field. Functions can receive
    /// credentials from secrets specified in the Composition. Added in Crossplane
    /// v1.16.
    Credentials = 3,
    /// Crossplane supports the conditions field. Functions can return status
    /// conditions to be applied to the XR and optionally its claim. Added in
    /// Crossplane v1.17.
    Conditions = 4,
    /// Crossplane supports the requirements.schemas field. Functions can request
    /// OpenAPI schemas and Crossplane will return them in required_schemas. Added
    /// in Crossplane v2.2.
    RequiredSchemas = 5,
}
impl Capability {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "CAPABILITY_UNSPECIFIED",
            Self::Capabilities => "CAPABILITY_CAPABILITIES",
            Self::RequiredResources => "CAPABILITY_REQUIRED_RESOURCES",
            Self::Credentials => "CAPABILITY_CREDENTIALS",
            Self::Conditions => "CAPABILITY_CONDITIONS",
            Self::RequiredSchemas => "CAPABILITY_REQUIRED_SCHEMAS",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "CAPABILITY_UNSPECIFIED" => Some(Self::Unspecified),
            "CAPABILITY_CAPABILITIES" => Some(Self::Capabilities),
            "CAPABILITY_REQUIRED_RESOURCES" => Some(Self::RequiredResources),
            "CAPABILITY_CREDENTIALS" => Some(Self::Credentials),
            "CAPABILITY_CONDITIONS" => Some(Self::Conditions),
            "CAPABILITY_REQUIRED_SCHEMAS" => Some(Self::RequiredSchemas),
            _ => None,
        }
    }
}
/// Ready indicates whether a resource should be considered ready.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Ready {
    Unspecified = 0,
    /// True means the resource has been observed to be ready.
    True = 1,
    /// False means the resource has not been observed to be ready.
    False = 2,
}
impl Ready {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "READY_UNSPECIFIED",
            Self::True => "READY_TRUE",
            Self::False => "READY_FALSE",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "READY_UNSPECIFIED" => Some(Self::Unspecified),
            "READY_TRUE" => Some(Self::True),
            "READY_FALSE" => Some(Self::False),
            _ => None,
        }
    }
}
/// Severity of function results.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Severity {
    Unspecified = 0,
    /// Fatal results are fatal; subsequent functions may run, but the function
    /// pipeline run will be considered a failure and the first fatal result will
    /// be returned as an error.
    Fatal = 1,
    /// Warning results are non-fatal; the entire pipeline will run to completion
    /// but warning events and debug logs associated with the XR or Operation will
    /// be emitted.
    Warning = 2,
    /// Normal results are emitted as normal events and debug logs associated with
    /// the XR or operation.
    Normal = 3,
}
impl Severity {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SEVERITY_UNSPECIFIED",
            Self::Fatal => "SEVERITY_FATAL",
            Self::Warning => "SEVERITY_WARNING",
            Self::Normal => "SEVERITY_NORMAL",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SEVERITY_UNSPECIFIED" => Some(Self::Unspecified),
            "SEVERITY_FATAL" => Some(Self::Fatal),
            "SEVERITY_WARNING" => Some(Self::Warning),
            "SEVERITY_NORMAL" => Some(Self::Normal),
            _ => None,
        }
    }
}
/// Target of function results and conditions.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Target {
    /// If the target is unspecified, the result targets the XR.
    Unspecified = 0,
    /// Target the XR. Results that target the XR should include detailed, advanced
    /// information.
    Composite = 1,
    /// Target the XR and the claim. Results that target the XR and the claim
    /// should include only end-user friendly information.
    CompositeAndClaim = 2,
}
impl Target {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "TARGET_UNSPECIFIED",
            Self::Composite => "TARGET_COMPOSITE",
            Self::CompositeAndClaim => "TARGET_COMPOSITE_AND_CLAIM",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "TARGET_UNSPECIFIED" => Some(Self::Unspecified),
            "TARGET_COMPOSITE" => Some(Self::Composite),
            "TARGET_COMPOSITE_AND_CLAIM" => Some(Self::CompositeAndClaim),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Status {
    ConditionUnspecified = 0,
    ConditionUnknown = 1,
    ConditionTrue = 2,
    ConditionFalse = 3,
}
impl Status {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::ConditionUnspecified => "STATUS_CONDITION_UNSPECIFIED",
            Self::ConditionUnknown => "STATUS_CONDITION_UNKNOWN",
            Self::ConditionTrue => "STATUS_CONDITION_TRUE",
            Self::ConditionFalse => "STATUS_CONDITION_FALSE",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "STATUS_CONDITION_UNSPECIFIED" => Some(Self::ConditionUnspecified),
            "STATUS_CONDITION_UNKNOWN" => Some(Self::ConditionUnknown),
            "STATUS_CONDITION_TRUE" => Some(Self::ConditionTrue),
            "STATUS_CONDITION_FALSE" => Some(Self::ConditionFalse),
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod function_runner_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// A FunctionRunnerService is a function.
    #[derive(Debug, Clone)]
    pub struct FunctionRunnerServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl FunctionRunnerServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> FunctionRunnerServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> FunctionRunnerServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            FunctionRunnerServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// RunFunction runs the function.
        pub async fn run_function(
            &mut self,
            request: impl tonic::IntoRequest<super::RunFunctionRequest>,
        ) -> std::result::Result<
            tonic::Response<super::RunFunctionResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "apiextensions.fn.proto.v1.FunctionRunnerService",
                        "RunFunction",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod function_runner_service_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with FunctionRunnerServiceServer.
    #[async_trait]
    pub trait FunctionRunnerService: std::marker::Send + std::marker::Sync + 'static {
        /// RunFunction runs the function.
        async fn run_function(
            &self,
            request: tonic::Request<super::RunFunctionRequest>,
        ) -> std::result::Result<
            tonic::Response<super::RunFunctionResponse>,
            tonic::Status,
        >;
    }
    /// A FunctionRunnerService is a function.
    #[derive(Debug)]
    pub struct FunctionRunnerServiceServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> FunctionRunnerServiceServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>>
    for FunctionRunnerServiceServer<T>
    where
        T: FunctionRunnerService,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction" => {
                    #[allow(non_camel_case_types)]
                    struct RunFunctionSvc<T: FunctionRunnerService>(pub Arc<T>);
                    impl<
                        T: FunctionRunnerService,
                    > tonic::server::UnaryService<super::RunFunctionRequest>
                    for RunFunctionSvc<T> {
                        type Response = super::RunFunctionResponse;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<super::RunFunctionRequest>,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as FunctionRunnerService>::run_function(&inner, request)
                                    .await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = RunFunctionSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for FunctionRunnerServiceServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "apiextensions.fn.proto.v1.FunctionRunnerService";
    impl<T> tonic::server::NamedService for FunctionRunnerServiceServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}