nominal_api/proto/
nominal.authorization.roles.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct RoleAssignmentRequest {
4    #[prost(enumeration = "Role", tag = "1")]
5    pub role: i32,
6    /// The identity, eg a user, to which the role is assigned.
7    #[prost(oneof = "role_assignment_request::Assignee", tags = "2")]
8    pub assignee: ::core::option::Option<role_assignment_request::Assignee>,
9}
10/// Nested message and enum types in `RoleAssignmentRequest`.
11pub mod role_assignment_request {
12    /// The identity, eg a user, to which the role is assigned.
13    #[derive(Clone, PartialEq, ::prost::Oneof)]
14    pub enum Assignee {
15        #[prost(string, tag = "2")]
16        UserRid(::prost::alloc::string::String),
17    }
18}
19#[derive(Clone, PartialEq, ::prost::Message)]
20pub struct RoleAssignmentResponse {
21    #[prost(enumeration = "Role", tag = "1")]
22    pub role: i32,
23    /// The identity, eg a user, to which the role is assigned.
24    #[prost(oneof = "role_assignment_response::Assignee", tags = "2")]
25    pub assignee: ::core::option::Option<role_assignment_response::Assignee>,
26}
27/// Nested message and enum types in `RoleAssignmentResponse`.
28pub mod role_assignment_response {
29    /// The identity, eg a user, to which the role is assigned.
30    #[derive(Clone, PartialEq, ::prost::Oneof)]
31    pub enum Assignee {
32        #[prost(string, tag = "2")]
33        UserRid(::prost::alloc::string::String),
34    }
35}
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct UpdateResourceRolesRequest {
38    #[prost(string, tag = "1")]
39    pub resource: ::prost::alloc::string::String,
40    #[prost(message, repeated, tag = "2")]
41    pub assignments_to_add: ::prost::alloc::vec::Vec<RoleAssignmentRequest>,
42    #[prost(message, repeated, tag = "3")]
43    pub assignments_to_remove: ::prost::alloc::vec::Vec<RoleAssignmentRequest>,
44}
45/// Intentionally empty.
46#[derive(Clone, Copy, PartialEq, ::prost::Message)]
47pub struct UpdateResourceRolesResponse {}
48#[derive(Clone, PartialEq, ::prost::Message)]
49pub struct GetResourceRolesRequest {
50    #[prost(string, tag = "1")]
51    pub resource: ::prost::alloc::string::String,
52}
53#[derive(Clone, PartialEq, ::prost::Message)]
54pub struct GetResourceRolesResponse {
55    #[prost(message, repeated, tag = "1")]
56    pub role_assignments: ::prost::alloc::vec::Vec<RoleAssignmentResponse>,
57}
58#[derive(Clone, PartialEq, ::prost::Message)]
59pub struct BatchGetResourceRolesRequest {
60    #[prost(string, repeated, tag = "1")]
61    pub resources: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
62}
63#[derive(Clone, PartialEq, ::prost::Message)]
64pub struct BatchGetResourceRolesResponse {
65    #[prost(map = "string, message", tag = "1")]
66    pub role_assignments_by_resource: ::std::collections::HashMap<
67        ::prost::alloc::string::String,
68        batch_get_resource_roles_response::RoleAssignmentWrapper,
69    >,
70}
71/// Nested message and enum types in `BatchGetResourceRolesResponse`.
72pub mod batch_get_resource_roles_response {
73    #[derive(Clone, PartialEq, ::prost::Message)]
74    pub struct RoleAssignmentWrapper {
75        #[prost(message, repeated, tag = "1")]
76        pub role_assignments: ::prost::alloc::vec::Vec<super::RoleAssignmentResponse>,
77    }
78}
79#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
80#[repr(i32)]
81pub enum Role {
82    /// Default value, should not be used.
83    Unspecified = 0,
84    Owner = 1,
85}
86impl Role {
87    /// String value of the enum field names used in the ProtoBuf definition.
88    ///
89    /// The values are not transformed in any way and thus are considered stable
90    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
91    pub fn as_str_name(&self) -> &'static str {
92        match self {
93            Self::Unspecified => "ROLE_UNSPECIFIED",
94            Self::Owner => "ROLE_OWNER",
95        }
96    }
97    /// Creates an enum from field names used in the ProtoBuf definition.
98    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
99        match value {
100            "ROLE_UNSPECIFIED" => Some(Self::Unspecified),
101            "ROLE_OWNER" => Some(Self::Owner),
102            _ => None,
103        }
104    }
105}
106/// Generated client implementations.
107pub mod role_service_client {
108    #![allow(
109        unused_variables,
110        dead_code,
111        missing_docs,
112        clippy::wildcard_imports,
113        clippy::let_unit_value,
114    )]
115    use tonic::codegen::*;
116    use tonic::codegen::http::Uri;
117    /// RoleService provides methods for managing roles within Nominal.
118    #[derive(Debug, Clone)]
119    pub struct RoleServiceClient<T> {
120        inner: tonic::client::Grpc<T>,
121    }
122    impl RoleServiceClient<tonic::transport::Channel> {
123        /// Attempt to create a new client by connecting to a given endpoint.
124        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
125        where
126            D: TryInto<tonic::transport::Endpoint>,
127            D::Error: Into<StdError>,
128        {
129            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
130            Ok(Self::new(conn))
131        }
132    }
133    impl<T> RoleServiceClient<T>
134    where
135        T: tonic::client::GrpcService<tonic::body::Body>,
136        T::Error: Into<StdError>,
137        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
138        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
139    {
140        pub fn new(inner: T) -> Self {
141            let inner = tonic::client::Grpc::new(inner);
142            Self { inner }
143        }
144        pub fn with_origin(inner: T, origin: Uri) -> Self {
145            let inner = tonic::client::Grpc::with_origin(inner, origin);
146            Self { inner }
147        }
148        pub fn with_interceptor<F>(
149            inner: T,
150            interceptor: F,
151        ) -> RoleServiceClient<InterceptedService<T, F>>
152        where
153            F: tonic::service::Interceptor,
154            T::ResponseBody: Default,
155            T: tonic::codegen::Service<
156                http::Request<tonic::body::Body>,
157                Response = http::Response<
158                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
159                >,
160            >,
161            <T as tonic::codegen::Service<
162                http::Request<tonic::body::Body>,
163            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
164        {
165            RoleServiceClient::new(InterceptedService::new(inner, interceptor))
166        }
167        /// Compress requests with the given encoding.
168        ///
169        /// This requires the server to support it otherwise it might respond with an
170        /// error.
171        #[must_use]
172        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
173            self.inner = self.inner.send_compressed(encoding);
174            self
175        }
176        /// Enable decompressing responses.
177        #[must_use]
178        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
179            self.inner = self.inner.accept_compressed(encoding);
180            self
181        }
182        /// Limits the maximum size of a decoded message.
183        ///
184        /// Default: `4MB`
185        #[must_use]
186        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
187            self.inner = self.inner.max_decoding_message_size(limit);
188            self
189        }
190        /// Limits the maximum size of an encoded message.
191        ///
192        /// Default: `usize::MAX`
193        #[must_use]
194        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
195            self.inner = self.inner.max_encoding_message_size(limit);
196            self
197        }
198        /// Atomically adds and removes role assignments for a resource.
199        /// Throws if the same role assignment is both added and removed in the same request.
200        pub async fn update_resource_roles(
201            &mut self,
202            request: impl tonic::IntoRequest<super::UpdateResourceRolesRequest>,
203        ) -> std::result::Result<
204            tonic::Response<super::UpdateResourceRolesResponse>,
205            tonic::Status,
206        > {
207            self.inner
208                .ready()
209                .await
210                .map_err(|e| {
211                    tonic::Status::unknown(
212                        format!("Service was not ready: {}", e.into()),
213                    )
214                })?;
215            let codec = tonic::codec::ProstCodec::default();
216            let path = http::uri::PathAndQuery::from_static(
217                "/nominal.authorization.roles.v1.RoleService/UpdateResourceRoles",
218            );
219            let mut req = request.into_request();
220            req.extensions_mut()
221                .insert(
222                    GrpcMethod::new(
223                        "nominal.authorization.roles.v1.RoleService",
224                        "UpdateResourceRoles",
225                    ),
226                );
227            self.inner.unary(req, path, codec).await
228        }
229        /// Gets the role assignments for a resource.
230        pub async fn get_resource_roles(
231            &mut self,
232            request: impl tonic::IntoRequest<super::GetResourceRolesRequest>,
233        ) -> std::result::Result<
234            tonic::Response<super::GetResourceRolesResponse>,
235            tonic::Status,
236        > {
237            self.inner
238                .ready()
239                .await
240                .map_err(|e| {
241                    tonic::Status::unknown(
242                        format!("Service was not ready: {}", e.into()),
243                    )
244                })?;
245            let codec = tonic::codec::ProstCodec::default();
246            let path = http::uri::PathAndQuery::from_static(
247                "/nominal.authorization.roles.v1.RoleService/GetResourceRoles",
248            );
249            let mut req = request.into_request();
250            req.extensions_mut()
251                .insert(
252                    GrpcMethod::new(
253                        "nominal.authorization.roles.v1.RoleService",
254                        "GetResourceRoles",
255                    ),
256                );
257            self.inner.unary(req, path, codec).await
258        }
259        /// Gets the role assignments for multiple resources.
260        pub async fn batch_get_resource_roles(
261            &mut self,
262            request: impl tonic::IntoRequest<super::BatchGetResourceRolesRequest>,
263        ) -> std::result::Result<
264            tonic::Response<super::BatchGetResourceRolesResponse>,
265            tonic::Status,
266        > {
267            self.inner
268                .ready()
269                .await
270                .map_err(|e| {
271                    tonic::Status::unknown(
272                        format!("Service was not ready: {}", e.into()),
273                    )
274                })?;
275            let codec = tonic::codec::ProstCodec::default();
276            let path = http::uri::PathAndQuery::from_static(
277                "/nominal.authorization.roles.v1.RoleService/BatchGetResourceRoles",
278            );
279            let mut req = request.into_request();
280            req.extensions_mut()
281                .insert(
282                    GrpcMethod::new(
283                        "nominal.authorization.roles.v1.RoleService",
284                        "BatchGetResourceRoles",
285                    ),
286                );
287            self.inner.unary(req, path, codec).await
288        }
289    }
290}