gcloud-sdk 0.30.0

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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
// This file is @generated by prost-build.
/// Request message for the `CreateReport` method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateReportRequest {
    /// Required. The parent Google Cloud project that will own the report.
    ///
    /// This value does not define the scope of the report data. See `Report.scope`
    /// for setting the data scope.
    ///
    /// Format: `projects/{project}/locations/{location}`.
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Required. The ID to use for this report. This ID must be unique within
    /// the parent project and should comply with RFC 1034 restrictions (letters,
    /// numbers, and hyphen, with the first character a letter, the last a letter
    /// or a number, and a 63 character maximum).
    #[prost(string, tag = "2")]
    pub report_id: ::prost::alloc::string::String,
    /// Required. The report resource to create.
    #[prost(message, optional, tag = "3")]
    pub report: ::core::option::Option<Report>,
}
/// A configuration that defines the parameters for the data represented by a
/// report.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Report {
    /// Identifier. The name of this report.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Required. A list of dimensions to include in the report. Supported values:
    ///
    /// * `project`
    /// * `application`
    /// * `service_or_workload`
    /// * `resource`
    /// * `resource_type`
    /// * `location`
    /// * `product_display_name`
    /// * `sku`
    /// * `month`
    /// * `day`
    /// * `hour`
    ///
    /// To aggregate results by time, specify at least one time dimension
    /// (`month`, `day`, or `hour`). All time dimensions use Pacific Time,
    /// respect Daylight Saving Time (DST), and follow these ISO 8601 formats:
    ///
    /// * `month`: `YYYY-MM` (e.g., `2024-01`)
    /// * `day`: `YYYY-MM-DD` (e.g., `2024-01-10`)
    /// * `hour`: `YYYY-MM-DDTHH` (e.g., `2024-01-10T00`)
    ///
    /// If the time range filter does not align with the selected time dimension,
    /// the range is expanded to encompass the full period of the finest-grained
    /// time dimension.
    ///
    /// For example, if the filter is `2026-01-10` through `2026-01-12` and the
    /// `month` dimension is selected, the effective time range expands to include
    /// all of January (`2026-01-01` to `2026-02-01`).
    #[prost(string, repeated, tag = "2")]
    pub dimensions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Required. A list of metrics to include in the report. Supported values:
    ///
    /// * `cost`
    /// * `cpu_mean_utilization`
    /// * `cpu_usage_core_seconds`
    /// * `cpu_allocation_core_seconds`
    /// * `cpu_p95_utilization`
    /// * `memory_mean_utilization`
    /// * `memory_usage_byte_seconds`
    /// * `memory_allocation_byte_seconds`
    /// * `memory_p95_utilization`
    #[prost(string, repeated, tag = "7")]
    pub metrics: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Optional. The resource containers for which to fetch data. Default is the
    /// project specified in the report's parent.
    #[prost(message, repeated, tag = "3")]
    pub scopes: ::prost::alloc::vec::Vec<Scope>,
    /// Optional. A Common Expression Language (CEL) expression used to filter the
    /// data for the report.
    ///
    /// Predicates may refer to any dimension. Filtering must conform to these
    /// constraints:
    ///
    /// * All string field predicates must use exact string matches.
    /// * Multiple predicates referring to the same string field must be joined
    ///   using the logical OR operator ('||').
    /// * All other predicates must be joined using the logical AND operator
    ///   (`&&`).
    /// * A predicate on a time dimension (e.g., `day`) specifying the start time
    ///   must use a greater-than-or-equal-to comparison (`>=`).
    /// * A predicate on a time dimension specifying the end time must use a
    ///   less-than comparison (`<`).
    ///
    /// Examples:
    ///
    /// 1. Filter by a specific resource type:
    ///    `"resource_type == 'compute.googleapis.com/Instance'"`
    ///
    /// 1. Filter data points that fall within a specific absolute time interval:
    ///    `"hour >= timestamp('2024-01-01T00:00:00Z') && hour < timestamp('2024-02-01T00:00:00Z')"`
    ///
    /// 1. Filter data points that fall within the past 72 hours:
    ///    `"hour >= now - duration('72h')"`
    ///
    /// 1. Combine string predicate with time interval predicate:
    ///    `"(location == 'us-east1' || location == 'us-west1') &&  hour >= timestamp('2023-12-01T00:00:00Z') &&  hour < timestamp('2024-02-01T00:00:00Z')"`
    ///
    /// If the filter omits time dimensions (`month`, `day`, `hour`), the report
    /// defaults to a 7-day range ending at the previous Pacific Time midnight,
    /// with Daylight Saving Time (DST) applied.
    ///
    /// For example, if the current Pacific Time is `2026-01-05T12:00:00`,
    /// the default range is `2025-12-29T00:00:00` to `2026-01-05T00:00:00` Pacific
    /// time.
    #[prost(string, tag = "4")]
    pub filter: ::prost::alloc::string::String,
    /// Defines this report's expiration time.
    #[prost(oneof = "report::Expiration", tags = "6")]
    pub expiration: ::core::option::Option<report::Expiration>,
}
/// Nested message and enum types in `Report`.
pub mod report {
    /// Defines this report's expiration time.
    #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
    pub enum Expiration {
        /// Output only. Timestamp in UTC of when this report expires. Once the
        /// report expires, it will no longer be accessible and the report's
        /// underlying data will be deleted.
        #[prost(message, tag = "6")]
        ExpireTime(::prost_types::Timestamp),
    }
}
/// Specifies the report scope.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Scope {
    #[prost(oneof = "scope::Scope", tags = "1, 2")]
    pub scope: ::core::option::Option<scope::Scope>,
}
/// Nested message and enum types in `Scope`.
pub mod scope {
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
    pub enum Scope {
        /// Required. A Google Cloud Platform project to fetch data from.
        ///
        /// Format: `"projects/{project}"`.
        #[prost(string, tag = "1")]
        Project(::prost::alloc::string::String),
        /// Required. An App Hub Application to fetch data from.
        ///
        /// Format:
        /// `"projects/{project}/locations/{location}/applications/{application}"`.
        #[prost(string, tag = "2")]
        Application(::prost::alloc::string::String),
    }
}
/// Request message for the `GetReport` method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetReportRequest {
    /// Required. The name of the report to retrieve.
    ///
    /// Format: `projects/{project}/locations/{location}/reports/{report_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the `ListReports` method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListReportsRequest {
    /// Required. The parent project whose reports are to be listed.
    ///
    /// Format: `projects/{project}/locations/{location}`.
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Optional. The maximum number of reports to return. The service may return
    /// fewer than this value. If unspecified, the server will determine the number
    /// of results to return.
    #[prost(int32, tag = "2")]
    pub page_size: i32,
    /// Optional. A page token, received from a previous `ListReports` call.
    /// Provide this to retrieve the subsequent page.
    ///
    /// When paginating, all other parameters provided to `ListReports` must match
    /// the call that provided the page token.
    #[prost(string, tag = "3")]
    pub page_token: ::prost::alloc::string::String,
}
/// Response message for the `ListReports` method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListReportsResponse {
    /// The list of reports.
    #[prost(message, repeated, tag = "1")]
    pub reports: ::prost::alloc::vec::Vec<Report>,
    /// A token that can be sent as `page_token` to retrieve the next page.
    /// If this field is empty, there are no subsequent pages.
    #[prost(string, tag = "2")]
    pub next_page_token: ::prost::alloc::string::String,
}
/// Request message for the `DeleteReport` method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteReportRequest {
    /// Required. The name of the report to delete.
    ///
    /// Format: `projects/{project}/locations/{location}/reports/{report_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Optional. If set to true, and the report is not found, the request will
    /// succeed but no action will be taken on the server.
    #[prost(bool, tag = "2")]
    pub allow_missing: bool,
}
/// Request message for the `ReadReport` method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ReadReportRequest {
    /// Required. The resource name of the report to query.
    ///
    /// Format: `projects/{project}/locations/{location}/reports/{report_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Optional. The maximum number of rows to return. The service may return
    /// fewer than this value. If unspecified, at most 10,000 rows will be returned
    /// per page. The maximum allowed value is 25,000; values above 25,000 are
    /// coerced to 25,000.
    #[prost(int32, tag = "4")]
    pub page_size: i32,
    /// Optional. A page token, received from a previous `ReadReport` call, to
    /// retrieve the subsequent page of results. When `page_token` is specified,
    /// `job_reference` must also be provided from the previous response, and the
    /// `statement` field must not be set.
    #[prost(string, tag = "5")]
    pub page_token: ::prost::alloc::string::String,
}
/// Response message for the `ReadReport` method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadReportResponse {
    /// A list of rows, where each row represents a record from the report.
    #[prost(message, repeated, tag = "1")]
    pub rows: ::prost::alloc::vec::Vec<::prost_types::ListValue>,
    /// The columns describing the structure of the data in the `rows` field.
    #[prost(message, repeated, tag = "5")]
    pub columns: ::prost::alloc::vec::Vec<Column>,
    /// A token that can be sent as `page_token` in a subsequent `ReadReport`
    /// request to retrieve the next page of results. If this field is empty,
    /// there are no further pages.
    #[prost(string, tag = "3")]
    pub next_page_token: ::prost::alloc::string::String,
}
/// Describes a single column within `Columns`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Column {
    /// The name of the column.
    ///
    /// This field:
    ///
    /// * Contains only letters (a-z, A-Z), numbers (0-9), or underscores (\_);
    /// * Start with a letter or underscore; and
    /// * Has a maximum length is 128 characters.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// The data type of the column.
    ///
    /// Supported values include:
    ///
    /// * `STRING`
    /// * `INT64`
    /// * `FLOAT64`
    /// * `BOOLEAN`
    /// * `TIMESTAMP`
    /// * `RECORD`
    ///
    /// `RECORD` indicates that the field contains a nested schema, described in
    /// the `columns` property of this `Column`.
    #[prost(string, tag = "2")]
    pub r#type: ::prost::alloc::string::String,
    /// The mode of the column, indicating if it is nullable, required, or
    /// repeated.
    ///
    /// Possible values:
    ///
    /// * `NULLABLE`: The column allows NULL values.
    /// * `REQUIRED`: The column does not allow NULL values.
    /// * `REPEATED`: The column contains an array of values.
    #[prost(string, tag = "3")]
    pub mode: ::prost::alloc::string::String,
    /// If the `type` of this column is `RECORD`, this sub-field describes the
    /// nested structure.
    #[prost(message, repeated, tag = "4")]
    pub columns: ::prost::alloc::vec::Vec<Column>,
}
/// Represents metadata related to the creation of a Report. This value is
/// embedded in the Operation object returned by `CreateReport`.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OperationMetadata {}
/// Generated client implementations.
pub mod app_optimize_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Service for managing and querying optimization reports.
    #[derive(Debug, Clone)]
    pub struct AppOptimizeClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl AppOptimizeClient<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> AppOptimizeClient<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,
        ) -> AppOptimizeClient<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,
        {
            AppOptimizeClient::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
        }
        /// Creates a new report.
        ///
        /// This initiates a long-running operation that, upon completion, results
        /// in a report resource. Once the report is created, its results can be read
        /// via `ReadReport`.
        pub async fn create_report(
            &mut self,
            request: impl tonic::IntoRequest<super::CreateReportRequest>,
        ) -> std::result::Result<
            tonic::Response<super::super::super::super::longrunning::Operation>,
            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.cloud.appoptimize.v1beta.AppOptimize/CreateReport",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.appoptimize.v1beta.AppOptimize",
                        "CreateReport",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Retrieves the details of a report configuration.
        pub async fn get_report(
            &mut self,
            request: impl tonic::IntoRequest<super::GetReportRequest>,
        ) -> std::result::Result<tonic::Response<super::Report>, 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.cloud.appoptimize.v1beta.AppOptimize/GetReport",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.appoptimize.v1beta.AppOptimize",
                        "GetReport",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Lists reports within a given project.
        pub async fn list_reports(
            &mut self,
            request: impl tonic::IntoRequest<super::ListReportsRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ListReportsResponse>,
            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.cloud.appoptimize.v1beta.AppOptimize/ListReports",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.appoptimize.v1beta.AppOptimize",
                        "ListReports",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Deletes the specified report.
        pub async fn delete_report(
            &mut self,
            request: impl tonic::IntoRequest<super::DeleteReportRequest>,
        ) -> std::result::Result<tonic::Response<()>, 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.cloud.appoptimize.v1beta.AppOptimize/DeleteReport",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.appoptimize.v1beta.AppOptimize",
                        "DeleteReport",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Reads data within a specified report.
        pub async fn read_report(
            &mut self,
            request: impl tonic::IntoRequest<super::ReadReportRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ReadReportResponse>,
            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.cloud.appoptimize.v1beta.AppOptimize/ReadReport",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.appoptimize.v1beta.AppOptimize",
                        "ReadReport",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}