Skip to main content

gestalt/
runtime.rs

1// Code generated by sdkgen. DO NOT EDIT.
2
3//! Generated native types and clients for runtime.proto.
4
5use crate::codec::runtime::{
6    from_wire_configure_provider_response, from_wire_health_check_response,
7    from_wire_provider_identity, from_wire_start_runtime_provider_response,
8    to_wire_configure_provider_request,
9};
10use crate::generated::v1;
11use crate::rpc_support::GestaltError;
12
13/// Open enum for `gestalt.provider.v1.ProviderKind`; unknown numeric values are preserved.
14pub type ProviderKind = i32;
15
16/// Named values of `ProviderKind`.
17pub mod provider_kind {
18    /// PROVIDER_KIND_UNSPECIFIED.
19    pub const PROVIDER_KIND_UNSPECIFIED: i32 = 0;
20    /// PROVIDER_KIND_APP.
21    pub const PROVIDER_KIND_APP: i32 = 1;
22    /// PROVIDER_KIND_IDENTITY.
23    pub const PROVIDER_KIND_IDENTITY: i32 = 2;
24    /// PROVIDER_KIND_INDEXEDDB.
25    pub const PROVIDER_KIND_INDEXEDDB: i32 = 3;
26    /// PROVIDER_KIND_SECRETS.
27    pub const PROVIDER_KIND_SECRETS: i32 = 4;
28    /// PROVIDER_KIND_TELEMETRY.
29    pub const PROVIDER_KIND_TELEMETRY: i32 = 5;
30    /// PROVIDER_KIND_CACHE.
31    pub const PROVIDER_KIND_CACHE: i32 = 6;
32    /// PROVIDER_KIND_S3.
33    pub const PROVIDER_KIND_S3: i32 = 7;
34    /// PROVIDER_KIND_WORKFLOW.
35    pub const PROVIDER_KIND_WORKFLOW: i32 = 8;
36    /// PROVIDER_KIND_AUTHORIZATION.
37    pub const PROVIDER_KIND_AUTHORIZATION: i32 = 9;
38    /// PROVIDER_KIND_RUNTIME.
39    pub const PROVIDER_KIND_RUNTIME: i32 = 10;
40    /// PROVIDER_KIND_AGENT.
41    pub const PROVIDER_KIND_AGENT: i32 = 11;
42    /// PROVIDER_KIND_EXTERNAL_CREDENTIAL.
43    pub const PROVIDER_KIND_EXTERNAL_CREDENTIAL: i32 = 12;
44    /// PROVIDER_KIND_TEST.
45    pub const PROVIDER_KIND_TEST: i32 = 13;
46}
47
48/// ConfigureProviderRequest configures a non-integration provider for one
49/// runtime session.
50///
51/// Native message type for `gestalt.provider.v1.ConfigureProviderRequest`.
52#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
53#[serde(rename_all = "camelCase")]
54pub struct ConfigureProviderRequest {
55    /// The `name` field.
56    pub name: String,
57    /// The `config` field; None when unset.
58    pub config: Option<serde_json::Map<String, serde_json::Value>>,
59    /// The `protocol_version` field.
60    pub protocol_version: i32,
61}
62
63/// ConfigureProviderResponse confirms the protocol version the provider is
64/// serving.
65///
66/// Native message type for `gestalt.provider.v1.ConfigureProviderResponse`.
67#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
68#[serde(rename_all = "camelCase")]
69pub struct ConfigureProviderResponse {
70    /// The `protocol_version` field.
71    pub protocol_version: i32,
72}
73
74/// HealthCheckResponse reports runtime readiness for a provider surface.
75///
76/// Native message type for `gestalt.provider.v1.HealthCheckResponse`.
77#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct HealthCheckResponse {
80    /// The `ready` field.
81    pub ready: bool,
82    /// The `message` field.
83    pub message: String,
84}
85
86/// ProviderIdentity describes a provider surface and the protocol versions it
87/// supports.
88///
89/// Native message type for `gestalt.provider.v1.ProviderIdentity`.
90#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
91#[serde(rename_all = "camelCase")]
92pub struct ProviderIdentity {
93    /// The `kind` field.
94    pub kind: ProviderKind,
95    /// The `name` field.
96    pub name: String,
97    /// The `display_name` field.
98    pub display_name: String,
99    /// The `description` field.
100    pub description: String,
101    /// The `version` field.
102    pub version: String,
103    /// The `warnings` field.
104    pub warnings: Vec<String>,
105    /// The `min_protocol_version` field.
106    pub min_protocol_version: i32,
107    /// The `max_protocol_version` field.
108    pub max_protocol_version: i32,
109}
110
111/// StartRuntimeProviderResponse confirms the protocol version the provider is
112/// serving after the optional runtime start phase.
113///
114/// Native message type for `gestalt.provider.v1.StartRuntimeProviderResponse`.
115#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
116#[serde(rename_all = "camelCase")]
117pub struct StartRuntimeProviderResponse {
118    /// The `protocol_version` field.
119    pub protocol_version: i32,
120}
121
122/// ProviderLifecycle is the common lifecycle protocol shared by every provider
123/// kind.
124///
125/// Client for the `gestalt.provider.v1.ProviderLifecycle` service.
126pub struct ProviderLifecycle {
127    inner: v1::provider_lifecycle_client::ProviderLifecycleClient<tonic::transport::Channel>,
128    timeout: Option<std::time::Duration>,
129}
130
131impl ProviderLifecycle {
132    /// Creates a client over an established channel.
133    pub fn new(channel: tonic::transport::Channel) -> Self {
134        Self {
135            inner: v1::provider_lifecycle_client::ProviderLifecycleClient::new(channel),
136            timeout: None,
137        }
138    }
139
140    /// Sets a deadline applied to every unary call; calls that run past it
141    /// fail with DEADLINE_EXCEEDED. Streaming calls are unaffected.
142    pub fn with_timeout(mut self, timeout: std::time::Duration) -> Self {
143        self.timeout = Some(timeout);
144        self
145    }
146
147    /// Calls `gestalt.provider.v1.ProviderLifecycle.GetProviderIdentity`.
148    pub async fn get_provider_identity(&mut self) -> Result<ProviderIdentity, GestaltError> {
149        let mut tonic_request = tonic::Request::new(());
150        if let Some(timeout) = self.timeout {
151            tonic_request.set_timeout(timeout);
152        }
153        let response = self.inner.get_provider_identity(tonic_request).await?;
154        Ok(from_wire_provider_identity(response.into_inner()))
155    }
156
157    /// Calls `gestalt.provider.v1.ProviderLifecycle.ConfigureProvider`.
158    pub async fn configure_provider(
159        &mut self,
160        name: String,
161        protocol_version: i32,
162        config: Option<serde_json::Map<String, serde_json::Value>>,
163    ) -> Result<i32, GestaltError> {
164        let request = ConfigureProviderRequest {
165            name,
166            protocol_version,
167            config,
168        };
169        let mut tonic_request = tonic::Request::new(to_wire_configure_provider_request(request));
170        if let Some(timeout) = self.timeout {
171            tonic_request.set_timeout(timeout);
172        }
173        let response = from_wire_configure_provider_response(
174            self.inner
175                .configure_provider(tonic_request)
176                .await?
177                .into_inner(),
178        );
179        Ok(response.protocol_version)
180    }
181
182    /// Calls `gestalt.provider.v1.ProviderLifecycle.ConfigureProvider` with the full request and response messages.
183    pub async fn configure_provider_raw(
184        &mut self,
185        request: ConfigureProviderRequest,
186    ) -> Result<ConfigureProviderResponse, GestaltError> {
187        let mut tonic_request = tonic::Request::new(to_wire_configure_provider_request(request));
188        if let Some(timeout) = self.timeout {
189            tonic_request.set_timeout(timeout);
190        }
191        let response = self.inner.configure_provider(tonic_request).await?;
192        Ok(from_wire_configure_provider_response(response.into_inner()))
193    }
194
195    /// Calls `gestalt.provider.v1.ProviderLifecycle.HealthCheck`.
196    pub async fn health_check(&mut self) -> Result<HealthCheckResponse, GestaltError> {
197        let mut tonic_request = tonic::Request::new(());
198        if let Some(timeout) = self.timeout {
199            tonic_request.set_timeout(timeout);
200        }
201        let response = self.inner.health_check(tonic_request).await?;
202        Ok(from_wire_health_check_response(response.into_inner()))
203    }
204
205    /// Calls `gestalt.provider.v1.ProviderLifecycle.StartProvider`.
206    pub async fn start_provider(&mut self) -> Result<i32, GestaltError> {
207        let mut tonic_request = tonic::Request::new(());
208        if let Some(timeout) = self.timeout {
209            tonic_request.set_timeout(timeout);
210        }
211        let response = from_wire_start_runtime_provider_response(
212            self.inner.start_provider(tonic_request).await?.into_inner(),
213        );
214        Ok(response.protocol_version)
215    }
216
217    /// Calls `gestalt.provider.v1.ProviderLifecycle.StartProvider` with the full request and response messages.
218    pub async fn start_provider_raw(
219        &mut self,
220    ) -> Result<StartRuntimeProviderResponse, GestaltError> {
221        let mut tonic_request = tonic::Request::new(());
222        if let Some(timeout) = self.timeout {
223            tonic_request.set_timeout(timeout);
224        }
225        let response = self.inner.start_provider(tonic_request).await?;
226        Ok(from_wire_start_runtime_provider_response(
227            response.into_inner(),
228        ))
229    }
230}