gcloud-sdk 0.30.1

Async Google gRPC/REST APIs and the client implementation hiding complexity of GCP authentication based on Tonic middleware and Reqwest.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
// This file is @generated by prost-build.
/// A Document represents a piece of content from the Developer Knowledge corpus.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Document {
    /// Identifier. Contains the resource name of the document.
    /// Format: `documents/{uri_without_scheme}`
    /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Output only. Provides the URI of the content, such as
    /// `docs.cloud.google.com/storage/docs/creating-buckets`.
    #[prost(string, tag = "2")]
    pub uri: ::prost::alloc::string::String,
    /// Output only. Contains the full content of the document in Markdown format.
    #[prost(string, tag = "3")]
    pub content: ::prost::alloc::string::String,
    /// Output only. Provides a description of the document.
    #[prost(string, tag = "4")]
    pub description: ::prost::alloc::string::String,
    /// Output only. Specifies the data source of the document.
    /// Example data source: `firebase.google.com`
    #[prost(string, tag = "5")]
    pub data_source: ::prost::alloc::string::String,
    /// Output only. Provides the title of the document.
    #[prost(string, tag = "6")]
    pub title: ::prost::alloc::string::String,
    /// Output only. Represents the timestamp when the content or metadata of the
    /// document was last updated.
    #[prost(message, optional, tag = "7")]
    pub update_time: ::core::option::Option<::prost_types::Timestamp>,
    /// Output only. Specifies the
    /// \[DocumentView\]\[google.developers.knowledge.v1.DocumentView\] of the
    /// document.
    #[prost(enumeration = "DocumentView", tag = "8")]
    pub view: i32,
}
/// Request message for
/// \[DeveloperKnowledge.SearchDocumentChunks\]\[google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks\].
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SearchDocumentChunksRequest {
    /// Required. Provides the raw query string provided by the user, such as "How
    /// to create a Cloud Storage bucket?".
    #[prost(string, tag = "1")]
    pub query: ::prost::alloc::string::String,
    /// Optional. Specifies the maximum number of results to return. The service
    /// may return fewer than this value.
    ///
    /// If unspecified, at most 5 results will be returned.
    ///
    /// The maximum value is 20; values above 20 will result in an INVALID_ARGUMENT
    /// error.
    #[prost(int32, tag = "2")]
    pub page_size: i32,
    /// Optional. Contains a page token, received from a previous
    /// `SearchDocumentChunks` call. Provide this to retrieve the subsequent page.
    #[prost(string, tag = "3")]
    pub page_token: ::prost::alloc::string::String,
    /// Optional. Applies a strict filter to the search results. The expression
    /// supports a subset of the syntax described at <https://google.aip.dev/160.>
    ///
    /// While `SearchDocumentChunks` returns
    /// \[DocumentChunk\]\[google.developers.knowledge.v1.DocumentChunk\]s, the filter
    /// is applied to `DocumentChunk.document` fields.
    ///
    /// Supported fields for filtering:
    ///
    /// * `data_source` (STRING): The source of the document, e.g.
    ///   `docs.cloud.google.com`. See
    ///   <https://developers.google.com/knowledge/reference/corpus-reference> for
    ///   the complete list of data sources in the corpus.
    /// * `update_time` (TIMESTAMP): The timestamp of when the document was last
    ///   meaningfully updated. A meaningful update is one that changes document's
    ///   markdown content or metadata.
    /// * `uri` (STRING): The document URI, e.g.
    ///   `<https://docs.cloud.google.com/bigquery/docs/tables`.>
    ///
    /// STRING fields support `=` (equals) and `!=` (not equals) operators for
    /// **exact match** on the whole string. Partial match, prefix match, and
    /// regexp match are not supported.
    ///
    /// TIMESTAMP fields support `=`, `<`, `<=`, `>`, and `>=` operators.
    /// Timestamps must be in RFC-3339 format, e.g., `"2025-01-01T00:00:00Z"`.
    ///
    /// You can combine expressions using `AND`, `OR`, and `NOT` (or `-`) logical
    /// operators. `OR` has higher precedence than `AND`. Use parentheses for
    /// explicit precedence grouping.
    ///
    /// Examples:
    ///
    /// * `data_source = "docs.cloud.google.com" OR data_source =  "firebase.google.com"`
    /// * `data_source != "firebase.google.com"`
    /// * `update_time < "2024-01-01T00:00:00Z"`
    /// * `update_time >= "2025-01-22T00:00:00Z" AND (data_source =  "developer.chrome.com" OR data_source = "web.dev")`
    /// * `uri = "<https://docs.cloud.google.com/release-notes"`>
    ///
    /// The `filter` string must not exceed 500 characters; values longer than 500
    /// characters will result in an `INVALID_ARGUMENT` error.
    #[prost(string, tag = "4")]
    pub filter: ::prost::alloc::string::String,
}
/// Response message for
/// \[DeveloperKnowledge.SearchDocumentChunks\]\[google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks\].
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchDocumentChunksResponse {
    /// Contains the search results for the given query. Each
    /// \[DocumentChunk\]\[google.developers.knowledge.v1.DocumentChunk\] in this list
    /// contains a snippet of content relevant to the search query. Use the
    /// \[DocumentChunk.parent\]\[google.developers.knowledge.v1.DocumentChunk.parent\]
    /// field of each result with
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// or
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
    /// to retrieve the full document content.
    #[prost(message, repeated, tag = "1")]
    pub results: ::prost::alloc::vec::Vec<DocumentChunk>,
    /// Optional. Provides a token that can be sent as `page_token` to retrieve the
    /// next page. If this field is omitted, there are no subsequent pages.
    #[prost(string, tag = "2")]
    pub next_page_token: ::prost::alloc::string::String,
}
/// Request message for
/// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\].
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetDocumentRequest {
    /// Required. Specifies the name of the document to retrieve.
    /// Format: `documents/{uri_without_scheme}`
    /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Optional. Specifies the
    /// \[DocumentView\]\[google.developers.knowledge.v1.DocumentView\] of the
    /// document. If unspecified,
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// defaults to `DOCUMENT_VIEW_CONTENT`.
    #[prost(enumeration = "DocumentView", tag = "2")]
    pub view: i32,
}
/// Request message for
/// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\].
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BatchGetDocumentsRequest {
    /// Required. Specifies the names of the documents to retrieve. A maximum of 20
    /// documents can be retrieved in a batch. The documents are returned in the
    /// same order as the `names` in the request.
    ///
    /// Format: `documents/{uri_without_scheme}`
    /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
    #[prost(string, repeated, tag = "1")]
    pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Optional. Specifies the
    /// \[DocumentView\]\[google.developers.knowledge.v1.DocumentView\] of the
    /// document. If unspecified,
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
    /// defaults to `DOCUMENT_VIEW_CONTENT`.
    #[prost(enumeration = "DocumentView", tag = "2")]
    pub view: i32,
}
/// Response message for
/// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\].
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchGetDocumentsResponse {
    /// Contains the documents requested.
    #[prost(message, repeated, tag = "1")]
    pub documents: ::prost::alloc::vec::Vec<Document>,
}
/// A DocumentChunk represents a piece of content from a
/// \[Document\]\[google.developers.knowledge.v1.Document\] in the DeveloperKnowledge
/// corpus. To fetch the entire document content, pass the `parent` to
/// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
/// or
/// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\].
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DocumentChunk {
    /// Output only. Contains the resource name of the document this chunk is from.
    /// Format: `documents/{uri_without_scheme}`
    /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Output only. Specifies the ID of this chunk within the document. The chunk
    /// ID is unique within a document, but not globally unique across documents.
    /// The chunk ID is not stable and may change over time.
    #[prost(string, tag = "2")]
    pub id: ::prost::alloc::string::String,
    /// Output only. Contains the content of the document chunk.
    #[prost(string, tag = "3")]
    pub content: ::prost::alloc::string::String,
    /// Output only. Represents metadata about the
    /// \[Document\]\[google.developers.knowledge.v1.Document\] this chunk is from. The
    /// \[DocumentView\]\[google.developers.knowledge.v1.DocumentView\] of this
    /// \[Document\]\[google.developers.knowledge.v1.Document\] message will be set to
    /// `DOCUMENT_VIEW_BASIC`. It is included here for convenience so that clients
    /// do not need to call
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// or
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
    /// if they only need the metadata fields. Otherwise, clients should use
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// or
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
    /// to fetch the full document content.
    #[prost(message, optional, tag = "4")]
    pub document: ::core::option::Option<Document>,
}
/// Specifies which fields of the
/// \[Document\]\[google.developers.knowledge.v1.Document\] are included.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DocumentView {
    /// The default / unset value. See each API method for its default value if
    /// \[DocumentView\]\[google.developers.knowledge.v1.DocumentView\] is not
    /// specified.
    Unspecified = 0,
    /// Includes only the basic metadata fields:
    ///
    /// * `name`
    /// * `uri`
    /// * `data_source`
    /// * `title`
    /// * `description`
    /// * `update_time`
    /// * `view`
    ///
    /// This is the default of view for
    /// \[DeveloperKnowledge.SearchDocumentChunks\]\[google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks\].
    Basic = 1,
    /// Includes all \[Document\]\[google.developers.knowledge.v1.Document\] fields.
    Full = 2,
    /// Includes the `DOCUMENT_VIEW_BASIC` fields and the `content` field.
    ///
    /// This is the default of view for
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// and
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\].
    Content = 3,
}
impl DocumentView {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "DOCUMENT_VIEW_UNSPECIFIED",
            Self::Basic => "DOCUMENT_VIEW_BASIC",
            Self::Full => "DOCUMENT_VIEW_FULL",
            Self::Content => "DOCUMENT_VIEW_CONTENT",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "DOCUMENT_VIEW_UNSPECIFIED" => Some(Self::Unspecified),
            "DOCUMENT_VIEW_BASIC" => Some(Self::Basic),
            "DOCUMENT_VIEW_FULL" => Some(Self::Full),
            "DOCUMENT_VIEW_CONTENT" => Some(Self::Content),
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod developer_knowledge_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// The Developer Knowledge API provides programmatic access to Google's public
    /// developer documentation, enabling you to integrate this knowledge base into
    /// your own applications and workflows.
    ///
    /// The API is designed to be the canonical source for machine-readable access to
    /// Google's developer documentation.
    ///
    /// A typical use case is to first use
    /// \[DeveloperKnowledge.SearchDocumentChunks\]\[google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks\]
    /// to find relevant page URIs based on a query, and then use
    /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
    /// or
    /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
    /// to fetch the full content of the top results.
    ///
    /// All document content is provided in Markdown format.
    #[derive(Debug, Clone)]
    pub struct DeveloperKnowledgeClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl DeveloperKnowledgeClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> DeveloperKnowledgeClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> DeveloperKnowledgeClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            DeveloperKnowledgeClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Searches for developer knowledge across Google's developer documentation.
        /// Returns \[DocumentChunk\]\[google.developers.knowledge.v1.DocumentChunk\]s
        /// based on the user's query. There may be many chunks from the same
        /// \[Document\]\[google.developers.knowledge.v1.Document\].  To retrieve full
        /// documents, use
        /// \[DeveloperKnowledge.GetDocument\]\[google.developers.knowledge.v1.DeveloperKnowledge.GetDocument\]
        /// or
        /// \[DeveloperKnowledge.BatchGetDocuments\]\[google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments\]
        /// with the
        /// \[DocumentChunk.parent\]\[google.developers.knowledge.v1.DocumentChunk.parent\]
        /// returned in the
        /// \[SearchDocumentChunksResponse.results\]\[google.developers.knowledge.v1.SearchDocumentChunksResponse.results\].
        pub async fn search_document_chunks(
            &mut self,
            request: impl tonic::IntoRequest<super::SearchDocumentChunksRequest>,
        ) -> std::result::Result<
            tonic::Response<super::SearchDocumentChunksResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.developers.knowledge.v1.DeveloperKnowledge/SearchDocumentChunks",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.developers.knowledge.v1.DeveloperKnowledge",
                        "SearchDocumentChunks",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Retrieves a single document with its full Markdown content.
        pub async fn get_document(
            &mut self,
            request: impl tonic::IntoRequest<super::GetDocumentRequest>,
        ) -> std::result::Result<tonic::Response<super::Document>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.developers.knowledge.v1.DeveloperKnowledge/GetDocument",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.developers.knowledge.v1.DeveloperKnowledge",
                        "GetDocument",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Retrieves multiple documents, each with its full Markdown content.
        pub async fn batch_get_documents(
            &mut self,
            request: impl tonic::IntoRequest<super::BatchGetDocumentsRequest>,
        ) -> std::result::Result<
            tonic::Response<super::BatchGetDocumentsResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.developers.knowledge.v1.DeveloperKnowledge/BatchGetDocuments",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.developers.knowledge.v1.DeveloperKnowledge",
                        "BatchGetDocuments",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}