google-cloud-api-servicecontrol-v2 1.7.0

Google Cloud Client Libraries for Rust - Service Control API
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
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gaxi;
extern crate google_cloud_gax;
extern crate google_cloud_rpc;
extern crate google_cloud_rpc_context;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Request message for the Check method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckRequest {
    /// The service name as specified in its service configuration. For example,
    /// `"pubsub.googleapis.com"`.
    ///
    /// See
    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
    /// for the definition of a service name.
    pub service_name: std::string::String,

    /// Specifies the version of the service configuration that should be used to
    /// process the request. Must not be empty. Set this field to 'latest' to
    /// specify using the latest configuration.
    pub service_config_id: std::string::String,

    /// Describes attributes about the operation being executed by the service.
    pub attributes: std::option::Option<google_cloud_rpc_context::model::AttributeContext>,

    /// Describes the resources and the policies applied to each resource.
    pub resources: std::vec::Vec<crate::model::ResourceInfo>,

    /// Optional. Contains a comma-separated list of flags.
    pub flags: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// let x = CheckRequest::new().set_service_name("example");
    /// ```
    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_name = v.into();
        self
    }

    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// let x = CheckRequest::new().set_service_config_id("example");
    /// ```
    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_config_id = v.into();
        self
    }

    /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// use google_cloud_rpc_context::model::AttributeContext;
    /// let x = CheckRequest::new().set_attributes(AttributeContext::default()/* use setters */);
    /// ```
    pub fn set_attributes<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
    {
        self.attributes = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// use google_cloud_rpc_context::model::AttributeContext;
    /// let x = CheckRequest::new().set_or_clear_attributes(Some(AttributeContext::default()/* use setters */));
    /// let x = CheckRequest::new().set_or_clear_attributes(None::<AttributeContext>);
    /// ```
    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
    {
        self.attributes = v.map(|x| x.into());
        self
    }

    /// Sets the value of [resources][crate::model::CheckRequest::resources].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = CheckRequest::new()
    ///     .set_resources([
    ///         ResourceInfo::default()/* use setters */,
    ///         ResourceInfo::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceInfo>,
    {
        use std::iter::Iterator;
        self.resources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [flags][crate::model::CheckRequest::flags].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
    /// let x = CheckRequest::new().set_flags("example");
    /// ```
    pub fn set_flags<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.flags = v.into();
        self
    }
}

impl wkt::message::Message for CheckRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.CheckRequest"
    }
}

/// Describes a resource referenced in the request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceInfo {
    /// The name of the resource referenced in the request.
    pub name: std::string::String,

    /// The resource type in the format of "{service}/{kind}".
    pub r#type: std::string::String,

    /// The resource permission needed for this request.
    /// The format must be "{service}/{plural}.{verb}".
    pub permission: std::string::String,

    /// Optional. The identifier of the container of this resource. For Google
    /// Cloud APIs, the resource container must be one of the following formats:
    /// - `projects/<project-id or project-number>`
    ///
    /// - `folders/<folder-number>`
    /// - `organizations/<organization-number>`
    ///
    /// Required for the policy enforcement on the container level (e.g. VPCSC,
    /// Location Policy check, Org Policy check).
    pub container: std::string::String,

    /// Optional. The location of the resource, it must be a valid zone, region or
    /// multiregion, for example: "europe-west4", "northamerica-northeast1-a".
    /// Required for location policy check.
    pub location: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ResourceInfo::name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfo::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::ResourceInfo::type].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfo::new().set_type("example");
    /// ```
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [permission][crate::model::ResourceInfo::permission].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfo::new().set_permission("example");
    /// ```
    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.permission = v.into();
        self
    }

    /// Sets the value of [container][crate::model::ResourceInfo::container].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfo::new().set_container("example");
    /// ```
    pub fn set_container<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.container = v.into();
        self
    }

    /// Sets the value of [location][crate::model::ResourceInfo::location].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfo::new().set_location("example");
    /// ```
    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.location = v.into();
        self
    }
}

impl wkt::message::Message for ResourceInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfo"
    }
}

/// Response message for the Check method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckResponse {
    /// Operation is allowed when this field is not set. Any non-'OK' status
    /// indicates a denial; [google.rpc.Status.details][google.rpc.Status.details]
    /// would contain additional details about the denial.
    ///
    /// [google.rpc.Status.details]: google_cloud_rpc::model::Status::details
    pub status: std::option::Option<google_cloud_rpc::model::Status>,

    /// Returns a set of request contexts generated from the `CheckRequest`.
    pub headers: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [status][crate::model::CheckResponse::status].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
    /// use google_cloud_rpc::model::Status;
    /// let x = CheckResponse::new().set_status(Status::default()/* use setters */);
    /// ```
    pub fn set_status<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_rpc::model::Status>,
    {
        self.status = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [status][crate::model::CheckResponse::status].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
    /// use google_cloud_rpc::model::Status;
    /// let x = CheckResponse::new().set_or_clear_status(Some(Status::default()/* use setters */));
    /// let x = CheckResponse::new().set_or_clear_status(None::<Status>);
    /// ```
    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_rpc::model::Status>,
    {
        self.status = v.map(|x| x.into());
        self
    }

    /// Sets the value of [headers][crate::model::CheckResponse::headers].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
    /// let x = CheckResponse::new().set_headers([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for CheckResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.CheckResponse"
    }
}

/// Request message for the Report method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReportRequest {
    /// The service name as specified in its service configuration. For example,
    /// `"pubsub.googleapis.com"`.
    ///
    /// See
    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
    /// for the definition of a service name.
    pub service_name: std::string::String,

    /// Specifies the version of the service configuration that should be used to
    /// process the request. Must not be empty. Set this field to 'latest' to
    /// specify using the latest configuration.
    pub service_config_id: std::string::String,

    /// Describes the list of operations to be reported. Each operation is
    /// represented as an AttributeContext, and contains all attributes around an
    /// API access.
    pub operations: std::vec::Vec<google_cloud_rpc_context::model::AttributeContext>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReportRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
    /// let x = ReportRequest::new().set_service_name("example");
    /// ```
    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_name = v.into();
        self
    }

    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
    /// let x = ReportRequest::new().set_service_config_id("example");
    /// ```
    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_config_id = v.into();
        self
    }

    /// Sets the value of [operations][crate::model::ReportRequest::operations].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
    /// use google_cloud_rpc_context::model::AttributeContext;
    /// let x = ReportRequest::new()
    ///     .set_operations([
    ///         AttributeContext::default()/* use setters */,
    ///         AttributeContext::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_operations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
    {
        use std::iter::Iterator;
        self.operations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ReportRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ReportRequest"
    }
}

/// Response message for the Report method.
/// If the request contains any invalid data, the server returns an RPC error.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReportResponse {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReportResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for ReportResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ReportResponse"
    }
}

/// Message containing resource details in a batch mode.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceInfoList {
    /// The resource details.
    pub resources: std::vec::Vec<crate::model::ResourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceInfoList {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [resources][crate::model::ResourceInfoList::resources].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfoList;
    /// use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
    /// let x = ResourceInfoList::new()
    ///     .set_resources([
    ///         ResourceInfo::default()/* use setters */,
    ///         ResourceInfo::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceInfo>,
    {
        use std::iter::Iterator;
        self.resources = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ResourceInfoList {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfoList"
    }
}