wick_config/
v1.rs

1#![deny(
2  warnings,
3  missing_debug_implementations,
4  trivial_casts,
5  trivial_numeric_casts,
6  unsafe_code,
7  unstable_features,
8  unused_import_braces,
9  unused_qualifications,
10  unreachable_pub,
11  type_alias_bounds,
12  trivial_bounds,
13  mutable_transmutes,
14  invalid_value,
15  explicit_outlives_requirements,
16  deprecated,
17  clashing_extern_declarations,
18  clippy::expect_used,
19  clippy::explicit_deref_methods
20)]
21#![warn(clippy::cognitive_complexity)]
22#![allow(
23  missing_docs,
24  clippy::large_enum_variant,
25  missing_copy_implementations,
26  clippy::missing_const_for_fn,
27  clippy::enum_variant_names,
28  clippy::exhaustive_enums,
29  clippy::exhaustive_structs
30)]
31
32#[cfg(feature = "config")]
33pub(crate) mod conversions;
34pub mod helpers;
35pub(crate) mod parse;
36
37use std::collections::HashMap;
38
39use num_traits::FromPrimitive;
40use serde::{Deserialize, Serialize};
41use serde_json::Value;
42
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
44#[serde(deny_unknown_fields)]
45#[serde(tag = "kind")]
46/// Root configuration that can be any one of the possible Wick configuration formats.
47pub enum WickConfig {
48  /// A variant representing a [AppConfiguration] type.
49  #[serde(rename = "wick/app@v1")]
50  AppConfiguration(AppConfiguration),
51  /// A variant representing a [ComponentConfiguration] type.
52  #[serde(rename = "wick/component@v1")]
53  ComponentConfiguration(ComponentConfiguration),
54  /// A variant representing a [TypesConfiguration] type.
55  #[serde(rename = "wick/types@v1")]
56  TypesConfiguration(TypesConfiguration),
57  /// A variant representing a [TestConfiguration] type.
58  #[serde(rename = "wick/tests@v1")]
59  TestConfiguration(TestConfiguration),
60  /// A variant representing a [LockdownConfiguration] type.
61  #[serde(rename = "wick/lockdown@v1")]
62  LockdownConfiguration(LockdownConfiguration),
63}
64
65/// An identifier/variable name bound to an import, resource, or type.
66#[allow(unused)]
67pub type BoundIdentifier = String;
68
69/// A liquid template. Liquid-JSON is a way of using Liquid templates in structured JSON-like data. See liquid's [homepage](https://shopify.github.io/liquid/) for more information.
70#[allow(unused)]
71pub type LiquidTemplate = String;
72
73#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
74#[serde(deny_unknown_fields)]
75/// Configuration for a standalone Wick application.
76pub struct AppConfiguration {
77  /// The application's name.
78  pub name: String,
79  /// Associated metadata for this application.
80
81  #[serde(default)]
82  #[serde(skip_serializing_if = "Option::is_none")]
83  pub metadata: Option<Metadata>,
84  /// Details about the package for this application.
85
86  #[serde(default)]
87  #[serde(skip_serializing_if = "Option::is_none")]
88  pub package: Option<PackageDefinition>,
89  /// Resources and configuration that the application and its components can access.
90
91  #[serde(default)]
92  #[serde(skip_serializing_if = "Vec::is_empty")]
93  pub resources: Vec<ResourceBinding>,
94  /// Components that to import and make available to the application.
95
96  #[serde(default)]
97  #[serde(skip_serializing_if = "Vec::is_empty")]
98  pub import: Vec<ImportBinding>,
99  /// Triggers to load and instantiate to drive the application&#x27;s behavior.
100
101  #[serde(default)]
102  #[serde(skip_serializing_if = "Vec::is_empty")]
103  pub triggers: Vec<TriggerDefinition>,
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
107#[serde(deny_unknown_fields)]
108/// Metadata to associate with an artifact.
109pub struct Metadata {
110  /// The version of the artifact.
111
112  #[serde(default)]
113  pub version: String,
114  /// A list of the authors.
115
116  #[serde(default)]
117  #[serde(skip_serializing_if = "Vec::is_empty")]
118  pub authors: Vec<String>,
119  /// A list of any vendors associated with the artifact.
120
121  #[serde(default)]
122  #[serde(skip_serializing_if = "Vec::is_empty")]
123  pub vendors: Vec<String>,
124  /// A short description.
125
126  #[serde(default)]
127  #[serde(skip_serializing_if = "Option::is_none")]
128  pub description: Option<String>,
129  /// Where to find documentation.
130
131  #[serde(default)]
132  #[serde(skip_serializing_if = "Option::is_none")]
133  pub documentation: Option<String>,
134  /// The license(s) for the artifact.
135
136  #[serde(default)]
137  #[serde(skip_serializing_if = "Vec::is_empty")]
138  pub licenses: Vec<String>,
139  /// An icon to associate with the artifact.
140
141  #[serde(default)]
142  #[serde(skip_serializing_if = "Option::is_none")]
143  pub icon: Option<crate::v1::helpers::LocationReference>,
144}
145
146#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
147#[serde(deny_unknown_fields)]
148/// Configuration for packaging and publishing Wick configurations.
149pub struct PackageDefinition {
150  /// The list of files and folders to be included with the package.
151
152  #[serde(default)]
153  #[serde(skip_serializing_if = "Vec::is_empty")]
154  pub files: Vec<crate::v1::helpers::Glob>,
155  /// Configuration for publishing the package to a registry.
156
157  #[serde(default)]
158  #[serde(skip_serializing_if = "Option::is_none")]
159  pub registry: Option<RegistryDefinition>,
160}
161
162#[allow(non_snake_case)]
163pub(crate) fn REGISTRY_DEFINITION_HOST() -> String {
164  "registry.candle.dev".to_owned()
165}
166
167#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
168#[serde(deny_unknown_fields)]
169pub struct RegistryDefinition {
170  /// The registry to publish to, e.g. registry.candle.dev
171
172  #[serde(default = "REGISTRY_DEFINITION_HOST")]
173  #[serde(alias = "registry")]
174  pub host: String,
175  /// The namespace on the registry. e.g.: [*your username*]
176
177  #[serde(default)]
178  pub namespace: String,
179}
180
181#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
182#[serde(deny_unknown_fields)]
183/// An identifier bound to a resource.
184pub struct ResourceBinding {
185  /// The name of the binding.
186  pub name: String,
187  /// The resource to bind to.
188  pub resource: ResourceDefinition,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
192#[serde(deny_unknown_fields)]
193/// An identifier bound to an imported component or type manifest.
194pub struct ImportBinding {
195  /// The name of the binding.
196  pub name: String,
197  /// The import to bind to.
198  pub component: ImportDefinition,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
202#[serde(deny_unknown_fields)]
203#[serde(tag = "kind")]
204/// The possible types of resources. Resources are system-level resources and sensitive configuration.
205pub enum ResourceDefinition {
206  /// A variant representing a [TcpPort] type.
207  #[serde(rename = "wick/resource/tcpport@v1")]
208  TcpPort(TcpPort),
209  /// A variant representing a [UdpPort] type.
210  #[serde(rename = "wick/resource/udpport@v1")]
211  UdpPort(UdpPort),
212  /// A variant representing a [Url] type.
213  #[serde(rename = "wick/resource/url@v1")]
214  Url(Url),
215  /// A variant representing a [Volume] type.
216  #[serde(rename = "wick/resource/volume@v1")]
217  Volume(Volume),
218}
219
220#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
221#[serde(deny_unknown_fields)]
222/// A TCP port to bind to.
223pub struct TcpPort {
224  /// The port to bind to.
225  pub port: LiquidTemplate,
226  /// The address to bind to.
227  pub address: LiquidTemplate,
228}
229
230#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
231#[serde(deny_unknown_fields)]
232/// A UDP port to bind to.
233pub struct UdpPort {
234  /// The port to bind to.
235  pub port: LiquidTemplate,
236  /// The address to bind to.
237  pub address: LiquidTemplate,
238}
239
240#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
241#[serde(deny_unknown_fields)]
242/// A filesystem or network volume resource.
243pub struct Volume {
244  /// The path.
245  pub path: LiquidTemplate,
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
249#[serde(deny_unknown_fields)]
250/// A URL configured as a resource.
251pub struct Url {
252  /// The url string.
253  pub url: LiquidTemplate,
254}
255
256#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
257#[serde(deny_unknown_fields)]
258#[serde(tag = "kind")]
259/// Triggers that operate off events and translate environment data to components. Triggers are the way that Wick handles standard use cases and translates them into the component world.
260pub enum TriggerDefinition {
261  /// A variant representing a [CliTrigger] type.
262  #[serde(rename = "wick/trigger/cli@v1")]
263  CliTrigger(CliTrigger),
264  /// A variant representing a [HttpTrigger] type.
265  #[serde(rename = "wick/trigger/http@v1")]
266  HttpTrigger(HttpTrigger),
267  /// A variant representing a [TimeTrigger] type.
268  #[serde(rename = "wick/trigger/time@v1")]
269  TimeTrigger(TimeTrigger),
270  /// A variant representing a [WasmCommandTrigger] type.
271  #[serde(rename = "wick/trigger/wasm-command@v1")]
272  WasmCommandTrigger(WasmCommandTrigger),
273}
274
275#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
276#[serde(deny_unknown_fields)]
277/// A trigger that runs when an application is called via the command line.
278pub struct WasmCommandTrigger {
279  /// The component to execute
280  pub reference: crate::v1::helpers::LocationReference,
281  /// Volumes to expose to the component.
282
283  #[serde(default)]
284  #[serde(skip_serializing_if = "Vec::is_empty")]
285  pub volumes: Vec<ExposedVolume>,
286}
287
288#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
289#[serde(deny_unknown_fields)]
290/// A trigger that runs when an application is called via the command line.
291pub struct CliTrigger {
292  /// The operation that will act as the main entrypoint for this trigger.
293
294  #[serde(serialize_with = "crate::v1::helpers::serialize_component_expression")]
295  #[serde(deserialize_with = "crate::v1::parse::component_operation_syntax")]
296  pub operation: ComponentOperationExpression,
297}
298
299#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
300#[serde(deny_unknown_fields)]
301/// A trigger that runs on a schedule similar to cron.
302pub struct TimeTrigger {
303  /// The schedule to run the trigger with.
304  pub schedule: Schedule,
305  /// The operation to execute on the schedule.
306
307  #[serde(serialize_with = "crate::v1::helpers::serialize_component_expression")]
308  #[serde(deserialize_with = "crate::v1::parse::component_operation_syntax")]
309  pub operation: ComponentOperationExpression,
310  /// Values passed to the operation as inputs
311
312  #[serde(skip_serializing_if = "Vec::is_empty")]
313  pub payload: Vec<OperationInput>,
314}
315
316#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
317#[serde(deny_unknown_fields)]
318/// Input to use when calling an operation
319pub struct OperationInput {
320  /// The name of the input.
321  pub name: String,
322  /// The value to pass.
323  pub value: Value,
324}
325
326#[allow(non_snake_case)]
327pub(crate) fn SCHEDULE_REPEAT() -> u16 {
328  0
329}
330
331#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
332#[serde(deny_unknown_fields)]
333/// The schedule to run the Time trigger with.
334pub struct Schedule {
335  /// Schedule in cron format with second precision. See [cron.help](https://cron.help) for more information.
336  pub cron: String,
337  /// repeat &#x60;n&#x60; times. Use &#x60;0&#x60; to repeat indefinitely
338
339  #[serde(default = "SCHEDULE_REPEAT")]
340  pub repeat: u16,
341}
342
343#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
344#[serde(deny_unknown_fields)]
345/// A reference to an operation. This type can be shortened to <code>component_id::operation_name</code> with the short-form syntax.
346pub struct ComponentOperationExpression {
347  /// The component that exports the operation.
348
349  #[serde(deserialize_with = "crate::v1::parse::component_shortform")]
350  pub component: ComponentDefinition,
351  /// The operation name.
352  pub name: String,
353  /// Configuration to pass to this operation on invocation.
354
355  #[serde(default)]
356  #[serde(skip_serializing_if = "Option::is_none")]
357  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
358  /// Timeout (in milliseconds) to wait for the operation to complete. Use 0 to wait indefinitely.
359
360  #[serde(default)]
361  #[serde(skip_serializing_if = "Option::is_none")]
362  pub timeout: Option<u64>,
363}
364
365#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
366#[serde(deny_unknown_fields)]
367/// An HTTP server that delegates to HTTP routers on every request.
368pub struct HttpTrigger {
369  /// The TcpPort resource to listen on for connections.
370  pub resource: BoundIdentifier,
371  /// The router to handle incoming requests
372
373  #[serde(default)]
374  #[serde(skip_serializing_if = "Vec::is_empty")]
375  pub routers: Vec<HttpRouter>,
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
379#[serde(deny_unknown_fields)]
380#[serde(tag = "kind")]
381/// The types of routers that can be configured on the HttpTrigger.
382pub enum HttpRouter {
383  /// A variant representing a [RawRouter] type.
384  #[serde(rename = "wick/router/raw@v1")]
385  RawRouter(RawRouter),
386  /// A variant representing a [RestRouter] type.
387  #[serde(rename = "wick/router/rest@v1")]
388  RestRouter(RestRouter),
389  /// A variant representing a [StaticRouter] type.
390  #[serde(rename = "wick/router/static@v1")]
391  StaticRouter(StaticRouter),
392  /// A variant representing a [ProxyRouter] type.
393  #[serde(rename = "wick/router/proxy@v1")]
394  ProxyRouter(ProxyRouter),
395}
396
397#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
398#[serde(deny_unknown_fields)]
399/// A router that proxies to the configured URL when the path matches.
400pub struct ProxyRouter {
401  /// The path that this router will trigger for.
402  pub path: String,
403  /// Middleware operations for this router.
404
405  #[serde(default)]
406  #[serde(skip_serializing_if = "Option::is_none")]
407  pub middleware: Option<Middleware>,
408  /// The URL resource to proxy to.
409  pub url: BoundIdentifier,
410  /// Whether or not to strip the router&#x27;s path from the proxied request.
411
412  #[serde(default)]
413  pub strip_path: bool,
414}
415
416#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
417#[serde(deny_unknown_fields)]
418/// A router that can be configured to delegate to specific operations on a per-route, per-method basis.
419pub struct RestRouter {
420  /// The path that this router will trigger for.
421  pub path: String,
422  /// Additional tools and services to enable.
423
424  #[serde(default)]
425  #[serde(skip_serializing_if = "Option::is_none")]
426  pub tools: Option<Tools>,
427  /// Middleware operations for this router.
428
429  #[serde(default)]
430  #[serde(skip_serializing_if = "Option::is_none")]
431  pub middleware: Option<Middleware>,
432  /// The routes to serve and operations that handle them.
433
434  #[serde(default)]
435  #[serde(skip_serializing_if = "Vec::is_empty")]
436  pub routes: Vec<Route>,
437  /// Information about the router to use when generating documentation and other tools.
438
439  #[serde(default)]
440  #[serde(skip_serializing_if = "Option::is_none")]
441  pub info: Option<Info>,
442}
443
444#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
445#[serde(deny_unknown_fields)]
446/// A route to serve and the operation that handles it.
447pub struct Route {
448  /// The path to serve this route from. See [URI documentation](/docs/configuration/uri) for more information on specifying query and path parameters.
449
450  #[serde(alias = "uri")]
451  pub sub_path: String,
452  /// The operation that will act as the main entrypoint for this route.
453
454  #[serde(serialize_with = "crate::v1::helpers::serialize_component_expression")]
455  #[serde(deserialize_with = "crate::v1::parse::component_operation_syntax")]
456  pub operation: ComponentOperationExpression,
457  /// The HTTP methods to serve this route for.
458
459  #[serde(default)]
460  #[serde(skip_serializing_if = "Vec::is_empty")]
461  pub methods: Vec<HttpMethod>,
462  /// The unique ID of the route, used for documentation and tooling.
463
464  #[serde(default)]
465  #[serde(skip_serializing_if = "Option::is_none")]
466  pub id: Option<String>,
467  /// A short description of the route.
468
469  #[serde(default)]
470  #[serde(skip_serializing_if = "Option::is_none")]
471  pub description: Option<String>,
472  /// A longer description of the route.
473
474  #[serde(default)]
475  #[serde(skip_serializing_if = "Option::is_none")]
476  pub summary: Option<String>,
477}
478
479#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
480#[serde(deny_unknown_fields)]
481/// Additional tools and services to enable.
482pub struct Tools {
483  /// Set to true to generate an OpenAPI specification and serve it at *router_path*/openapi.json
484
485  #[serde(default)]
486  pub openapi: bool,
487}
488
489#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
490#[serde(deny_unknown_fields)]
491/// Information about the router to use when generating documentation and other tools.
492pub struct Info {
493  /// The title of the API.
494
495  #[serde(default)]
496  #[serde(skip_serializing_if = "Option::is_none")]
497  pub title: Option<String>,
498  /// A short description of the API.
499
500  #[serde(default)]
501  #[serde(skip_serializing_if = "Option::is_none")]
502  pub description: Option<String>,
503  /// The terms of service for the API.
504
505  #[serde(default)]
506  #[serde(skip_serializing_if = "Option::is_none")]
507  pub tos: Option<String>,
508  /// The contact information for the API.
509
510  #[serde(default)]
511  #[serde(skip_serializing_if = "Option::is_none")]
512  pub contact: Option<Contact>,
513  /// The license information for the API.
514
515  #[serde(default)]
516  #[serde(skip_serializing_if = "Option::is_none")]
517  pub license: Option<License>,
518  /// The version of the API.
519
520  #[serde(default)]
521  pub version: String,
522  /// The URL to the API&#x27;s terms of service.
523
524  #[serde(default)]
525  #[serde(skip_serializing_if = "Option::is_none")]
526  pub documentation: Option<Documentation>,
527}
528
529#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
530#[serde(deny_unknown_fields)]
531/// Information about where and how the API is documented.
532pub struct Documentation {
533  /// The URL to the API&#x27;s documentation.
534
535  #[serde(default)]
536  #[serde(skip_serializing_if = "Option::is_none")]
537  pub url: Option<String>,
538  /// A short description of the documentation.
539
540  #[serde(default)]
541  #[serde(skip_serializing_if = "Option::is_none")]
542  pub description: Option<String>,
543}
544
545#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
546#[serde(deny_unknown_fields)]
547/// Any licensing information for the API.
548pub struct License {
549  /// The name of the license.
550  pub name: String,
551  /// The URL to the license.
552
553  #[serde(default)]
554  #[serde(skip_serializing_if = "Option::is_none")]
555  pub url: Option<String>,
556}
557
558#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
559#[serde(deny_unknown_fields)]
560/// Contact information to expose for the API.
561pub struct Contact {
562  /// The name of the contact.
563
564  #[serde(default)]
565  #[serde(skip_serializing_if = "Option::is_none")]
566  pub name: Option<String>,
567  /// The URL to the contact.
568
569  #[serde(default)]
570  #[serde(skip_serializing_if = "Option::is_none")]
571  pub url: Option<String>,
572  /// The email address of the contact.
573
574  #[serde(default)]
575  #[serde(skip_serializing_if = "Option::is_none")]
576  pub email: Option<String>,
577}
578
579#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
580#[serde(deny_unknown_fields)]
581/// A router that serves static files.
582pub struct StaticRouter {
583  /// The path that this router will trigger for.
584  pub path: String,
585  /// Middleware operations for this router.
586
587  #[serde(default)]
588  #[serde(skip_serializing_if = "Option::is_none")]
589  pub middleware: Option<Middleware>,
590  /// The volume to serve static files from.
591  pub volume: String,
592  /// Fallback path (relative to volume &#x60;resource&#x60;) for files to serve in case of a 404. Useful for SPA&#x27;s. if volume resource is: /www and fallback: index.html, then a 404 will serve /www/index.html
593
594  #[serde(default)]
595  #[serde(skip_serializing_if = "Option::is_none")]
596  pub fallback: Option<String>,
597  /// Whether or not to serve directory listings when a directory is requested.
598
599  #[serde(default)]
600  pub indexes: bool,
601}
602
603#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
604#[serde(deny_unknown_fields)]
605/// A router that delegates all requests to the configured operation, optionally encoding/decoding based on the specified codec.
606pub struct RawRouter {
607  /// The path that this router will trigger for.
608  pub path: String,
609  /// Middleware operations for this router.
610
611  #[serde(default)]
612  #[serde(skip_serializing_if = "Option::is_none")]
613  pub middleware: Option<Middleware>,
614  /// The codec to use when encoding/decoding data.
615
616  #[serde(default)]
617  #[serde(skip_serializing_if = "Option::is_none")]
618  pub codec: Option<Codec>,
619  /// The operation that handles HTTP requests.
620
621  #[serde(serialize_with = "crate::v1::helpers::serialize_component_expression")]
622  #[serde(deserialize_with = "crate::v1::parse::component_operation_syntax")]
623  pub operation: ComponentOperationExpression,
624}
625
626#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
627#[serde(deny_unknown_fields)]
628/// Request and response operations that run before and after the main operation.
629pub struct Middleware {
630  /// The middleware to apply to requests.
631
632  #[serde(default)]
633  #[serde(skip_serializing_if = "Vec::is_empty")]
634  #[serde(deserialize_with = "crate::v1::parse::vec_component_operation")]
635  pub request: Vec<ComponentOperationExpression>,
636  /// The middleware to apply to responses.
637
638  #[serde(default)]
639  #[serde(skip_serializing_if = "Vec::is_empty")]
640  #[serde(deserialize_with = "crate::v1::parse::vec_component_operation")]
641  pub response: Vec<ComponentOperationExpression>,
642}
643
644#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
645#[serde(deny_unknown_fields)]
646/// A type definition for a Wick Components and Operations
647pub struct TypesConfiguration {
648  /// The name of this type.
649
650  #[serde(default)]
651  #[serde(skip_serializing_if = "Option::is_none")]
652  pub name: Option<String>,
653  /// Associated metadata for this type.
654
655  #[serde(default)]
656  #[serde(skip_serializing_if = "Option::is_none")]
657  pub metadata: Option<Metadata>,
658  /// Additional types to export and make available to the type.
659
660  #[serde(default)]
661  #[serde(skip_serializing_if = "Vec::is_empty")]
662  pub types: Vec<TypeDefinition>,
663  /// A list of operation signatures.
664
665  #[serde(default)]
666  #[serde(skip_serializing_if = "Vec::is_empty")]
667  pub operations: Vec<OperationDefinition>,
668  /// Details about the package for this types.
669
670  #[serde(default)]
671  #[serde(skip_serializing_if = "Option::is_none")]
672  pub package: Option<PackageDefinition>,
673}
674
675#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
676#[serde(deny_unknown_fields)]
677/// A configuration for a Wick Component
678pub struct TestConfiguration {
679  /// The name of this component.
680
681  #[serde(default)]
682  #[serde(skip_serializing_if = "Option::is_none")]
683  pub name: Option<String>,
684  /// Configuration used to instantiate this component.
685
686  #[serde(default)]
687  #[serde(skip_serializing_if = "Option::is_none")]
688  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
689  /// Unit tests to run against components and operations.
690
691  #[serde(default)]
692  #[serde(skip_serializing_if = "Vec::is_empty")]
693  pub cases: Vec<TestDefinition>,
694}
695
696#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
697#[serde(deny_unknown_fields)]
698/// A lockdown configuration used to secure Wick components and applications
699pub struct LockdownConfiguration {
700  /// Associated metadata for this configuration.
701
702  #[serde(default)]
703  #[serde(skip_serializing_if = "Option::is_none")]
704  pub metadata: Option<Metadata>,
705  /// Restrictions to apply to resources before an application or component can be run.
706
707  #[serde(default)]
708  #[serde(skip_serializing_if = "Vec::is_empty")]
709  pub resources: Vec<ResourceRestriction>,
710}
711
712#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
713#[serde(deny_unknown_fields)]
714#[serde(tag = "kind")]
715/// Restrictions to assert against an application or component.
716pub enum ResourceRestriction {
717  /// A variant representing a [VolumeRestriction] type.
718  #[serde(rename = "wick/resource/volume@v1")]
719  VolumeRestriction(VolumeRestriction),
720  /// A variant representing a [UrlRestriction] type.
721  #[serde(rename = "wick/resource/url@v1")]
722  UrlRestriction(UrlRestriction),
723  /// A variant representing a [TcpPortRestriction] type.
724  #[serde(rename = "wick/resource/tcpport@v1")]
725  TcpPortRestriction(TcpPortRestriction),
726  /// A variant representing a [UdpPortRestriction] type.
727  #[serde(rename = "wick/resource/udpport@v1")]
728  UdpPortRestriction(UdpPortRestriction),
729}
730
731#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
732#[serde(deny_unknown_fields)]
733/// Restrictions to apply against Volume resources
734pub struct VolumeRestriction {
735  /// The components this restriction applies to
736
737  #[serde(default)]
738  #[serde(skip_serializing_if = "Vec::is_empty")]
739  pub components: Vec<String>,
740  /// The volumes to allow
741  pub allow: LiquidTemplate,
742}
743
744#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
745#[serde(deny_unknown_fields)]
746/// Restrictions to apply against URL resources
747pub struct UrlRestriction {
748  /// The components this restriction applies to
749
750  #[serde(default)]
751  #[serde(skip_serializing_if = "Vec::is_empty")]
752  pub components: Vec<String>,
753  /// The URLs to allow
754  pub allow: LiquidTemplate,
755}
756
757#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
758#[serde(deny_unknown_fields)]
759/// Restrictions to apply against TCP Port resources
760pub struct TcpPortRestriction {
761  /// The components this restriction applies to
762
763  #[serde(default)]
764  #[serde(skip_serializing_if = "Vec::is_empty")]
765  pub components: Vec<String>,
766  /// The address to allow
767  pub address: LiquidTemplate,
768  /// The port to allow
769  pub port: LiquidTemplate,
770}
771
772#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
773#[serde(deny_unknown_fields)]
774/// Restrictions to apply against UDP Port resources
775pub struct UdpPortRestriction {
776  /// The components this restriction applies to
777
778  #[serde(default)]
779  #[serde(skip_serializing_if = "Vec::is_empty")]
780  pub components: Vec<String>,
781  /// The address to allow
782  pub address: LiquidTemplate,
783  /// The port to allow
784  pub port: LiquidTemplate,
785}
786
787#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
788#[serde(deny_unknown_fields)]
789/// A configuration for a Wick Component
790pub struct ComponentConfiguration {
791  /// The name of the component.
792
793  #[serde(default)]
794  #[serde(skip_serializing_if = "Option::is_none")]
795  pub name: Option<String>,
796  /// Associated metadata for this component.
797
798  #[serde(default)]
799  #[serde(skip_serializing_if = "Option::is_none")]
800  pub metadata: Option<Metadata>,
801  /// Details about the package for this component.
802
803  #[serde(default)]
804  #[serde(skip_serializing_if = "Option::is_none")]
805  pub package: Option<PackageDefinition>,
806  /// Configuration for when wick hosts this component as a service.
807
808  #[serde(default)]
809  #[serde(skip_serializing_if = "Option::is_none")]
810  pub host: Option<HostConfig>,
811  /// Resources that the component can access.
812
813  #[serde(default)]
814  #[serde(skip_serializing_if = "Vec::is_empty")]
815  pub resources: Vec<ResourceBinding>,
816  /// Components or types to import into this component&#x27;s scope.
817
818  #[serde(default)]
819  #[serde(skip_serializing_if = "Vec::is_empty")]
820  pub import: Vec<ImportBinding>,
821  /// Additional types to export and make available to the component.
822
823  #[serde(default)]
824  #[serde(skip_serializing_if = "Vec::is_empty")]
825  pub types: Vec<TypeDefinition>,
826  /// Interfaces the component requires to operate.
827
828  #[serde(default)]
829  #[serde(skip_serializing_if = "Vec::is_empty")]
830  pub requires: Vec<InterfaceBinding>,
831  /// Configuration specific to different kinds of components.
832  pub component: ComponentKind,
833  /// Assertions that can be run against the component to validate its behavior.
834
835  #[serde(default)]
836  #[serde(skip_serializing_if = "Vec::is_empty")]
837  pub tests: Vec<TestConfiguration>,
838}
839
840#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
841#[serde(deny_unknown_fields)]
842/// An interface bound to an ID. Used in the require/provide relationship between components.
843pub struct InterfaceBinding {
844  /// The name of the interface.
845  pub name: String,
846  /// The interface to bind to.
847  pub interface: InterfaceDefinition,
848}
849
850#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
851#[serde(deny_unknown_fields)]
852/// A interface definition. Used as a signature that components can require or provide.
853pub struct InterfaceDefinition {
854  /// Types used by the interface&#x27;s operations
855
856  #[serde(default)]
857  #[serde(skip_serializing_if = "Vec::is_empty")]
858  pub types: Vec<TypeDefinition>,
859  /// A list of operations defined by this interface.
860
861  #[serde(default)]
862  #[serde(skip_serializing_if = "Vec::is_empty")]
863  pub operations: Vec<OperationDefinition>,
864}
865
866#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
867#[serde(deny_unknown_fields)]
868/// A component made from connectiong other components.
869pub struct CompositeComponentConfiguration {
870  /// A list of operations exposed by the Composite component.
871
872  #[serde(default)]
873  #[serde(skip_serializing_if = "Vec::is_empty")]
874  pub operations: Vec<CompositeOperationDefinition>,
875  /// Configuration necessary to provide when instantiating the component.
876
877  #[serde(default)]
878  #[serde(skip_serializing_if = "Vec::is_empty")]
879  pub with: Vec<Field>,
880  /// A component or components whose operations you want to inherit from.
881
882  #[serde(default)]
883  #[serde(skip_serializing_if = "Vec::is_empty")]
884  pub extends: Vec<String>,
885}
886
887#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
888#[serde(deny_unknown_fields)]
889/// A component whose implementation is a WasmRS WebAssembly module.
890pub struct WasmComponentConfiguration {
891  /// The path or OCI reference to the WebAssembly module
892
893  #[serde(rename = "ref")]
894  pub reference: crate::v1::helpers::LocationReference,
895  /// Volumes to expose to the component.
896
897  #[serde(default)]
898  #[serde(skip_serializing_if = "Vec::is_empty")]
899  pub volumes: Vec<ExposedVolume>,
900  /// The default size to allocate to the component&#x27;s send/receive buffer.
901
902  #[serde(default)]
903  #[serde(skip_serializing_if = "Option::is_none")]
904  pub max_packet_size: Option<u32>,
905  /// Configuration necessary to provide when instantiating the component.
906
907  #[serde(default)]
908  #[serde(skip_serializing_if = "Vec::is_empty")]
909  pub with: Vec<Field>,
910  /// A list of operations implemented by the WebAssembly module.
911
912  #[serde(default)]
913  #[serde(skip_serializing_if = "Vec::is_empty")]
914  pub operations: Vec<OperationDefinition>,
915}
916
917#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
918#[serde(deny_unknown_fields)]
919/// A component whose implementation is a WasmRS WebAssembly module.
920pub struct WasmComponentModel {
921  /// The path or OCI reference to the WebAssembly module
922
923  #[serde(rename = "ref")]
924  pub reference: crate::v1::helpers::LocationReference,
925  /// Volumes to expose to the component.
926
927  #[serde(default)]
928  #[serde(skip_serializing_if = "Vec::is_empty")]
929  pub volumes: Vec<ExposedVolume>,
930  /// Configuration necessary to provide when instantiating the component.
931
932  #[serde(default)]
933  #[serde(skip_serializing_if = "Vec::is_empty")]
934  pub with: Vec<Field>,
935  /// A list of operations implemented by the WebAssembly module.
936
937  #[serde(default)]
938  #[serde(skip_serializing_if = "Vec::is_empty")]
939  pub operations: Vec<OperationDefinition>,
940}
941
942#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
943#[serde(deny_unknown_fields)]
944/// Volumes to expose to a component and the internal paths they map to.
945pub struct ExposedVolume {
946  /// The resource ID of the volume.
947  pub resource: BoundIdentifier,
948  /// The path to map it to in the component.
949  pub path: String,
950}
951
952#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
953#[serde(deny_unknown_fields)]
954#[serde(tag = "kind")]
955/// Root component types. These are the components that can be instantiated and run.
956pub enum ComponentKind {
957  /// A variant representing a [WasmComponentConfiguration] type.
958  #[serde(rename = "wick/component/wasmrs@v1")]
959  WasmComponentConfiguration(WasmComponentConfiguration),
960  /// A variant representing a [WasmComponentModel] type.
961  #[serde(rename = "wick/component/wasm@v1")]
962  WasmComponentModel(WasmComponentModel),
963  /// A variant representing a [CompositeComponentConfiguration] type.
964  #[serde(rename = "wick/component/composite@v1")]
965  CompositeComponentConfiguration(CompositeComponentConfiguration),
966  /// A variant representing a [SqlComponent] type.
967  #[serde(rename = "wick/component/sql@v1")]
968  SqlComponent(SqlComponent),
969  /// A variant representing a [HttpClientComponent] type.
970  #[serde(rename = "wick/component/http@v1")]
971  HttpClientComponent(HttpClientComponent),
972}
973
974#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
975#[serde(deny_unknown_fields)]
976#[serde(tag = "kind")]
977/// Types of possible imports.
978pub enum ImportDefinition {
979  /// A variant representing a [TypesComponent] type.
980  #[serde(rename = "wick/component/types@v1")]
981  TypesComponent(TypesComponent),
982  /// A variant representing a [ManifestComponent] type.
983  #[serde(rename = "wick/component/manifest@v1")]
984  ManifestComponent(ManifestComponent),
985  /// A variant representing a [SqlComponent] type.
986  #[serde(rename = "wick/component/sql@v1")]
987  SqlComponent(SqlComponent),
988  /// A variant representing a [HttpClientComponent] type.
989  #[serde(rename = "wick/component/http@v1")]
990  HttpClientComponent(HttpClientComponent),
991}
992
993#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
994#[serde(deny_unknown_fields)]
995#[serde(tag = "kind")]
996/// Component types used when referencing operations or linking components.
997pub enum ComponentDefinition {
998  /// A variant representing a [GrpcUrlComponent] type.
999  #[serde(rename = "wick/component/grpc@v1")]
1000  GrpcUrlComponent(GrpcUrlComponent),
1001  /// A variant representing a [ManifestComponent] type.
1002  #[serde(rename = "wick/component/manifest@v1")]
1003  ManifestComponent(ManifestComponent),
1004  /// A variant representing a [ComponentReference] type.
1005  #[serde(rename = "wick/component/reference@v1")]
1006  ComponentReference(ComponentReference),
1007  /// A variant representing a [SqlComponent] type.
1008  #[serde(rename = "wick/component/sql@v1")]
1009  SqlComponent(SqlComponent),
1010  /// A variant representing a [HttpClientComponent] type.
1011  #[serde(rename = "wick/component/http@v1")]
1012  HttpClientComponent(HttpClientComponent),
1013}
1014
1015#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1016#[serde(deny_unknown_fields)]
1017/// A types configuration to import into this component's scope.
1018pub struct TypesComponent {
1019  /// The URL (and optional tag) or local file path to find the types manifest.
1020
1021  #[serde(rename = "ref")]
1022  pub reference: crate::v1::helpers::LocationReference,
1023  /// The types to import from the manifest.
1024
1025  #[serde(default)]
1026  #[serde(skip_serializing_if = "Vec::is_empty")]
1027  pub types: Vec<String>,
1028}
1029
1030#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1031#[serde(deny_unknown_fields)]
1032/// A reference to a component in the application's scope.
1033pub struct ComponentReference {
1034  /// The id of the referenced component.
1035  pub id: BoundIdentifier,
1036}
1037
1038#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
1039#[serde(deny_unknown_fields)]
1040/// Host configuration options.
1041pub struct HostConfig {
1042  /// Whether or not to allow the &#x60;:latest&#x60; tag on remote artifacts.
1043
1044  #[serde(default)]
1045  pub allow_latest: bool,
1046  /// A list of registries to connect to insecurely (over HTTP vs HTTPS).
1047
1048  #[serde(default)]
1049  #[serde(skip_serializing_if = "Vec::is_empty")]
1050  pub insecure_registries: Vec<String>,
1051  /// Configuration for the GRPC server.
1052
1053  #[serde(default)]
1054  #[serde(skip_serializing_if = "Option::is_none")]
1055  pub rpc: Option<HttpConfig>,
1056}
1057
1058#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1059#[serde(deny_unknown_fields)]
1060/// Configuration for the GRPC service.
1061pub struct HttpConfig {
1062  /// Enable/disable the server.
1063
1064  #[serde(default)]
1065  pub enabled: bool,
1066  /// The port to bind to.
1067
1068  #[serde(default)]
1069  #[serde(skip_serializing_if = "Option::is_none")]
1070  pub port: Option<u16>,
1071  /// The address to bind to.
1072
1073  #[serde(default)]
1074  #[serde(skip_serializing_if = "Option::is_none")]
1075  pub address: Option<String>,
1076  /// Path to pem file for TLS.
1077
1078  #[serde(default)]
1079  #[serde(skip_serializing_if = "Option::is_none")]
1080  pub pem: Option<crate::v1::helpers::LocationReference>,
1081  /// Path to key file for TLS.
1082
1083  #[serde(default)]
1084  #[serde(skip_serializing_if = "Option::is_none")]
1085  pub key: Option<crate::v1::helpers::LocationReference>,
1086  /// Path to CA file.
1087
1088  #[serde(default)]
1089  #[serde(skip_serializing_if = "Option::is_none")]
1090  pub ca: Option<crate::v1::helpers::LocationReference>,
1091}
1092
1093#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1094#[serde(deny_unknown_fields)]
1095/// A component hosted as an independent microservice.
1096pub struct GrpcUrlComponent {
1097  /// The GRPC URL to connect to.
1098  pub url: String,
1099  /// Any configuration necessary for the component.
1100
1101  #[serde(default)]
1102  #[serde(skip_serializing_if = "Option::is_none")]
1103  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
1104}
1105
1106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1107#[serde(deny_unknown_fields)]
1108/// A configuration defined in a Wick component manifest.
1109pub struct ManifestComponent {
1110  /// The URL (and optional tag) or local file path to find the manifest.
1111
1112  #[serde(rename = "ref")]
1113  pub reference: crate::v1::helpers::LocationReference,
1114  /// Any configuration necessary for the component.
1115
1116  #[serde(default)]
1117  #[serde(skip_serializing_if = "Option::is_none")]
1118  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
1119  /// External components to provide to the referenced component.
1120
1121  #[serde(default)]
1122  #[serde(skip_serializing_if = "HashMap::is_empty")]
1123  #[serde(deserialize_with = "crate::helpers::kv_deserializer")]
1124  pub provide: HashMap<String, String>,
1125  /// If applicable, the default size to allocate to the component&#x27;s send/receive buffer.
1126
1127  #[serde(default)]
1128  #[serde(skip_serializing_if = "Option::is_none")]
1129  pub max_packet_size: Option<u32>,
1130}
1131
1132#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1133#[serde(deny_unknown_fields)]
1134/// Composite operations are operations whose implementations come from connecting other operations into a flow or series of pipelines.
1135pub struct CompositeOperationDefinition {
1136  /// The name of the operation.
1137
1138  #[serde(default)]
1139  pub name: String,
1140  /// Any configuration required by the operation.
1141
1142  #[serde(default)]
1143  #[serde(skip_serializing_if = "Vec::is_empty")]
1144  pub with: Vec<Field>,
1145  /// Types of the inputs to the operation.
1146
1147  #[serde(default)]
1148  #[serde(skip_serializing_if = "Vec::is_empty")]
1149  pub inputs: Vec<Field>,
1150  /// Types of the outputs to the operation.
1151
1152  #[serde(default)]
1153  #[serde(skip_serializing_if = "Vec::is_empty")]
1154  pub outputs: Vec<Field>,
1155  /// A map of IDs to specific operations.
1156
1157  #[serde(default)]
1158  #[serde(skip_serializing_if = "Vec::is_empty")]
1159  pub uses: Vec<OperationInstance>,
1160  /// A list of connections from operation to operation.
1161
1162  #[serde(default)]
1163  #[serde(skip_serializing_if = "Vec::is_empty")]
1164  #[serde(deserialize_with = "crate::v1::parse::vec_connection")]
1165  pub flow: Vec<FlowExpression>,
1166  /// Additional &#x60;CompositeOperationDefinition&#x60;s to define as children.
1167
1168  #[serde(default)]
1169  #[serde(skip_serializing_if = "Vec::is_empty")]
1170  pub operations: Vec<CompositeOperationDefinition>,
1171}
1172
1173#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1174#[serde(deny_unknown_fields)]
1175#[serde(untagged)]
1176/// A flow operation, i.e. a connection from one operation's outputs to another's inputs.
1177pub enum FlowExpression {
1178  /// A variant representing a [ConnectionDefinition] type.
1179  #[serde(rename = "ConnectionDefinition")]
1180  ConnectionDefinition(ConnectionDefinition),
1181  /// A variant representing a [BlockExpression] type.
1182  #[serde(rename = "BlockExpression")]
1183  BlockExpression(BlockExpression),
1184}
1185
1186#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1187#[serde(deny_unknown_fields)]
1188/// A list of FlowExpressions. Typically used only when expanding a shortform `FlowExpression` into multiple `FlowExpression`s.
1189pub struct BlockExpression {
1190  #[serde(skip_serializing_if = "Vec::is_empty")]
1191  #[serde(deserialize_with = "crate::v1::parse::vec_connection")]
1192  pub expressions: Vec<FlowExpression>,
1193}
1194
1195#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1196#[serde(into = "String")]
1197#[serde(deny_unknown_fields)]
1198/// A connection between Operations and their ports. This can be specified in short-form syntax.
1199pub struct ConnectionDefinition {
1200  /// An upstream operation&#x27;s output.
1201  pub from: ConnectionTargetDefinition,
1202  /// A downstream operation&#x27;s input.
1203  pub to: ConnectionTargetDefinition,
1204}
1205
1206#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1207#[serde(deny_unknown_fields)]
1208/// A connection target e.g. a specific input or output on an operation instance. This can be specified in shortform syntax.
1209pub struct ConnectionTargetDefinition {
1210  /// The instance ID of the component operation.
1211  pub instance: String,
1212  /// The operation&#x27;s input or output (depending on to/from).
1213
1214  #[serde(default)]
1215  #[serde(skip_serializing_if = "Option::is_none")]
1216  pub port: Option<String>,
1217  /// The default value to provide on this connection in the event of an error.
1218
1219  #[serde(default)]
1220  #[serde(skip_serializing_if = "Option::is_none")]
1221  pub data: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
1222}
1223
1224#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1225#[serde(deny_unknown_fields)]
1226/// An operation name and its input and output signatures
1227pub struct OperationDefinition {
1228  /// The name of the operation.
1229
1230  #[serde(default)]
1231  pub name: String,
1232  /// Any configuration required by the operation.
1233
1234  #[serde(default)]
1235  #[serde(skip_serializing_if = "Vec::is_empty")]
1236  pub with: Vec<Field>,
1237  /// Types of the inputs to the operation.
1238
1239  #[serde(default)]
1240  #[serde(skip_serializing_if = "Vec::is_empty")]
1241  pub inputs: Vec<Field>,
1242  /// Types of the outputs to the operation.
1243
1244  #[serde(default)]
1245  #[serde(skip_serializing_if = "Vec::is_empty")]
1246  pub outputs: Vec<Field>,
1247}
1248
1249#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1250#[serde(deny_unknown_fields)]
1251/// Field definition with a name and type signature
1252pub struct Field {
1253  /// The name of the field.
1254  pub name: String,
1255  /// The type signature of the field.
1256
1257  #[serde(rename = "type")]
1258  pub ty: TypeSignature,
1259  /// The description of the field.
1260
1261  #[serde(default)]
1262  #[serde(skip_serializing_if = "Option::is_none")]
1263  pub description: Option<String>,
1264}
1265
1266#[derive(Debug, Clone, serde_with::DeserializeFromStr, Serialize, PartialEq)]
1267#[serde(deny_unknown_fields)]
1268#[serde(into = "String")]
1269#[serde(tag = "kind")]
1270pub enum TypeSignature {
1271  /// A variant representing a [I8] type.
1272  #[serde(rename = "I8")]
1273  I8(I8),
1274  /// A variant representing a [I16] type.
1275  #[serde(rename = "I16")]
1276  I16(I16),
1277  /// A variant representing a [I32] type.
1278  #[serde(rename = "I32")]
1279  I32(I32),
1280  /// A variant representing a [I64] type.
1281  #[serde(rename = "I64")]
1282  I64(I64),
1283  /// A variant representing a [U8] type.
1284  #[serde(rename = "U8")]
1285  U8(U8),
1286  /// A variant representing a [U16] type.
1287  #[serde(rename = "U16")]
1288  U16(U16),
1289  /// A variant representing a [U32] type.
1290  #[serde(rename = "U32")]
1291  U32(U32),
1292  /// A variant representing a [U64] type.
1293  #[serde(rename = "U64")]
1294  U64(U64),
1295  /// A variant representing a [F32] type.
1296  #[serde(rename = "F32")]
1297  F32(F32),
1298  /// A variant representing a [F64] type.
1299  #[serde(rename = "F64")]
1300  F64(F64),
1301  /// A variant representing a [Bool] type.
1302  #[serde(rename = "Bool")]
1303  Bool(Bool),
1304  /// A variant representing a [StringType] type.
1305  #[serde(rename = "StringType")]
1306  StringType(StringType),
1307  /// A variant representing a [Optional] type.
1308  #[serde(rename = "Optional")]
1309  Optional(Optional),
1310  /// A variant representing a [Datetime] type.
1311  #[serde(rename = "Datetime")]
1312  Datetime(Datetime),
1313  /// A variant representing a [Bytes] type.
1314  #[serde(rename = "Bytes")]
1315  Bytes(Bytes),
1316  /// A variant representing a [Custom] type.
1317  #[serde(rename = "Custom")]
1318  Custom(Custom),
1319  /// A variant representing a [List] type.
1320  #[serde(rename = "List")]
1321  List(List),
1322  /// A variant representing a [Map] type.
1323  #[serde(rename = "Map")]
1324  Map(Map),
1325  /// A variant representing a [Object] type.
1326  #[serde(rename = "Object")]
1327  Object(Object),
1328}
1329
1330#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1331#[serde(deny_unknown_fields)]
1332pub struct I8;
1333
1334#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1335#[serde(deny_unknown_fields)]
1336pub struct I16;
1337
1338#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1339#[serde(deny_unknown_fields)]
1340pub struct I32;
1341
1342#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1343#[serde(deny_unknown_fields)]
1344pub struct I64;
1345
1346#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1347#[serde(deny_unknown_fields)]
1348pub struct U8;
1349
1350#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1351#[serde(deny_unknown_fields)]
1352pub struct U16;
1353
1354#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1355#[serde(deny_unknown_fields)]
1356pub struct U32;
1357
1358#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1359#[serde(deny_unknown_fields)]
1360pub struct U64;
1361
1362#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1363#[serde(deny_unknown_fields)]
1364pub struct F32;
1365
1366#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1367#[serde(deny_unknown_fields)]
1368pub struct F64;
1369
1370#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1371#[serde(deny_unknown_fields)]
1372pub struct Bool;
1373
1374#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1375#[serde(deny_unknown_fields)]
1376pub struct StringType;
1377
1378#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1379#[serde(deny_unknown_fields)]
1380pub struct Datetime;
1381
1382#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1383#[serde(deny_unknown_fields)]
1384pub struct Bytes;
1385
1386#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1387#[serde(deny_unknown_fields)]
1388pub struct Custom {
1389  /// The name of the custom type.
1390
1391  #[serde(default)]
1392  pub name: String,
1393}
1394
1395#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1396#[serde(deny_unknown_fields)]
1397pub struct Optional {
1398  #[serde(rename = "type")]
1399  pub ty: Box<TypeSignature>,
1400}
1401
1402#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1403#[serde(deny_unknown_fields)]
1404pub struct List {
1405  #[serde(rename = "type")]
1406  pub ty: Box<TypeSignature>,
1407}
1408
1409#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1410#[serde(deny_unknown_fields)]
1411pub struct Map {
1412  pub key: Box<TypeSignature>,
1413
1414  pub value: Box<TypeSignature>,
1415}
1416
1417#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1418#[serde(deny_unknown_fields)]
1419pub struct Object;
1420
1421#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1422#[serde(deny_unknown_fields)]
1423#[serde(tag = "kind")]
1424/// A Struct or Enum type definition.
1425pub enum TypeDefinition {
1426  /// A variant representing a [StructSignature] type.
1427  #[serde(rename = "wick/type/struct@v1")]
1428  StructSignature(StructSignature),
1429  /// A variant representing a [EnumSignature] type.
1430  #[serde(rename = "wick/type/enum@v1")]
1431  EnumSignature(EnumSignature),
1432  /// A variant representing a [UnionSignature] type.
1433  #[serde(rename = "wick/type/union@v1")]
1434  UnionSignature(UnionSignature),
1435}
1436
1437#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1438#[serde(deny_unknown_fields)]
1439/// A struct definition of named fields and types.
1440pub struct StructSignature {
1441  /// The name of the struct.
1442
1443  #[serde(default)]
1444  pub name: String,
1445  /// The fields in this struct.
1446
1447  #[serde(default)]
1448  #[serde(skip_serializing_if = "Vec::is_empty")]
1449  pub fields: Vec<Field>,
1450  /// The description of the struct.
1451
1452  #[serde(default)]
1453  #[serde(skip_serializing_if = "Option::is_none")]
1454  pub description: Option<String>,
1455}
1456
1457#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1458#[serde(deny_unknown_fields)]
1459/// An enum definition of named variants.
1460pub struct UnionSignature {
1461  /// The name of the union.
1462
1463  #[serde(default)]
1464  pub name: String,
1465  /// The types in the union.
1466
1467  #[serde(default)]
1468  #[serde(skip_serializing_if = "Vec::is_empty")]
1469  pub types: Vec<TypeSignature>,
1470  /// The description of the union.
1471
1472  #[serde(default)]
1473  #[serde(skip_serializing_if = "Option::is_none")]
1474  pub description: Option<String>,
1475}
1476
1477#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1478#[serde(deny_unknown_fields)]
1479/// An enum definition of named variants.
1480pub struct EnumSignature {
1481  /// The name of the enum.
1482
1483  #[serde(default)]
1484  pub name: String,
1485  /// The variants in the enum.
1486
1487  #[serde(default)]
1488  #[serde(skip_serializing_if = "Vec::is_empty")]
1489  pub variants: Vec<EnumVariant>,
1490  /// The description of the enum.
1491
1492  #[serde(default)]
1493  #[serde(skip_serializing_if = "Option::is_none")]
1494  pub description: Option<String>,
1495}
1496
1497#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1498#[serde(deny_unknown_fields)]
1499/// An enum variant.
1500pub struct EnumVariant {
1501  /// The name of the variant.
1502
1503  #[serde(default)]
1504  pub name: String,
1505  /// The index of the variant.
1506
1507  #[serde(default)]
1508  #[serde(skip_serializing_if = "Option::is_none")]
1509  pub index: Option<u32>,
1510  /// The optional value of the variant.
1511
1512  #[serde(default)]
1513  #[serde(skip_serializing_if = "Option::is_none")]
1514  pub value: Option<String>,
1515  /// A description of the variant.
1516
1517  #[serde(default)]
1518  #[serde(skip_serializing_if = "Option::is_none")]
1519  pub description: Option<String>,
1520}
1521
1522#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1523#[serde(deny_unknown_fields)]
1524/// An identifier bound to a component's operation.
1525pub struct OperationInstance {
1526  /// The name of the binding.
1527  pub name: String,
1528  /// The operation to bind to.
1529
1530  #[serde(serialize_with = "crate::v1::helpers::serialize_component_expression")]
1531  #[serde(deserialize_with = "crate::v1::parse::component_operation_syntax")]
1532  pub operation: ComponentOperationExpression,
1533  /// Data to associate with the reference, if any.
1534
1535  #[serde(default)]
1536  #[serde(skip_serializing_if = "Option::is_none")]
1537  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
1538  /// Timeout (in milliseconds) to wait for the operation to complete. Use 0 to wait indefinitely.
1539
1540  #[serde(default)]
1541  #[serde(skip_serializing_if = "Option::is_none")]
1542  pub timeout: Option<u64>,
1543}
1544
1545#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1546#[serde(deny_unknown_fields)]
1547/// A test case for a component's operation.
1548pub struct TestDefinition {
1549  /// The name of the test.
1550
1551  #[serde(default)]
1552  #[serde(skip_serializing_if = "Option::is_none")]
1553  pub name: Option<String>,
1554  /// The operaton to test.
1555  pub operation: String,
1556  /// Inherent data to use for the test.
1557
1558  #[serde(default)]
1559  #[serde(skip_serializing_if = "Option::is_none")]
1560  pub inherent: Option<InherentData>,
1561  /// The configuration for the operation, if any.
1562
1563  #[serde(default)]
1564  #[serde(skip_serializing_if = "Option::is_none")]
1565  pub with: Option<HashMap<String, liquid_json::LiquidJsonValue>>,
1566  /// The inputs to the test.
1567
1568  #[serde(default)]
1569  #[serde(alias = "input")]
1570  #[serde(skip_serializing_if = "Vec::is_empty")]
1571  pub inputs: Vec<PacketData>,
1572  /// The expected outputs of the operation.
1573
1574  #[serde(default)]
1575  #[serde(alias = "output")]
1576  #[serde(skip_serializing_if = "Vec::is_empty")]
1577  pub outputs: Vec<TestPacketData>,
1578}
1579
1580#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1581#[serde(deny_unknown_fields)]
1582/// Data inherent to all invocations.
1583pub struct InherentData {
1584  /// A random seed, i.e. to initialize a random number generator.
1585
1586  #[serde(default)]
1587  #[serde(skip_serializing_if = "Option::is_none")]
1588  pub seed: Option<u64>,
1589  /// A timestamp.
1590
1591  #[serde(default)]
1592  #[serde(skip_serializing_if = "Option::is_none")]
1593  pub timestamp: Option<u64>,
1594}
1595
1596#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1597#[serde(deny_unknown_fields)]
1598#[serde(untagged)]
1599/// Either a success packet or an error packet.
1600pub enum PacketData {
1601  /// A variant representing a [SuccessPacket] type.
1602  #[serde(rename = "SuccessPacket")]
1603  SuccessPacket(SuccessPacket),
1604  /// A variant representing a [SignalPacket] type.
1605  #[serde(rename = "SignalPacket")]
1606  SignalPacket(SignalPacket),
1607  /// A variant representing a [ErrorPacket] type.
1608  #[serde(rename = "ErrorPacket")]
1609  ErrorPacket(ErrorPacket),
1610}
1611
1612#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1613#[serde(deny_unknown_fields)]
1614#[serde(untagged)]
1615/// Packet assertions.
1616pub enum TestPacketData {
1617  /// A variant representing a [SuccessPacket] type.
1618  #[serde(rename = "SuccessPacket")]
1619  SuccessPacket(SuccessPacket),
1620  /// A variant representing a [SignalPacket] type.
1621  #[serde(rename = "SignalPacket")]
1622  SignalPacket(SignalPacket),
1623  /// A variant representing a [PacketAssertionDef] type.
1624  #[serde(rename = "PacketAssertionDef")]
1625  PacketAssertionDef(PacketAssertionDef),
1626  /// A variant representing a [ErrorPacket] type.
1627  #[serde(rename = "ErrorPacket")]
1628  ErrorPacket(ErrorPacket),
1629}
1630
1631#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1632#[serde(deny_unknown_fields)]
1633/// A simplified representation of a Wick signal packet, used when writing tests.
1634pub struct SignalPacket {
1635  /// The name of the input or output this packet is going to or coming from.
1636  pub name: String,
1637  /// Any flags set on the packet. Deprecated, use &#x27;flag:&#x27; instead
1638
1639  #[deprecated()]
1640  #[serde(default)]
1641  #[serde(skip_serializing_if = "Option::is_none")]
1642  pub flags: Option<PacketFlags>,
1643  /// The flag set on the packet.
1644
1645  #[serde(default)]
1646  #[serde(skip_serializing_if = "Option::is_none")]
1647  pub flag: Option<PacketFlag>,
1648}
1649
1650#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1651#[serde(deny_unknown_fields)]
1652/// A simplified representation of a Wick data packet & payload, used when writing tests.
1653pub struct SuccessPacket {
1654  /// The name of the input or output this packet is going to or coming from.
1655  pub name: String,
1656  /// The packet payload.
1657
1658  #[serde(alias = "data")]
1659  pub value: liquid_json::LiquidJsonValue,
1660}
1661
1662#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1663#[serde(deny_unknown_fields)]
1664/// A test case for a component's operation that uses loose equality for comparing data.
1665pub struct PacketAssertionDef {
1666  /// The name of the input or output this packet is going to or coming from.
1667  pub name: String,
1668  /// An assertion to test against the packet.
1669
1670  #[serde(default)]
1671  #[serde(skip_serializing_if = "Vec::is_empty")]
1672  pub assertions: Vec<PacketAssertion>,
1673}
1674
1675#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1676#[serde(deny_unknown_fields)]
1677/// A packet assertion.
1678pub struct PacketAssertion {
1679  /// The optional path to a value in the packet to assert against.
1680
1681  #[serde(default)]
1682  #[serde(skip_serializing_if = "Option::is_none")]
1683  pub path: Option<String>,
1684  /// The operation to use when asserting against a packet.
1685  pub operator: AssertionOperator,
1686  /// A value or object combine with the operator to assert against a packet value.
1687  pub value: liquid_json::LiquidJsonValue,
1688}
1689
1690#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
1691#[serde(deny_unknown_fields)]
1692/// An operation that drives the logic in a packet assertion.
1693pub enum AssertionOperator {
1694  Equals = 0,
1695  LessThan = 1,
1696  GreaterThan = 2,
1697  Regex = 3,
1698  Contains = 4,
1699}
1700
1701impl Default for AssertionOperator {
1702  fn default() -> Self {
1703    Self::from_u16(0).unwrap()
1704  }
1705}
1706
1707impl FromPrimitive for AssertionOperator {
1708  fn from_i64(n: i64) -> Option<Self> {
1709    Some(match n {
1710      0 => Self::Equals,
1711      1 => Self::LessThan,
1712      2 => Self::GreaterThan,
1713      3 => Self::Regex,
1714      4 => Self::Contains,
1715      _ => {
1716        return None;
1717      }
1718    })
1719  }
1720
1721  fn from_u64(n: u64) -> Option<Self> {
1722    Some(match n {
1723      0 => Self::Equals,
1724      1 => Self::LessThan,
1725      2 => Self::GreaterThan,
1726      3 => Self::Regex,
1727      4 => Self::Contains,
1728      _ => {
1729        return None;
1730      }
1731    })
1732  }
1733}
1734
1735#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1736#[serde(deny_unknown_fields)]
1737pub struct ErrorPacket {
1738  /// The name of the input or output this packet is going to or coming from.
1739  pub name: String,
1740  /// Any flags set on the packet. Deprecated, use &#x27;flag:&#x27; instead
1741
1742  #[deprecated()]
1743  #[serde(default)]
1744  #[serde(skip_serializing_if = "Option::is_none")]
1745  pub flags: Option<PacketFlags>,
1746  /// The flag set on the packet.
1747
1748  #[serde(default)]
1749  #[serde(skip_serializing_if = "Option::is_none")]
1750  pub flag: Option<PacketFlag>,
1751  /// The error message.
1752  pub error: LiquidTemplate,
1753}
1754
1755#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1756#[serde(deny_unknown_fields)]
1757/// Flags set on a packet.
1758pub struct PacketFlags {
1759  /// Indicates the port should be considered closed.
1760
1761  #[serde(default)]
1762  pub done: bool,
1763  /// Indicates the opening of a new substream context within the parent stream.
1764
1765  #[serde(default)]
1766  pub open: bool,
1767  /// Indicates the closing of a substream context within the parent stream.
1768
1769  #[serde(default)]
1770  pub close: bool,
1771}
1772
1773#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
1774#[serde(deny_unknown_fields)]
1775/// Possible flags that can be set on a packet.
1776pub enum PacketFlag {
1777  /// Indicates the port should be considered closed.
1778  Done = 0,
1779  /// Indicates the opening of a new substream context within the parent stream.
1780  Open = 1,
1781  /// Indicates the closing of a substream context within the parent stream.
1782  Close = 2,
1783}
1784
1785impl Default for PacketFlag {
1786  fn default() -> Self {
1787    Self::from_u16(0).unwrap()
1788  }
1789}
1790
1791impl FromPrimitive for PacketFlag {
1792  fn from_i64(n: i64) -> Option<Self> {
1793    Some(match n {
1794      0 => Self::Done,
1795      1 => Self::Open,
1796      2 => Self::Close,
1797      _ => {
1798        return None;
1799      }
1800    })
1801  }
1802
1803  fn from_u64(n: u64) -> Option<Self> {
1804    Some(match n {
1805      0 => Self::Done,
1806      1 => Self::Open,
1807      2 => Self::Close,
1808      _ => {
1809        return None;
1810      }
1811    })
1812  }
1813}
1814
1815#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1816#[serde(deny_unknown_fields)]
1817/// A dynamic component whose operations are SQL queries to a database.
1818pub struct SqlComponent {
1819  /// The connect string URL resource for the database.
1820  pub resource: BoundIdentifier,
1821  /// Whether or not to use TLS.
1822
1823  #[serde(default)]
1824  pub tls: bool,
1825  /// Configuration necessary to provide when instantiating the component.
1826
1827  #[serde(default)]
1828  #[serde(skip_serializing_if = "Vec::is_empty")]
1829  pub with: Vec<Field>,
1830  /// A list of operations to expose on this component.
1831
1832  #[serde(default)]
1833  #[serde(skip_serializing_if = "Vec::is_empty")]
1834  pub operations: Vec<SqlQueryKind>,
1835}
1836
1837#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1838#[serde(deny_unknown_fields)]
1839#[serde(untagged)]
1840pub enum SqlQueryKind {
1841  /// A variant representing a [SqlQueryOperationDefinition] type.
1842  #[serde(rename = "SqlQueryOperationDefinition")]
1843  SqlQueryOperationDefinition(SqlQueryOperationDefinition),
1844  /// A variant representing a [SqlExecOperationDefinition] type.
1845  #[serde(rename = "SqlExecOperationDefinition")]
1846  SqlExecOperationDefinition(SqlExecOperationDefinition),
1847}
1848
1849#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1850#[serde(deny_unknown_fields)]
1851/// A dynamic operation whose implementation is a SQL query.
1852pub struct SqlQueryOperationDefinition {
1853  /// The name of the operation.
1854  pub name: String,
1855  /// Any configuration required by the operation.
1856
1857  #[serde(default)]
1858  #[serde(skip_serializing_if = "Vec::is_empty")]
1859  pub with: Vec<Field>,
1860  /// Types of the inputs to the operation.
1861
1862  #[serde(default)]
1863  #[serde(skip_serializing_if = "Vec::is_empty")]
1864  pub inputs: Vec<Field>,
1865  /// Types of the outputs to the operation.
1866
1867  #[serde(default)]
1868  #[serde(skip_serializing_if = "Vec::is_empty")]
1869  pub outputs: Vec<Field>,
1870  /// The query to execute.
1871  pub query: String,
1872  /// The positional arguments to the query, defined as a list of input names.
1873
1874  #[serde(default)]
1875  #[serde(skip_serializing_if = "Vec::is_empty")]
1876  pub arguments: Vec<String>,
1877  /// What to do when an error occurs.
1878
1879  #[serde(default)]
1880  #[serde(skip_serializing_if = "Option::is_none")]
1881  pub on_error: Option<ErrorBehavior>,
1882}
1883
1884#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1885#[serde(deny_unknown_fields)]
1886/// A dynamic operation whose implementation is a SQL query that returns the number of rows affected or failure.
1887pub struct SqlExecOperationDefinition {
1888  /// The name of the operation.
1889  pub name: String,
1890  /// Any configuration required by the operation.
1891
1892  #[serde(default)]
1893  #[serde(skip_serializing_if = "Vec::is_empty")]
1894  pub with: Vec<Field>,
1895  /// Types of the inputs to the operation.
1896
1897  #[serde(default)]
1898  #[serde(skip_serializing_if = "Vec::is_empty")]
1899  pub inputs: Vec<Field>,
1900  /// Types of the outputs to the operation.
1901
1902  #[serde(default)]
1903  #[serde(skip_serializing_if = "Vec::is_empty")]
1904  pub outputs: Vec<Field>,
1905  /// The query to execute.
1906  pub exec: String,
1907  /// The positional arguments to the query, defined as a list of input names.
1908
1909  #[serde(default)]
1910  #[serde(skip_serializing_if = "Vec::is_empty")]
1911  pub arguments: Vec<String>,
1912  /// What to do when an error occurs.
1913
1914  #[serde(default)]
1915  #[serde(skip_serializing_if = "Option::is_none")]
1916  pub on_error: Option<ErrorBehavior>,
1917}
1918
1919#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
1920#[serde(deny_unknown_fields)]
1921/// What to do when an error occurs.
1922pub enum ErrorBehavior {
1923  /// Errors will be ignored.
1924  Ignore = 0,
1925  /// The operation will commit what has succeeded.
1926  Commit = 1,
1927  /// The operation will rollback changes.
1928  Rollback = 2,
1929}
1930
1931impl Default for ErrorBehavior {
1932  fn default() -> Self {
1933    Self::from_u16(0).unwrap()
1934  }
1935}
1936
1937impl FromPrimitive for ErrorBehavior {
1938  fn from_i64(n: i64) -> Option<Self> {
1939    Some(match n {
1940      0 => Self::Ignore,
1941      1 => Self::Commit,
1942      2 => Self::Rollback,
1943      _ => {
1944        return None;
1945      }
1946    })
1947  }
1948
1949  fn from_u64(n: u64) -> Option<Self> {
1950    Some(match n {
1951      0 => Self::Ignore,
1952      1 => Self::Commit,
1953      2 => Self::Rollback,
1954      _ => {
1955        return None;
1956      }
1957    })
1958  }
1959}
1960
1961#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1962#[serde(deny_unknown_fields)]
1963/// A component whose operations are HTTP requests.
1964pub struct HttpClientComponent {
1965  /// The URL base to use.
1966  pub resource: BoundIdentifier,
1967  /// The codec to use when encoding/decoding data. Can be overridden by individual operations.
1968
1969  #[serde(default)]
1970  #[serde(skip_serializing_if = "Option::is_none")]
1971  pub codec: Option<Codec>,
1972  /// The proxy HTTP / HTTPS to use.
1973
1974  #[serde(default)]
1975  #[serde(skip_serializing_if = "Option::is_none")]
1976  pub proxy: Option<Proxy>,
1977  /// The timeout in seconds
1978
1979  #[serde(default)]
1980  #[serde(skip_serializing_if = "Option::is_none")]
1981  pub timeout: Option<u16>,
1982  /// Configuration necessary to provide when instantiating the component.
1983
1984  #[serde(default)]
1985  #[serde(skip_serializing_if = "Vec::is_empty")]
1986  pub with: Vec<Field>,
1987  /// A list of operations to expose on this component.
1988
1989  #[serde(default)]
1990  #[serde(skip_serializing_if = "Vec::is_empty")]
1991  pub operations: Vec<HttpClientOperationDefinition>,
1992}
1993
1994#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1995#[serde(deny_unknown_fields)]
1996pub struct Proxy {
1997  /// The URL base to use. http, https are supported.
1998
1999  #[serde(default)]
2000  pub resource: String,
2001  /// The username to use when authenticating with the proxy.
2002
2003  #[serde(default)]
2004  #[serde(skip_serializing_if = "Option::is_none")]
2005  pub username: Option<String>,
2006  /// The password to use when authenticating with the proxy.
2007
2008  #[serde(default)]
2009  #[serde(skip_serializing_if = "Option::is_none")]
2010  pub password: Option<String>,
2011}
2012
2013#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
2014#[serde(deny_unknown_fields)]
2015/// A dynamic operation whose implementation is an HTTP request. The outputs of HttpClientOperationDefinition are always `response` & `body`
2016pub struct HttpClientOperationDefinition {
2017  /// The name of the operation.
2018  pub name: String,
2019  /// Any configuration required by the operation.
2020
2021  #[serde(default)]
2022  #[serde(skip_serializing_if = "Vec::is_empty")]
2023  pub with: Vec<Field>,
2024  /// Types of the inputs to the operation.
2025
2026  #[serde(default)]
2027  #[serde(skip_serializing_if = "Vec::is_empty")]
2028  pub inputs: Vec<Field>,
2029  /// The HTTP method to use.
2030  pub method: HttpMethod,
2031  /// The codec to use when encoding/decoding data.
2032
2033  #[serde(default)]
2034  #[serde(skip_serializing_if = "Option::is_none")]
2035  pub codec: Option<Codec>,
2036  /// Any headers to add to the request.
2037
2038  #[serde(default)]
2039  #[serde(skip_serializing_if = "Option::is_none")]
2040  pub headers: Option<HashMap<String, Vec<String>>>,
2041  /// The body to send, processed as a structured JSON liquid template.
2042
2043  #[serde(default)]
2044  #[serde(skip_serializing_if = "Option::is_none")]
2045  pub body: Option<liquid_json::LiquidJsonValue>,
2046  /// The path to append to our base URL, processed as a liquid template with each input as part of the template data.
2047
2048  #[serde(default)]
2049  pub path: String,
2050}
2051
2052#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
2053#[serde(deny_unknown_fields)]
2054/// Codec to use when encoding/decoding data.
2055pub enum Codec {
2056  /// JSON data
2057  Json = 0,
2058  /// Raw bytes
2059  Raw = 1,
2060  /// Form Data
2061  FormData = 2,
2062  /// Raw text
2063  Text = 3,
2064}
2065
2066impl Default for Codec {
2067  fn default() -> Self {
2068    Self::from_u16(0).unwrap()
2069  }
2070}
2071
2072impl FromPrimitive for Codec {
2073  fn from_i64(n: i64) -> Option<Self> {
2074    Some(match n {
2075      0 => Self::Json,
2076      1 => Self::Raw,
2077      2 => Self::FormData,
2078      3 => Self::Text,
2079      _ => {
2080        return None;
2081      }
2082    })
2083  }
2084
2085  fn from_u64(n: u64) -> Option<Self> {
2086    Some(match n {
2087      0 => Self::Json,
2088      1 => Self::Raw,
2089      2 => Self::FormData,
2090      3 => Self::Text,
2091      _ => {
2092        return None;
2093      }
2094    })
2095  }
2096}
2097
2098#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
2099#[serde(deny_unknown_fields)]
2100/// Supported HTTP methods
2101pub enum HttpMethod {
2102  /// GET method
2103  Get = 0,
2104  /// POST method
2105  Post = 1,
2106  /// PUT method
2107  Put = 2,
2108  /// DELETE method
2109  Delete = 3,
2110}
2111
2112impl Default for HttpMethod {
2113  fn default() -> Self {
2114    Self::from_u16(0).unwrap()
2115  }
2116}
2117
2118impl FromPrimitive for HttpMethod {
2119  fn from_i64(n: i64) -> Option<Self> {
2120    Some(match n {
2121      0 => Self::Get,
2122      1 => Self::Post,
2123      2 => Self::Put,
2124      3 => Self::Delete,
2125      _ => {
2126        return None;
2127      }
2128    })
2129  }
2130
2131  fn from_u64(n: u64) -> Option<Self> {
2132    Some(match n {
2133      0 => Self::Get,
2134      1 => Self::Post,
2135      2 => Self::Put,
2136      3 => Self::Delete,
2137      _ => {
2138        return None;
2139      }
2140    })
2141  }
2142}