1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct DatabaseRequest {
4 #[prost(string, tag = "1")]
5 pub project_name: ::prost::alloc::string::String,
6 #[prost(string, optional, tag = "2")]
8 pub db_name: ::core::option::Option<::prost::alloc::string::String>,
9 #[prost(oneof = "database_request::DbType", tags = "10, 11")]
10 pub db_type: ::core::option::Option<database_request::DbType>,
11}
12pub mod database_request {
14 #[allow(clippy::derive_partial_eq_without_eq)]
15 #[derive(Clone, PartialEq, ::prost::Oneof)]
16 pub enum DbType {
17 #[prost(message, tag = "10")]
18 Shared(super::Shared),
19 #[prost(message, tag = "11")]
20 AwsRds(super::AwsRds),
21 }
22}
23#[allow(clippy::derive_partial_eq_without_eq)]
24#[derive(Clone, PartialEq, ::prost::Message)]
25pub struct DatabaseDumpRequest {
26 #[prost(string, tag = "1")]
27 pub project_name: ::prost::alloc::string::String,
28}
29#[allow(clippy::derive_partial_eq_without_eq)]
30#[derive(Clone, PartialEq, ::prost::Message)]
31pub struct Shared {
32 #[prost(oneof = "shared::Engine", tags = "1, 50")]
33 pub engine: ::core::option::Option<shared::Engine>,
34}
35pub mod shared {
37 #[allow(clippy::derive_partial_eq_without_eq)]
38 #[derive(Clone, PartialEq, ::prost::Oneof)]
39 pub enum Engine {
40 #[prost(string, tag = "1")]
41 Postgres(::prost::alloc::string::String),
42 #[prost(string, tag = "50")]
43 Mongodb(::prost::alloc::string::String),
44 }
45}
46#[allow(clippy::derive_partial_eq_without_eq)]
47#[derive(Clone, PartialEq, ::prost::Message)]
48pub struct AwsRds {
49 #[prost(oneof = "aws_rds::Engine", tags = "1, 2, 3")]
50 pub engine: ::core::option::Option<aws_rds::Engine>,
51}
52pub mod aws_rds {
54 #[allow(clippy::derive_partial_eq_without_eq)]
55 #[derive(Clone, PartialEq, ::prost::Oneof)]
56 pub enum Engine {
57 #[prost(message, tag = "1")]
58 Postgres(super::RdsConfig),
59 #[prost(message, tag = "2")]
60 Mysql(super::RdsConfig),
61 #[prost(message, tag = "3")]
62 Mariadb(super::RdsConfig),
63 }
64}
65#[allow(clippy::derive_partial_eq_without_eq)]
66#[derive(Clone, PartialEq, ::prost::Message)]
67pub struct RdsConfig {}
68#[allow(clippy::derive_partial_eq_without_eq)]
69#[derive(Clone, PartialEq, ::prost::Message)]
70pub struct DatabaseResponse {
71 #[prost(string, tag = "1")]
72 pub username: ::prost::alloc::string::String,
73 #[prost(string, tag = "2")]
74 pub password: ::prost::alloc::string::String,
75 #[prost(string, tag = "3")]
76 pub database_name: ::prost::alloc::string::String,
77 #[prost(string, tag = "4")]
78 pub engine: ::prost::alloc::string::String,
79 #[prost(string, tag = "5")]
80 pub address_private: ::prost::alloc::string::String,
81 #[prost(string, tag = "6")]
82 pub address_public: ::prost::alloc::string::String,
83 #[prost(string, tag = "7")]
84 pub port: ::prost::alloc::string::String,
85}
86#[allow(clippy::derive_partial_eq_without_eq)]
87#[derive(Clone, PartialEq, ::prost::Message)]
88pub struct DatabaseDeletionResponse {}
89#[allow(clippy::derive_partial_eq_without_eq)]
90#[derive(Clone, PartialEq, ::prost::Message)]
91pub struct DatabaseDumpResponse {
92 #[prost(bytes = "vec", tag = "1")]
93 pub sql: ::prost::alloc::vec::Vec<u8>,
94}
95#[allow(clippy::derive_partial_eq_without_eq)]
96#[derive(Clone, PartialEq, ::prost::Message)]
97pub struct Ping {}
98#[allow(clippy::derive_partial_eq_without_eq)]
99#[derive(Clone, PartialEq, ::prost::Message)]
100pub struct Pong {}
101pub mod provisioner_client {
103 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
104 use tonic::codegen::http::Uri;
105 use tonic::codegen::*;
106 #[derive(Debug, Clone)]
107 pub struct ProvisionerClient<T> {
108 inner: tonic::client::Grpc<T>,
109 }
110 impl ProvisionerClient<tonic::transport::Channel> {
111 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
113 where
114 D: TryInto<tonic::transport::Endpoint>,
115 D::Error: Into<StdError>,
116 {
117 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
118 Ok(Self::new(conn))
119 }
120 }
121 impl<T> ProvisionerClient<T>
122 where
123 T: tonic::client::GrpcService<tonic::body::BoxBody>,
124 T::Error: Into<StdError>,
125 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
126 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
127 {
128 pub fn new(inner: T) -> Self {
129 let inner = tonic::client::Grpc::new(inner);
130 Self { inner }
131 }
132 pub fn with_origin(inner: T, origin: Uri) -> Self {
133 let inner = tonic::client::Grpc::with_origin(inner, origin);
134 Self { inner }
135 }
136 pub fn with_interceptor<F>(
137 inner: T,
138 interceptor: F,
139 ) -> ProvisionerClient<InterceptedService<T, F>>
140 where
141 F: tonic::service::Interceptor,
142 T::ResponseBody: Default,
143 T: tonic::codegen::Service<
144 http::Request<tonic::body::BoxBody>,
145 Response = http::Response<
146 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
147 >,
148 >,
149 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
150 Into<StdError> + Send + Sync,
151 {
152 ProvisionerClient::new(InterceptedService::new(inner, interceptor))
153 }
154 #[must_use]
159 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
160 self.inner = self.inner.send_compressed(encoding);
161 self
162 }
163 #[must_use]
165 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
166 self.inner = self.inner.accept_compressed(encoding);
167 self
168 }
169 #[must_use]
173 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
174 self.inner = self.inner.max_decoding_message_size(limit);
175 self
176 }
177 #[must_use]
181 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
182 self.inner = self.inner.max_encoding_message_size(limit);
183 self
184 }
185 pub async fn provision_database(
186 &mut self,
187 request: impl tonic::IntoRequest<super::DatabaseRequest>,
188 ) -> std::result::Result<tonic::Response<super::DatabaseResponse>, tonic::Status> {
189 self.inner.ready().await.map_err(|e| {
190 tonic::Status::new(
191 tonic::Code::Unknown,
192 format!("Service was not ready: {}", e.into()),
193 )
194 })?;
195 let codec = tonic::codec::ProstCodec::default();
196 let path =
197 http::uri::PathAndQuery::from_static("/provisioner.Provisioner/ProvisionDatabase");
198 let mut req = request.into_request();
199 req.extensions_mut().insert(GrpcMethod::new(
200 "provisioner.Provisioner",
201 "ProvisionDatabase",
202 ));
203 self.inner.unary(req, path, codec).await
204 }
205 pub async fn delete_database(
206 &mut self,
207 request: impl tonic::IntoRequest<super::DatabaseRequest>,
208 ) -> std::result::Result<tonic::Response<super::DatabaseDeletionResponse>, tonic::Status>
209 {
210 self.inner.ready().await.map_err(|e| {
211 tonic::Status::new(
212 tonic::Code::Unknown,
213 format!("Service was not ready: {}", e.into()),
214 )
215 })?;
216 let codec = tonic::codec::ProstCodec::default();
217 let path =
218 http::uri::PathAndQuery::from_static("/provisioner.Provisioner/DeleteDatabase");
219 let mut req = request.into_request();
220 req.extensions_mut()
221 .insert(GrpcMethod::new("provisioner.Provisioner", "DeleteDatabase"));
222 self.inner.unary(req, path, codec).await
223 }
224 pub async fn dump_database(
225 &mut self,
226 request: impl tonic::IntoRequest<super::DatabaseDumpRequest>,
227 ) -> std::result::Result<tonic::Response<super::DatabaseDumpResponse>, tonic::Status>
228 {
229 self.inner.ready().await.map_err(|e| {
230 tonic::Status::new(
231 tonic::Code::Unknown,
232 format!("Service was not ready: {}", e.into()),
233 )
234 })?;
235 let codec = tonic::codec::ProstCodec::default();
236 let path =
237 http::uri::PathAndQuery::from_static("/provisioner.Provisioner/DumpDatabase");
238 let mut req = request.into_request();
239 req.extensions_mut()
240 .insert(GrpcMethod::new("provisioner.Provisioner", "DumpDatabase"));
241 self.inner.unary(req, path, codec).await
242 }
243 pub async fn health_check(
244 &mut self,
245 request: impl tonic::IntoRequest<super::Ping>,
246 ) -> std::result::Result<tonic::Response<super::Pong>, tonic::Status> {
247 self.inner.ready().await.map_err(|e| {
248 tonic::Status::new(
249 tonic::Code::Unknown,
250 format!("Service was not ready: {}", e.into()),
251 )
252 })?;
253 let codec = tonic::codec::ProstCodec::default();
254 let path = http::uri::PathAndQuery::from_static("/provisioner.Provisioner/HealthCheck");
255 let mut req = request.into_request();
256 req.extensions_mut()
257 .insert(GrpcMethod::new("provisioner.Provisioner", "HealthCheck"));
258 self.inner.unary(req, path, codec).await
259 }
260 }
261}
262pub mod provisioner_server {
264 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
265 use tonic::codegen::*;
266 #[async_trait]
268 pub trait Provisioner: Send + Sync + 'static {
269 async fn provision_database(
270 &self,
271 request: tonic::Request<super::DatabaseRequest>,
272 ) -> std::result::Result<tonic::Response<super::DatabaseResponse>, tonic::Status>;
273 async fn delete_database(
274 &self,
275 request: tonic::Request<super::DatabaseRequest>,
276 ) -> std::result::Result<tonic::Response<super::DatabaseDeletionResponse>, tonic::Status>;
277 async fn dump_database(
278 &self,
279 request: tonic::Request<super::DatabaseDumpRequest>,
280 ) -> std::result::Result<tonic::Response<super::DatabaseDumpResponse>, tonic::Status>;
281 async fn health_check(
282 &self,
283 request: tonic::Request<super::Ping>,
284 ) -> std::result::Result<tonic::Response<super::Pong>, tonic::Status>;
285 }
286 #[derive(Debug)]
287 pub struct ProvisionerServer<T: Provisioner> {
288 inner: _Inner<T>,
289 accept_compression_encodings: EnabledCompressionEncodings,
290 send_compression_encodings: EnabledCompressionEncodings,
291 max_decoding_message_size: Option<usize>,
292 max_encoding_message_size: Option<usize>,
293 }
294 struct _Inner<T>(Arc<T>);
295 impl<T: Provisioner> ProvisionerServer<T> {
296 pub fn new(inner: T) -> Self {
297 Self::from_arc(Arc::new(inner))
298 }
299 pub fn from_arc(inner: Arc<T>) -> Self {
300 let inner = _Inner(inner);
301 Self {
302 inner,
303 accept_compression_encodings: Default::default(),
304 send_compression_encodings: Default::default(),
305 max_decoding_message_size: None,
306 max_encoding_message_size: None,
307 }
308 }
309 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
310 where
311 F: tonic::service::Interceptor,
312 {
313 InterceptedService::new(Self::new(inner), interceptor)
314 }
315 #[must_use]
317 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
318 self.accept_compression_encodings.enable(encoding);
319 self
320 }
321 #[must_use]
323 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
324 self.send_compression_encodings.enable(encoding);
325 self
326 }
327 #[must_use]
331 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
332 self.max_decoding_message_size = Some(limit);
333 self
334 }
335 #[must_use]
339 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
340 self.max_encoding_message_size = Some(limit);
341 self
342 }
343 }
344 impl<T, B> tonic::codegen::Service<http::Request<B>> for ProvisionerServer<T>
345 where
346 T: Provisioner,
347 B: Body + Send + 'static,
348 B::Error: Into<StdError> + Send + 'static,
349 {
350 type Response = http::Response<tonic::body::BoxBody>;
351 type Error = std::convert::Infallible;
352 type Future = BoxFuture<Self::Response, Self::Error>;
353 fn poll_ready(
354 &mut self,
355 _cx: &mut Context<'_>,
356 ) -> Poll<std::result::Result<(), Self::Error>> {
357 Poll::Ready(Ok(()))
358 }
359 fn call(&mut self, req: http::Request<B>) -> Self::Future {
360 let inner = self.inner.clone();
361 match req.uri().path() {
362 "/provisioner.Provisioner/ProvisionDatabase" => {
363 #[allow(non_camel_case_types)]
364 struct ProvisionDatabaseSvc<T: Provisioner>(pub Arc<T>);
365 impl<T: Provisioner> tonic::server::UnaryService<super::DatabaseRequest>
366 for ProvisionDatabaseSvc<T>
367 {
368 type Response = super::DatabaseResponse;
369 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
370 fn call(
371 &mut self,
372 request: tonic::Request<super::DatabaseRequest>,
373 ) -> Self::Future {
374 let inner = Arc::clone(&self.0);
375 let fut = async move {
376 <T as Provisioner>::provision_database(&inner, request).await
377 };
378 Box::pin(fut)
379 }
380 }
381 let accept_compression_encodings = self.accept_compression_encodings;
382 let send_compression_encodings = self.send_compression_encodings;
383 let max_decoding_message_size = self.max_decoding_message_size;
384 let max_encoding_message_size = self.max_encoding_message_size;
385 let inner = self.inner.clone();
386 let fut = async move {
387 let inner = inner.0;
388 let method = ProvisionDatabaseSvc(inner);
389 let codec = tonic::codec::ProstCodec::default();
390 let mut grpc = tonic::server::Grpc::new(codec)
391 .apply_compression_config(
392 accept_compression_encodings,
393 send_compression_encodings,
394 )
395 .apply_max_message_size_config(
396 max_decoding_message_size,
397 max_encoding_message_size,
398 );
399 let res = grpc.unary(method, req).await;
400 Ok(res)
401 };
402 Box::pin(fut)
403 }
404 "/provisioner.Provisioner/DeleteDatabase" => {
405 #[allow(non_camel_case_types)]
406 struct DeleteDatabaseSvc<T: Provisioner>(pub Arc<T>);
407 impl<T: Provisioner> tonic::server::UnaryService<super::DatabaseRequest> for DeleteDatabaseSvc<T> {
408 type Response = super::DatabaseDeletionResponse;
409 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
410 fn call(
411 &mut self,
412 request: tonic::Request<super::DatabaseRequest>,
413 ) -> Self::Future {
414 let inner = Arc::clone(&self.0);
415 let fut = async move {
416 <T as Provisioner>::delete_database(&inner, request).await
417 };
418 Box::pin(fut)
419 }
420 }
421 let accept_compression_encodings = self.accept_compression_encodings;
422 let send_compression_encodings = self.send_compression_encodings;
423 let max_decoding_message_size = self.max_decoding_message_size;
424 let max_encoding_message_size = self.max_encoding_message_size;
425 let inner = self.inner.clone();
426 let fut = async move {
427 let inner = inner.0;
428 let method = DeleteDatabaseSvc(inner);
429 let codec = tonic::codec::ProstCodec::default();
430 let mut grpc = tonic::server::Grpc::new(codec)
431 .apply_compression_config(
432 accept_compression_encodings,
433 send_compression_encodings,
434 )
435 .apply_max_message_size_config(
436 max_decoding_message_size,
437 max_encoding_message_size,
438 );
439 let res = grpc.unary(method, req).await;
440 Ok(res)
441 };
442 Box::pin(fut)
443 }
444 "/provisioner.Provisioner/DumpDatabase" => {
445 #[allow(non_camel_case_types)]
446 struct DumpDatabaseSvc<T: Provisioner>(pub Arc<T>);
447 impl<T: Provisioner> tonic::server::UnaryService<super::DatabaseDumpRequest>
448 for DumpDatabaseSvc<T>
449 {
450 type Response = super::DatabaseDumpResponse;
451 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
452 fn call(
453 &mut self,
454 request: tonic::Request<super::DatabaseDumpRequest>,
455 ) -> Self::Future {
456 let inner = Arc::clone(&self.0);
457 let fut = async move {
458 <T as Provisioner>::dump_database(&inner, request).await
459 };
460 Box::pin(fut)
461 }
462 }
463 let accept_compression_encodings = self.accept_compression_encodings;
464 let send_compression_encodings = self.send_compression_encodings;
465 let max_decoding_message_size = self.max_decoding_message_size;
466 let max_encoding_message_size = self.max_encoding_message_size;
467 let inner = self.inner.clone();
468 let fut = async move {
469 let inner = inner.0;
470 let method = DumpDatabaseSvc(inner);
471 let codec = tonic::codec::ProstCodec::default();
472 let mut grpc = tonic::server::Grpc::new(codec)
473 .apply_compression_config(
474 accept_compression_encodings,
475 send_compression_encodings,
476 )
477 .apply_max_message_size_config(
478 max_decoding_message_size,
479 max_encoding_message_size,
480 );
481 let res = grpc.unary(method, req).await;
482 Ok(res)
483 };
484 Box::pin(fut)
485 }
486 "/provisioner.Provisioner/HealthCheck" => {
487 #[allow(non_camel_case_types)]
488 struct HealthCheckSvc<T: Provisioner>(pub Arc<T>);
489 impl<T: Provisioner> tonic::server::UnaryService<super::Ping> for HealthCheckSvc<T> {
490 type Response = super::Pong;
491 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
492 fn call(&mut self, request: tonic::Request<super::Ping>) -> Self::Future {
493 let inner = Arc::clone(&self.0);
494 let fut = async move {
495 <T as Provisioner>::health_check(&inner, request).await
496 };
497 Box::pin(fut)
498 }
499 }
500 let accept_compression_encodings = self.accept_compression_encodings;
501 let send_compression_encodings = self.send_compression_encodings;
502 let max_decoding_message_size = self.max_decoding_message_size;
503 let max_encoding_message_size = self.max_encoding_message_size;
504 let inner = self.inner.clone();
505 let fut = async move {
506 let inner = inner.0;
507 let method = HealthCheckSvc(inner);
508 let codec = tonic::codec::ProstCodec::default();
509 let mut grpc = tonic::server::Grpc::new(codec)
510 .apply_compression_config(
511 accept_compression_encodings,
512 send_compression_encodings,
513 )
514 .apply_max_message_size_config(
515 max_decoding_message_size,
516 max_encoding_message_size,
517 );
518 let res = grpc.unary(method, req).await;
519 Ok(res)
520 };
521 Box::pin(fut)
522 }
523 _ => Box::pin(async move {
524 Ok(http::Response::builder()
525 .status(200)
526 .header("grpc-status", "12")
527 .header("content-type", "application/grpc")
528 .body(empty_body())
529 .unwrap())
530 }),
531 }
532 }
533 }
534 impl<T: Provisioner> Clone for ProvisionerServer<T> {
535 fn clone(&self) -> Self {
536 let inner = self.inner.clone();
537 Self {
538 inner,
539 accept_compression_encodings: self.accept_compression_encodings,
540 send_compression_encodings: self.send_compression_encodings,
541 max_decoding_message_size: self.max_decoding_message_size,
542 max_encoding_message_size: self.max_encoding_message_size,
543 }
544 }
545 }
546 impl<T: Provisioner> Clone for _Inner<T> {
547 fn clone(&self) -> Self {
548 Self(Arc::clone(&self.0))
549 }
550 }
551 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
552 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
553 write!(f, "{:?}", self.0)
554 }
555 }
556 impl<T: Provisioner> tonic::server::NamedService for ProvisionerServer<T> {
557 const NAME: &'static str = "provisioner.Provisioner";
558 }
559}