nominal_api/proto/
nominal.blob_storage_service.v1.rs

1// This file is @generated by prost-build.
2/// This is used to identify any type of blob that will be in object storage.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ResourceIdentifier {
5    #[prost(string, tag = "1")]
6    pub rid: ::prost::alloc::string::String,
7}
8/// file_name and owning_rid should be consistent across all requests for a byte stream
9/// permission on the uploaded blob is tied to associated owning_rid
10/// when making a call to upload stream request, the assumption is that the user already has
11/// auth on the owning_rid, and we will throw a permission error if this doesn't hold
12#[derive(Clone, PartialEq, ::prost::Message)]
13pub struct UploadBlobStreamRequest {
14    #[prost(message, optional, tag = "1")]
15    pub owning_rid: ::core::option::Option<ResourceIdentifier>,
16    #[prost(string, tag = "2")]
17    pub file_name: ::prost::alloc::string::String,
18    /// when set to true, ensure_unique will attach the current timestamp to the file name
19    /// this will ensure that we do not overwrite an existing file in blob storage
20    #[prost(bool, tag = "3")]
21    pub ensure_unique: bool,
22    #[prost(bytes = "vec", tag = "4")]
23    pub content: ::prost::alloc::vec::Vec<u8>,
24}
25#[derive(Clone, PartialEq, ::prost::Message)]
26pub struct UploadBlobStreamResponse {
27    /// This is the key that can be used in a retrieve blob request in order
28    /// to retrieve this specific blob. If ensure_unique is not set, this will match
29    /// the file name provided in UploadBlobStreamRequest
30    #[prost(string, tag = "1")]
31    pub file_name: ::prost::alloc::string::String,
32}
33#[derive(Clone, PartialEq, ::prost::Message)]
34pub struct GetSignedUrlForBlobRequest {
35    #[prost(message, optional, tag = "1")]
36    pub owning_rid: ::core::option::Option<ResourceIdentifier>,
37    #[prost(string, tag = "2")]
38    pub file_name: ::prost::alloc::string::String,
39}
40#[derive(Clone, PartialEq, ::prost::Message)]
41pub struct GetSignedUrlForBlobResponse {
42    /// This is a short lived signed url that can be used by the client to retrieve
43    /// the object
44    #[prost(string, tag = "1")]
45    pub url: ::prost::alloc::string::String,
46}
47/// Generated client implementations.
48pub mod blob_storage_service_client {
49    #![allow(
50        unused_variables,
51        dead_code,
52        missing_docs,
53        clippy::wildcard_imports,
54        clippy::let_unit_value,
55    )]
56    use tonic::codegen::*;
57    use tonic::codegen::http::Uri;
58    /// Service for storing and retrieving blobs in object storage with workspace-based authorization.
59    #[derive(Debug, Clone)]
60    pub struct BlobStorageServiceClient<T> {
61        inner: tonic::client::Grpc<T>,
62    }
63    impl BlobStorageServiceClient<tonic::transport::Channel> {
64        /// Attempt to create a new client by connecting to a given endpoint.
65        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
66        where
67            D: TryInto<tonic::transport::Endpoint>,
68            D::Error: Into<StdError>,
69        {
70            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
71            Ok(Self::new(conn))
72        }
73    }
74    impl<T> BlobStorageServiceClient<T>
75    where
76        T: tonic::client::GrpcService<tonic::body::Body>,
77        T::Error: Into<StdError>,
78        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
79        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
80    {
81        pub fn new(inner: T) -> Self {
82            let inner = tonic::client::Grpc::new(inner);
83            Self { inner }
84        }
85        pub fn with_origin(inner: T, origin: Uri) -> Self {
86            let inner = tonic::client::Grpc::with_origin(inner, origin);
87            Self { inner }
88        }
89        pub fn with_interceptor<F>(
90            inner: T,
91            interceptor: F,
92        ) -> BlobStorageServiceClient<InterceptedService<T, F>>
93        where
94            F: tonic::service::Interceptor,
95            T::ResponseBody: Default,
96            T: tonic::codegen::Service<
97                http::Request<tonic::body::Body>,
98                Response = http::Response<
99                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
100                >,
101            >,
102            <T as tonic::codegen::Service<
103                http::Request<tonic::body::Body>,
104            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
105        {
106            BlobStorageServiceClient::new(InterceptedService::new(inner, interceptor))
107        }
108        /// Compress requests with the given encoding.
109        ///
110        /// This requires the server to support it otherwise it might respond with an
111        /// error.
112        #[must_use]
113        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
114            self.inner = self.inner.send_compressed(encoding);
115            self
116        }
117        /// Enable decompressing responses.
118        #[must_use]
119        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
120            self.inner = self.inner.accept_compressed(encoding);
121            self
122        }
123        /// Limits the maximum size of a decoded message.
124        ///
125        /// Default: `4MB`
126        #[must_use]
127        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
128            self.inner = self.inner.max_decoding_message_size(limit);
129            self
130        }
131        /// Limits the maximum size of an encoded message.
132        ///
133        /// Default: `usize::MAX`
134        #[must_use]
135        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
136            self.inner = self.inner.max_encoding_message_size(limit);
137            self
138        }
139        /// Upload a blob using streaming. The blob will be stored with authorization checks
140        /// based on the provided owningRid.
141        pub async fn upload_blob_stream(
142            &mut self,
143            request: impl tonic::IntoStreamingRequest<
144                Message = super::UploadBlobStreamRequest,
145            >,
146        ) -> std::result::Result<
147            tonic::Response<super::UploadBlobStreamResponse>,
148            tonic::Status,
149        > {
150            self.inner
151                .ready()
152                .await
153                .map_err(|e| {
154                    tonic::Status::unknown(
155                        format!("Service was not ready: {}", e.into()),
156                    )
157                })?;
158            let codec = tonic::codec::ProstCodec::default();
159            let path = http::uri::PathAndQuery::from_static(
160                "/nominal.blob_storage_service.v1.BlobStorageService/UploadBlobStream",
161            );
162            let mut req = request.into_streaming_request();
163            req.extensions_mut()
164                .insert(
165                    GrpcMethod::new(
166                        "nominal.blob_storage_service.v1.BlobStorageService",
167                        "UploadBlobStream",
168                    ),
169                );
170            self.inner.client_streaming(req, path, codec).await
171        }
172        /// Retrieve a signed URL for downloading a blob. The URL is valid for 15 minutes.
173        pub async fn get_signed_url_for_blob(
174            &mut self,
175            request: impl tonic::IntoRequest<super::GetSignedUrlForBlobRequest>,
176        ) -> std::result::Result<
177            tonic::Response<super::GetSignedUrlForBlobResponse>,
178            tonic::Status,
179        > {
180            self.inner
181                .ready()
182                .await
183                .map_err(|e| {
184                    tonic::Status::unknown(
185                        format!("Service was not ready: {}", e.into()),
186                    )
187                })?;
188            let codec = tonic::codec::ProstCodec::default();
189            let path = http::uri::PathAndQuery::from_static(
190                "/nominal.blob_storage_service.v1.BlobStorageService/GetSignedUrlForBlob",
191            );
192            let mut req = request.into_request();
193            req.extensions_mut()
194                .insert(
195                    GrpcMethod::new(
196                        "nominal.blob_storage_service.v1.BlobStorageService",
197                        "GetSignedUrlForBlob",
198                    ),
199                );
200            self.inner.unary(req, path, codec).await
201        }
202    }
203}