1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct Subject {
4 #[prost(string, tag = "1")]
6 pub subject_id: ::prost::alloc::string::String,
7 #[prost(message, optional, tag = "2")]
9 pub claims: ::core::option::Option<::prost_types::Struct>,
10}
11#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
12pub struct ValidateCredentialRequest {
13 #[prost(string, tag = "1")]
16 pub credential: ::prost::alloc::string::String,
17}
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct ValidateCredentialResponse {
20 #[prost(enumeration = "validate_credential_response::Result", tag = "1")]
24 pub result: i32,
25 #[prost(message, optional, tag = "2")]
28 pub subject: ::core::option::Option<Subject>,
29}
30pub mod validate_credential_response {
32 #[derive(
33 Clone,
34 Copy,
35 Debug,
36 PartialEq,
37 Eq,
38 Hash,
39 PartialOrd,
40 Ord,
41 ::prost::Enumeration
42 )]
43 #[repr(i32)]
44 pub enum Result {
45 Valid = 0,
46 Invalid = 1,
47 }
48 impl Result {
49 pub fn as_str_name(&self) -> &'static str {
54 match self {
55 Self::Valid => "RESULT_VALID",
56 Self::Invalid => "RESULT_INVALID",
57 }
58 }
59 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
61 match value {
62 "RESULT_VALID" => Some(Self::Valid),
63 "RESULT_INVALID" => Some(Self::Invalid),
64 _ => None,
65 }
66 }
67 }
68}
69pub mod authentication_client {
71 #![allow(
72 unused_variables,
73 dead_code,
74 missing_docs,
75 clippy::wildcard_imports,
76 clippy::let_unit_value,
77 )]
78 use tonic::codegen::*;
79 use tonic::codegen::http::Uri;
80 #[derive(Debug, Clone)]
81 pub struct AuthenticationClient<T> {
82 inner: tonic::client::Grpc<T>,
83 }
84 impl AuthenticationClient<tonic::transport::Channel> {
85 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
87 where
88 D: TryInto<tonic::transport::Endpoint>,
89 D::Error: Into<StdError>,
90 {
91 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
92 Ok(Self::new(conn))
93 }
94 }
95 impl<T> AuthenticationClient<T>
96 where
97 T: tonic::client::GrpcService<tonic::body::Body>,
98 T::Error: Into<StdError>,
99 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
100 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
101 {
102 pub fn new(inner: T) -> Self {
103 let inner = tonic::client::Grpc::new(inner);
104 Self { inner }
105 }
106 pub fn with_origin(inner: T, origin: Uri) -> Self {
107 let inner = tonic::client::Grpc::with_origin(inner, origin);
108 Self { inner }
109 }
110 pub fn with_interceptor<F>(
111 inner: T,
112 interceptor: F,
113 ) -> AuthenticationClient<InterceptedService<T, F>>
114 where
115 F: tonic::service::Interceptor,
116 T::ResponseBody: Default,
117 T: tonic::codegen::Service<
118 http::Request<tonic::body::Body>,
119 Response = http::Response<
120 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
121 >,
122 >,
123 <T as tonic::codegen::Service<
124 http::Request<tonic::body::Body>,
125 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
126 {
127 AuthenticationClient::new(InterceptedService::new(inner, interceptor))
128 }
129 #[must_use]
134 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
135 self.inner = self.inner.send_compressed(encoding);
136 self
137 }
138 #[must_use]
140 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
141 self.inner = self.inner.accept_compressed(encoding);
142 self
143 }
144 #[must_use]
148 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
149 self.inner = self.inner.max_decoding_message_size(limit);
150 self
151 }
152 #[must_use]
156 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
157 self.inner = self.inner.max_encoding_message_size(limit);
158 self
159 }
160 pub async fn validate_credential(
161 &mut self,
162 request: impl tonic::IntoRequest<super::ValidateCredentialRequest>,
163 ) -> std::result::Result<
164 tonic::Response<super::ValidateCredentialResponse>,
165 tonic::Status,
166 > {
167 self.inner
168 .ready()
169 .await
170 .map_err(|e| {
171 tonic::Status::unknown(
172 format!("Service was not ready: {}", e.into()),
173 )
174 })?;
175 let codec = tonic_prost::ProstCodec::default();
176 let path = http::uri::PathAndQuery::from_static(
177 "/runtime.iam.v1.Authentication/ValidateCredential",
178 );
179 let mut req = request.into_request();
180 req.extensions_mut()
181 .insert(
182 GrpcMethod::new(
183 "runtime.iam.v1.Authentication",
184 "ValidateCredential",
185 ),
186 );
187 self.inner.unary(req, path, codec).await
188 }
189 }
190}
191pub mod authentication_server {
193 #![allow(
194 unused_variables,
195 dead_code,
196 missing_docs,
197 clippy::wildcard_imports,
198 clippy::let_unit_value,
199 )]
200 use tonic::codegen::*;
201 #[async_trait]
203 pub trait Authentication: std::marker::Send + std::marker::Sync + 'static {
204 async fn validate_credential(
205 &self,
206 request: tonic::Request<super::ValidateCredentialRequest>,
207 ) -> std::result::Result<
208 tonic::Response<super::ValidateCredentialResponse>,
209 tonic::Status,
210 >;
211 }
212 #[derive(Debug)]
213 pub struct AuthenticationServer<T> {
214 inner: Arc<T>,
215 accept_compression_encodings: EnabledCompressionEncodings,
216 send_compression_encodings: EnabledCompressionEncodings,
217 max_decoding_message_size: Option<usize>,
218 max_encoding_message_size: Option<usize>,
219 }
220 impl<T> AuthenticationServer<T> {
221 pub fn new(inner: T) -> Self {
222 Self::from_arc(Arc::new(inner))
223 }
224 pub fn from_arc(inner: Arc<T>) -> Self {
225 Self {
226 inner,
227 accept_compression_encodings: Default::default(),
228 send_compression_encodings: Default::default(),
229 max_decoding_message_size: None,
230 max_encoding_message_size: None,
231 }
232 }
233 pub fn with_interceptor<F>(
234 inner: T,
235 interceptor: F,
236 ) -> InterceptedService<Self, F>
237 where
238 F: tonic::service::Interceptor,
239 {
240 InterceptedService::new(Self::new(inner), interceptor)
241 }
242 #[must_use]
244 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
245 self.accept_compression_encodings.enable(encoding);
246 self
247 }
248 #[must_use]
250 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
251 self.send_compression_encodings.enable(encoding);
252 self
253 }
254 #[must_use]
258 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
259 self.max_decoding_message_size = Some(limit);
260 self
261 }
262 #[must_use]
266 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
267 self.max_encoding_message_size = Some(limit);
268 self
269 }
270 }
271 impl<T, B> tonic::codegen::Service<http::Request<B>> for AuthenticationServer<T>
272 where
273 T: Authentication,
274 B: Body + std::marker::Send + 'static,
275 B::Error: Into<StdError> + std::marker::Send + 'static,
276 {
277 type Response = http::Response<tonic::body::Body>;
278 type Error = std::convert::Infallible;
279 type Future = BoxFuture<Self::Response, Self::Error>;
280 fn poll_ready(
281 &mut self,
282 _cx: &mut Context<'_>,
283 ) -> Poll<std::result::Result<(), Self::Error>> {
284 Poll::Ready(Ok(()))
285 }
286 fn call(&mut self, req: http::Request<B>) -> Self::Future {
287 match req.uri().path() {
288 "/runtime.iam.v1.Authentication/ValidateCredential" => {
289 #[allow(non_camel_case_types)]
290 struct ValidateCredentialSvc<T: Authentication>(pub Arc<T>);
291 impl<
292 T: Authentication,
293 > tonic::server::UnaryService<super::ValidateCredentialRequest>
294 for ValidateCredentialSvc<T> {
295 type Response = super::ValidateCredentialResponse;
296 type Future = BoxFuture<
297 tonic::Response<Self::Response>,
298 tonic::Status,
299 >;
300 fn call(
301 &mut self,
302 request: tonic::Request<super::ValidateCredentialRequest>,
303 ) -> Self::Future {
304 let inner = Arc::clone(&self.0);
305 let fut = async move {
306 <T as Authentication>::validate_credential(&inner, request)
307 .await
308 };
309 Box::pin(fut)
310 }
311 }
312 let accept_compression_encodings = self.accept_compression_encodings;
313 let send_compression_encodings = self.send_compression_encodings;
314 let max_decoding_message_size = self.max_decoding_message_size;
315 let max_encoding_message_size = self.max_encoding_message_size;
316 let inner = self.inner.clone();
317 let fut = async move {
318 let method = ValidateCredentialSvc(inner);
319 let codec = tonic_prost::ProstCodec::default();
320 let mut grpc = tonic::server::Grpc::new(codec)
321 .apply_compression_config(
322 accept_compression_encodings,
323 send_compression_encodings,
324 )
325 .apply_max_message_size_config(
326 max_decoding_message_size,
327 max_encoding_message_size,
328 );
329 let res = grpc.unary(method, req).await;
330 Ok(res)
331 };
332 Box::pin(fut)
333 }
334 _ => {
335 Box::pin(async move {
336 let mut response = http::Response::new(
337 tonic::body::Body::default(),
338 );
339 let headers = response.headers_mut();
340 headers
341 .insert(
342 tonic::Status::GRPC_STATUS,
343 (tonic::Code::Unimplemented as i32).into(),
344 );
345 headers
346 .insert(
347 http::header::CONTENT_TYPE,
348 tonic::metadata::GRPC_CONTENT_TYPE,
349 );
350 Ok(response)
351 })
352 }
353 }
354 }
355 }
356 impl<T> Clone for AuthenticationServer<T> {
357 fn clone(&self) -> Self {
358 let inner = self.inner.clone();
359 Self {
360 inner,
361 accept_compression_encodings: self.accept_compression_encodings,
362 send_compression_encodings: self.send_compression_encodings,
363 max_decoding_message_size: self.max_decoding_message_size,
364 max_encoding_message_size: self.max_encoding_message_size,
365 }
366 }
367 }
368 pub const SERVICE_NAME: &str = "runtime.iam.v1.Authentication";
370 impl<T> tonic::server::NamedService for AuthenticationServer<T> {
371 const NAME: &'static str = SERVICE_NAME;
372 }
373}
374#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
375pub struct Relationship {
376 #[prost(string, tag = "1")]
378 pub relation: ::prost::alloc::string::String,
379 #[prost(string, tag = "2")]
381 pub subject_id: ::prost::alloc::string::String,
382}
383#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
384pub struct AccessRequestAction {
385 #[prost(string, tag = "1")]
387 pub action: ::prost::alloc::string::String,
388 #[prost(string, tag = "2")]
390 pub resource_id: ::prost::alloc::string::String,
391}
392#[derive(Clone, PartialEq, ::prost::Message)]
393pub struct CheckAccessRequest {
394 #[prost(string, tag = "1")]
397 pub credential: ::prost::alloc::string::String,
398 #[prost(message, repeated, tag = "2")]
401 pub actions: ::prost::alloc::vec::Vec<AccessRequestAction>,
402}
403#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
404pub struct CheckAccessResponse {
405 #[prost(enumeration = "check_access_response::Result", tag = "1")]
406 pub result: i32,
407}
408pub mod check_access_response {
410 #[derive(
411 Clone,
412 Copy,
413 Debug,
414 PartialEq,
415 Eq,
416 Hash,
417 PartialOrd,
418 Ord,
419 ::prost::Enumeration
420 )]
421 #[repr(i32)]
422 pub enum Result {
423 Allowed = 0,
424 Denied = 1,
425 }
426 impl Result {
427 pub fn as_str_name(&self) -> &'static str {
432 match self {
433 Self::Allowed => "RESULT_ALLOWED",
434 Self::Denied => "RESULT_DENIED",
435 }
436 }
437 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
439 match value {
440 "RESULT_ALLOWED" => Some(Self::Allowed),
441 "RESULT_DENIED" => Some(Self::Denied),
442 _ => None,
443 }
444 }
445 }
446}
447#[derive(Clone, PartialEq, ::prost::Message)]
448pub struct CreateRelationshipsRequest {
449 #[prost(string, tag = "1")]
451 pub resource_id: ::prost::alloc::string::String,
452 #[prost(message, repeated, tag = "2")]
454 pub relationships: ::prost::alloc::vec::Vec<Relationship>,
455}
456#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
457pub struct CreateRelationshipsResponse {}
458#[derive(Clone, PartialEq, ::prost::Message)]
459pub struct DeleteRelationshipsRequest {
460 #[prost(string, tag = "1")]
462 pub resource_id: ::prost::alloc::string::String,
463 #[prost(message, repeated, tag = "2")]
465 pub relationships: ::prost::alloc::vec::Vec<Relationship>,
466}
467#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
468pub struct DeleteRelationshipsResponse {}
469pub mod authorization_client {
471 #![allow(
472 unused_variables,
473 dead_code,
474 missing_docs,
475 clippy::wildcard_imports,
476 clippy::let_unit_value,
477 )]
478 use tonic::codegen::*;
479 use tonic::codegen::http::Uri;
480 #[derive(Debug, Clone)]
481 pub struct AuthorizationClient<T> {
482 inner: tonic::client::Grpc<T>,
483 }
484 impl AuthorizationClient<tonic::transport::Channel> {
485 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
487 where
488 D: TryInto<tonic::transport::Endpoint>,
489 D::Error: Into<StdError>,
490 {
491 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
492 Ok(Self::new(conn))
493 }
494 }
495 impl<T> AuthorizationClient<T>
496 where
497 T: tonic::client::GrpcService<tonic::body::Body>,
498 T::Error: Into<StdError>,
499 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
500 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
501 {
502 pub fn new(inner: T) -> Self {
503 let inner = tonic::client::Grpc::new(inner);
504 Self { inner }
505 }
506 pub fn with_origin(inner: T, origin: Uri) -> Self {
507 let inner = tonic::client::Grpc::with_origin(inner, origin);
508 Self { inner }
509 }
510 pub fn with_interceptor<F>(
511 inner: T,
512 interceptor: F,
513 ) -> AuthorizationClient<InterceptedService<T, F>>
514 where
515 F: tonic::service::Interceptor,
516 T::ResponseBody: Default,
517 T: tonic::codegen::Service<
518 http::Request<tonic::body::Body>,
519 Response = http::Response<
520 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
521 >,
522 >,
523 <T as tonic::codegen::Service<
524 http::Request<tonic::body::Body>,
525 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
526 {
527 AuthorizationClient::new(InterceptedService::new(inner, interceptor))
528 }
529 #[must_use]
534 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
535 self.inner = self.inner.send_compressed(encoding);
536 self
537 }
538 #[must_use]
540 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
541 self.inner = self.inner.accept_compressed(encoding);
542 self
543 }
544 #[must_use]
548 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
549 self.inner = self.inner.max_decoding_message_size(limit);
550 self
551 }
552 #[must_use]
556 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
557 self.inner = self.inner.max_encoding_message_size(limit);
558 self
559 }
560 pub async fn check_access(
561 &mut self,
562 request: impl tonic::IntoRequest<super::CheckAccessRequest>,
563 ) -> std::result::Result<
564 tonic::Response<super::CheckAccessResponse>,
565 tonic::Status,
566 > {
567 self.inner
568 .ready()
569 .await
570 .map_err(|e| {
571 tonic::Status::unknown(
572 format!("Service was not ready: {}", e.into()),
573 )
574 })?;
575 let codec = tonic_prost::ProstCodec::default();
576 let path = http::uri::PathAndQuery::from_static(
577 "/runtime.iam.v1.Authorization/CheckAccess",
578 );
579 let mut req = request.into_request();
580 req.extensions_mut()
581 .insert(GrpcMethod::new("runtime.iam.v1.Authorization", "CheckAccess"));
582 self.inner.unary(req, path, codec).await
583 }
584 pub async fn create_relationships(
585 &mut self,
586 request: impl tonic::IntoRequest<super::CreateRelationshipsRequest>,
587 ) -> std::result::Result<
588 tonic::Response<super::CreateRelationshipsResponse>,
589 tonic::Status,
590 > {
591 self.inner
592 .ready()
593 .await
594 .map_err(|e| {
595 tonic::Status::unknown(
596 format!("Service was not ready: {}", e.into()),
597 )
598 })?;
599 let codec = tonic_prost::ProstCodec::default();
600 let path = http::uri::PathAndQuery::from_static(
601 "/runtime.iam.v1.Authorization/CreateRelationships",
602 );
603 let mut req = request.into_request();
604 req.extensions_mut()
605 .insert(
606 GrpcMethod::new(
607 "runtime.iam.v1.Authorization",
608 "CreateRelationships",
609 ),
610 );
611 self.inner.unary(req, path, codec).await
612 }
613 pub async fn delete_relationships(
614 &mut self,
615 request: impl tonic::IntoRequest<super::DeleteRelationshipsRequest>,
616 ) -> std::result::Result<
617 tonic::Response<super::DeleteRelationshipsResponse>,
618 tonic::Status,
619 > {
620 self.inner
621 .ready()
622 .await
623 .map_err(|e| {
624 tonic::Status::unknown(
625 format!("Service was not ready: {}", e.into()),
626 )
627 })?;
628 let codec = tonic_prost::ProstCodec::default();
629 let path = http::uri::PathAndQuery::from_static(
630 "/runtime.iam.v1.Authorization/DeleteRelationships",
631 );
632 let mut req = request.into_request();
633 req.extensions_mut()
634 .insert(
635 GrpcMethod::new(
636 "runtime.iam.v1.Authorization",
637 "DeleteRelationships",
638 ),
639 );
640 self.inner.unary(req, path, codec).await
641 }
642 }
643}
644pub mod authorization_server {
646 #![allow(
647 unused_variables,
648 dead_code,
649 missing_docs,
650 clippy::wildcard_imports,
651 clippy::let_unit_value,
652 )]
653 use tonic::codegen::*;
654 #[async_trait]
656 pub trait Authorization: std::marker::Send + std::marker::Sync + 'static {
657 async fn check_access(
658 &self,
659 request: tonic::Request<super::CheckAccessRequest>,
660 ) -> std::result::Result<
661 tonic::Response<super::CheckAccessResponse>,
662 tonic::Status,
663 >;
664 async fn create_relationships(
665 &self,
666 request: tonic::Request<super::CreateRelationshipsRequest>,
667 ) -> std::result::Result<
668 tonic::Response<super::CreateRelationshipsResponse>,
669 tonic::Status,
670 >;
671 async fn delete_relationships(
672 &self,
673 request: tonic::Request<super::DeleteRelationshipsRequest>,
674 ) -> std::result::Result<
675 tonic::Response<super::DeleteRelationshipsResponse>,
676 tonic::Status,
677 >;
678 }
679 #[derive(Debug)]
680 pub struct AuthorizationServer<T> {
681 inner: Arc<T>,
682 accept_compression_encodings: EnabledCompressionEncodings,
683 send_compression_encodings: EnabledCompressionEncodings,
684 max_decoding_message_size: Option<usize>,
685 max_encoding_message_size: Option<usize>,
686 }
687 impl<T> AuthorizationServer<T> {
688 pub fn new(inner: T) -> Self {
689 Self::from_arc(Arc::new(inner))
690 }
691 pub fn from_arc(inner: Arc<T>) -> Self {
692 Self {
693 inner,
694 accept_compression_encodings: Default::default(),
695 send_compression_encodings: Default::default(),
696 max_decoding_message_size: None,
697 max_encoding_message_size: None,
698 }
699 }
700 pub fn with_interceptor<F>(
701 inner: T,
702 interceptor: F,
703 ) -> InterceptedService<Self, F>
704 where
705 F: tonic::service::Interceptor,
706 {
707 InterceptedService::new(Self::new(inner), interceptor)
708 }
709 #[must_use]
711 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
712 self.accept_compression_encodings.enable(encoding);
713 self
714 }
715 #[must_use]
717 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
718 self.send_compression_encodings.enable(encoding);
719 self
720 }
721 #[must_use]
725 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
726 self.max_decoding_message_size = Some(limit);
727 self
728 }
729 #[must_use]
733 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
734 self.max_encoding_message_size = Some(limit);
735 self
736 }
737 }
738 impl<T, B> tonic::codegen::Service<http::Request<B>> for AuthorizationServer<T>
739 where
740 T: Authorization,
741 B: Body + std::marker::Send + 'static,
742 B::Error: Into<StdError> + std::marker::Send + 'static,
743 {
744 type Response = http::Response<tonic::body::Body>;
745 type Error = std::convert::Infallible;
746 type Future = BoxFuture<Self::Response, Self::Error>;
747 fn poll_ready(
748 &mut self,
749 _cx: &mut Context<'_>,
750 ) -> Poll<std::result::Result<(), Self::Error>> {
751 Poll::Ready(Ok(()))
752 }
753 fn call(&mut self, req: http::Request<B>) -> Self::Future {
754 match req.uri().path() {
755 "/runtime.iam.v1.Authorization/CheckAccess" => {
756 #[allow(non_camel_case_types)]
757 struct CheckAccessSvc<T: Authorization>(pub Arc<T>);
758 impl<
759 T: Authorization,
760 > tonic::server::UnaryService<super::CheckAccessRequest>
761 for CheckAccessSvc<T> {
762 type Response = super::CheckAccessResponse;
763 type Future = BoxFuture<
764 tonic::Response<Self::Response>,
765 tonic::Status,
766 >;
767 fn call(
768 &mut self,
769 request: tonic::Request<super::CheckAccessRequest>,
770 ) -> Self::Future {
771 let inner = Arc::clone(&self.0);
772 let fut = async move {
773 <T as Authorization>::check_access(&inner, request).await
774 };
775 Box::pin(fut)
776 }
777 }
778 let accept_compression_encodings = self.accept_compression_encodings;
779 let send_compression_encodings = self.send_compression_encodings;
780 let max_decoding_message_size = self.max_decoding_message_size;
781 let max_encoding_message_size = self.max_encoding_message_size;
782 let inner = self.inner.clone();
783 let fut = async move {
784 let method = CheckAccessSvc(inner);
785 let codec = tonic_prost::ProstCodec::default();
786 let mut grpc = tonic::server::Grpc::new(codec)
787 .apply_compression_config(
788 accept_compression_encodings,
789 send_compression_encodings,
790 )
791 .apply_max_message_size_config(
792 max_decoding_message_size,
793 max_encoding_message_size,
794 );
795 let res = grpc.unary(method, req).await;
796 Ok(res)
797 };
798 Box::pin(fut)
799 }
800 "/runtime.iam.v1.Authorization/CreateRelationships" => {
801 #[allow(non_camel_case_types)]
802 struct CreateRelationshipsSvc<T: Authorization>(pub Arc<T>);
803 impl<
804 T: Authorization,
805 > tonic::server::UnaryService<super::CreateRelationshipsRequest>
806 for CreateRelationshipsSvc<T> {
807 type Response = super::CreateRelationshipsResponse;
808 type Future = BoxFuture<
809 tonic::Response<Self::Response>,
810 tonic::Status,
811 >;
812 fn call(
813 &mut self,
814 request: tonic::Request<super::CreateRelationshipsRequest>,
815 ) -> Self::Future {
816 let inner = Arc::clone(&self.0);
817 let fut = async move {
818 <T as Authorization>::create_relationships(&inner, request)
819 .await
820 };
821 Box::pin(fut)
822 }
823 }
824 let accept_compression_encodings = self.accept_compression_encodings;
825 let send_compression_encodings = self.send_compression_encodings;
826 let max_decoding_message_size = self.max_decoding_message_size;
827 let max_encoding_message_size = self.max_encoding_message_size;
828 let inner = self.inner.clone();
829 let fut = async move {
830 let method = CreateRelationshipsSvc(inner);
831 let codec = tonic_prost::ProstCodec::default();
832 let mut grpc = tonic::server::Grpc::new(codec)
833 .apply_compression_config(
834 accept_compression_encodings,
835 send_compression_encodings,
836 )
837 .apply_max_message_size_config(
838 max_decoding_message_size,
839 max_encoding_message_size,
840 );
841 let res = grpc.unary(method, req).await;
842 Ok(res)
843 };
844 Box::pin(fut)
845 }
846 "/runtime.iam.v1.Authorization/DeleteRelationships" => {
847 #[allow(non_camel_case_types)]
848 struct DeleteRelationshipsSvc<T: Authorization>(pub Arc<T>);
849 impl<
850 T: Authorization,
851 > tonic::server::UnaryService<super::DeleteRelationshipsRequest>
852 for DeleteRelationshipsSvc<T> {
853 type Response = super::DeleteRelationshipsResponse;
854 type Future = BoxFuture<
855 tonic::Response<Self::Response>,
856 tonic::Status,
857 >;
858 fn call(
859 &mut self,
860 request: tonic::Request<super::DeleteRelationshipsRequest>,
861 ) -> Self::Future {
862 let inner = Arc::clone(&self.0);
863 let fut = async move {
864 <T as Authorization>::delete_relationships(&inner, request)
865 .await
866 };
867 Box::pin(fut)
868 }
869 }
870 let accept_compression_encodings = self.accept_compression_encodings;
871 let send_compression_encodings = self.send_compression_encodings;
872 let max_decoding_message_size = self.max_decoding_message_size;
873 let max_encoding_message_size = self.max_encoding_message_size;
874 let inner = self.inner.clone();
875 let fut = async move {
876 let method = DeleteRelationshipsSvc(inner);
877 let codec = tonic_prost::ProstCodec::default();
878 let mut grpc = tonic::server::Grpc::new(codec)
879 .apply_compression_config(
880 accept_compression_encodings,
881 send_compression_encodings,
882 )
883 .apply_max_message_size_config(
884 max_decoding_message_size,
885 max_encoding_message_size,
886 );
887 let res = grpc.unary(method, req).await;
888 Ok(res)
889 };
890 Box::pin(fut)
891 }
892 _ => {
893 Box::pin(async move {
894 let mut response = http::Response::new(
895 tonic::body::Body::default(),
896 );
897 let headers = response.headers_mut();
898 headers
899 .insert(
900 tonic::Status::GRPC_STATUS,
901 (tonic::Code::Unimplemented as i32).into(),
902 );
903 headers
904 .insert(
905 http::header::CONTENT_TYPE,
906 tonic::metadata::GRPC_CONTENT_TYPE,
907 );
908 Ok(response)
909 })
910 }
911 }
912 }
913 }
914 impl<T> Clone for AuthorizationServer<T> {
915 fn clone(&self) -> Self {
916 let inner = self.inner.clone();
917 Self {
918 inner,
919 accept_compression_encodings: self.accept_compression_encodings,
920 send_compression_encodings: self.send_compression_encodings,
921 max_decoding_message_size: self.max_decoding_message_size,
922 max_encoding_message_size: self.max_encoding_message_size,
923 }
924 }
925 }
926 pub const SERVICE_NAME: &str = "runtime.iam.v1.Authorization";
928 impl<T> tonic::server::NamedService for AuthorizationServer<T> {
929 const NAME: &'static str = SERVICE_NAME;
930 }
931}
932#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
933pub struct GetAccessTokenRequest {}
934#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
935pub struct GetAccessTokenResponse {
936 #[prost(string, tag = "1")]
938 pub token: ::prost::alloc::string::String,
939}
940pub mod identity_client {
942 #![allow(
943 unused_variables,
944 dead_code,
945 missing_docs,
946 clippy::wildcard_imports,
947 clippy::let_unit_value,
948 )]
949 use tonic::codegen::*;
950 use tonic::codegen::http::Uri;
951 #[derive(Debug, Clone)]
952 pub struct IdentityClient<T> {
953 inner: tonic::client::Grpc<T>,
954 }
955 impl IdentityClient<tonic::transport::Channel> {
956 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
958 where
959 D: TryInto<tonic::transport::Endpoint>,
960 D::Error: Into<StdError>,
961 {
962 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
963 Ok(Self::new(conn))
964 }
965 }
966 impl<T> IdentityClient<T>
967 where
968 T: tonic::client::GrpcService<tonic::body::Body>,
969 T::Error: Into<StdError>,
970 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
971 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
972 {
973 pub fn new(inner: T) -> Self {
974 let inner = tonic::client::Grpc::new(inner);
975 Self { inner }
976 }
977 pub fn with_origin(inner: T, origin: Uri) -> Self {
978 let inner = tonic::client::Grpc::with_origin(inner, origin);
979 Self { inner }
980 }
981 pub fn with_interceptor<F>(
982 inner: T,
983 interceptor: F,
984 ) -> IdentityClient<InterceptedService<T, F>>
985 where
986 F: tonic::service::Interceptor,
987 T::ResponseBody: Default,
988 T: tonic::codegen::Service<
989 http::Request<tonic::body::Body>,
990 Response = http::Response<
991 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
992 >,
993 >,
994 <T as tonic::codegen::Service<
995 http::Request<tonic::body::Body>,
996 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
997 {
998 IdentityClient::new(InterceptedService::new(inner, interceptor))
999 }
1000 #[must_use]
1005 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1006 self.inner = self.inner.send_compressed(encoding);
1007 self
1008 }
1009 #[must_use]
1011 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1012 self.inner = self.inner.accept_compressed(encoding);
1013 self
1014 }
1015 #[must_use]
1019 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1020 self.inner = self.inner.max_decoding_message_size(limit);
1021 self
1022 }
1023 #[must_use]
1027 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1028 self.inner = self.inner.max_encoding_message_size(limit);
1029 self
1030 }
1031 pub async fn get_access_token(
1032 &mut self,
1033 request: impl tonic::IntoRequest<super::GetAccessTokenRequest>,
1034 ) -> std::result::Result<
1035 tonic::Response<super::GetAccessTokenResponse>,
1036 tonic::Status,
1037 > {
1038 self.inner
1039 .ready()
1040 .await
1041 .map_err(|e| {
1042 tonic::Status::unknown(
1043 format!("Service was not ready: {}", e.into()),
1044 )
1045 })?;
1046 let codec = tonic_prost::ProstCodec::default();
1047 let path = http::uri::PathAndQuery::from_static(
1048 "/runtime.iam.v1.Identity/GetAccessToken",
1049 );
1050 let mut req = request.into_request();
1051 req.extensions_mut()
1052 .insert(GrpcMethod::new("runtime.iam.v1.Identity", "GetAccessToken"));
1053 self.inner.unary(req, path, codec).await
1054 }
1055 }
1056}
1057pub mod identity_server {
1059 #![allow(
1060 unused_variables,
1061 dead_code,
1062 missing_docs,
1063 clippy::wildcard_imports,
1064 clippy::let_unit_value,
1065 )]
1066 use tonic::codegen::*;
1067 #[async_trait]
1069 pub trait Identity: std::marker::Send + std::marker::Sync + 'static {
1070 async fn get_access_token(
1071 &self,
1072 request: tonic::Request<super::GetAccessTokenRequest>,
1073 ) -> std::result::Result<
1074 tonic::Response<super::GetAccessTokenResponse>,
1075 tonic::Status,
1076 >;
1077 }
1078 #[derive(Debug)]
1079 pub struct IdentityServer<T> {
1080 inner: Arc<T>,
1081 accept_compression_encodings: EnabledCompressionEncodings,
1082 send_compression_encodings: EnabledCompressionEncodings,
1083 max_decoding_message_size: Option<usize>,
1084 max_encoding_message_size: Option<usize>,
1085 }
1086 impl<T> IdentityServer<T> {
1087 pub fn new(inner: T) -> Self {
1088 Self::from_arc(Arc::new(inner))
1089 }
1090 pub fn from_arc(inner: Arc<T>) -> Self {
1091 Self {
1092 inner,
1093 accept_compression_encodings: Default::default(),
1094 send_compression_encodings: Default::default(),
1095 max_decoding_message_size: None,
1096 max_encoding_message_size: None,
1097 }
1098 }
1099 pub fn with_interceptor<F>(
1100 inner: T,
1101 interceptor: F,
1102 ) -> InterceptedService<Self, F>
1103 where
1104 F: tonic::service::Interceptor,
1105 {
1106 InterceptedService::new(Self::new(inner), interceptor)
1107 }
1108 #[must_use]
1110 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1111 self.accept_compression_encodings.enable(encoding);
1112 self
1113 }
1114 #[must_use]
1116 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1117 self.send_compression_encodings.enable(encoding);
1118 self
1119 }
1120 #[must_use]
1124 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1125 self.max_decoding_message_size = Some(limit);
1126 self
1127 }
1128 #[must_use]
1132 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1133 self.max_encoding_message_size = Some(limit);
1134 self
1135 }
1136 }
1137 impl<T, B> tonic::codegen::Service<http::Request<B>> for IdentityServer<T>
1138 where
1139 T: Identity,
1140 B: Body + std::marker::Send + 'static,
1141 B::Error: Into<StdError> + std::marker::Send + 'static,
1142 {
1143 type Response = http::Response<tonic::body::Body>;
1144 type Error = std::convert::Infallible;
1145 type Future = BoxFuture<Self::Response, Self::Error>;
1146 fn poll_ready(
1147 &mut self,
1148 _cx: &mut Context<'_>,
1149 ) -> Poll<std::result::Result<(), Self::Error>> {
1150 Poll::Ready(Ok(()))
1151 }
1152 fn call(&mut self, req: http::Request<B>) -> Self::Future {
1153 match req.uri().path() {
1154 "/runtime.iam.v1.Identity/GetAccessToken" => {
1155 #[allow(non_camel_case_types)]
1156 struct GetAccessTokenSvc<T: Identity>(pub Arc<T>);
1157 impl<
1158 T: Identity,
1159 > tonic::server::UnaryService<super::GetAccessTokenRequest>
1160 for GetAccessTokenSvc<T> {
1161 type Response = super::GetAccessTokenResponse;
1162 type Future = BoxFuture<
1163 tonic::Response<Self::Response>,
1164 tonic::Status,
1165 >;
1166 fn call(
1167 &mut self,
1168 request: tonic::Request<super::GetAccessTokenRequest>,
1169 ) -> Self::Future {
1170 let inner = Arc::clone(&self.0);
1171 let fut = async move {
1172 <T as Identity>::get_access_token(&inner, request).await
1173 };
1174 Box::pin(fut)
1175 }
1176 }
1177 let accept_compression_encodings = self.accept_compression_encodings;
1178 let send_compression_encodings = self.send_compression_encodings;
1179 let max_decoding_message_size = self.max_decoding_message_size;
1180 let max_encoding_message_size = self.max_encoding_message_size;
1181 let inner = self.inner.clone();
1182 let fut = async move {
1183 let method = GetAccessTokenSvc(inner);
1184 let codec = tonic_prost::ProstCodec::default();
1185 let mut grpc = tonic::server::Grpc::new(codec)
1186 .apply_compression_config(
1187 accept_compression_encodings,
1188 send_compression_encodings,
1189 )
1190 .apply_max_message_size_config(
1191 max_decoding_message_size,
1192 max_encoding_message_size,
1193 );
1194 let res = grpc.unary(method, req).await;
1195 Ok(res)
1196 };
1197 Box::pin(fut)
1198 }
1199 _ => {
1200 Box::pin(async move {
1201 let mut response = http::Response::new(
1202 tonic::body::Body::default(),
1203 );
1204 let headers = response.headers_mut();
1205 headers
1206 .insert(
1207 tonic::Status::GRPC_STATUS,
1208 (tonic::Code::Unimplemented as i32).into(),
1209 );
1210 headers
1211 .insert(
1212 http::header::CONTENT_TYPE,
1213 tonic::metadata::GRPC_CONTENT_TYPE,
1214 );
1215 Ok(response)
1216 })
1217 }
1218 }
1219 }
1220 }
1221 impl<T> Clone for IdentityServer<T> {
1222 fn clone(&self) -> Self {
1223 let inner = self.inner.clone();
1224 Self {
1225 inner,
1226 accept_compression_encodings: self.accept_compression_encodings,
1227 send_compression_encodings: self.send_compression_encodings,
1228 max_decoding_message_size: self.max_decoding_message_size,
1229 max_encoding_message_size: self.max_encoding_message_size,
1230 }
1231 }
1232 }
1233 pub const SERVICE_NAME: &str = "runtime.iam.v1.Identity";
1235 impl<T> tonic::server::NamedService for IdentityServer<T> {
1236 const NAME: &'static str = SERVICE_NAME;
1237 }
1238}