google_cloud_profiler_v2/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// CreateProfileRequest describes a profile resource online creation request.
36/// The deployment field must be populated. The profile_type specifies the list
37/// of profile types supported by the agent. The creation call will hang until a
38/// profile of one of these types needs to be collected.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct CreateProfileRequest {
42 /// Parent project to create the profile in.
43 pub parent: std::string::String,
44
45 /// Deployment details.
46 pub deployment: std::option::Option<crate::model::Deployment>,
47
48 /// One or more profile types that the agent is capable of providing.
49 pub profile_type: std::vec::Vec<crate::model::ProfileType>,
50
51 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl CreateProfileRequest {
55 pub fn new() -> Self {
56 std::default::Default::default()
57 }
58
59 /// Sets the value of [parent][crate::model::CreateProfileRequest::parent].
60 ///
61 /// # Example
62 /// ```ignore,no_run
63 /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
64 /// let x = CreateProfileRequest::new().set_parent("example");
65 /// ```
66 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
67 self.parent = v.into();
68 self
69 }
70
71 /// Sets the value of [deployment][crate::model::CreateProfileRequest::deployment].
72 ///
73 /// # Example
74 /// ```ignore,no_run
75 /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
76 /// use google_cloud_profiler_v2::model::Deployment;
77 /// let x = CreateProfileRequest::new().set_deployment(Deployment::default()/* use setters */);
78 /// ```
79 pub fn set_deployment<T>(mut self, v: T) -> Self
80 where
81 T: std::convert::Into<crate::model::Deployment>,
82 {
83 self.deployment = std::option::Option::Some(v.into());
84 self
85 }
86
87 /// Sets or clears the value of [deployment][crate::model::CreateProfileRequest::deployment].
88 ///
89 /// # Example
90 /// ```ignore,no_run
91 /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
92 /// use google_cloud_profiler_v2::model::Deployment;
93 /// let x = CreateProfileRequest::new().set_or_clear_deployment(Some(Deployment::default()/* use setters */));
94 /// let x = CreateProfileRequest::new().set_or_clear_deployment(None::<Deployment>);
95 /// ```
96 pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
97 where
98 T: std::convert::Into<crate::model::Deployment>,
99 {
100 self.deployment = v.map(|x| x.into());
101 self
102 }
103
104 /// Sets the value of [profile_type][crate::model::CreateProfileRequest::profile_type].
105 ///
106 /// # Example
107 /// ```ignore,no_run
108 /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
109 /// use google_cloud_profiler_v2::model::ProfileType;
110 /// let x = CreateProfileRequest::new().set_profile_type([
111 /// ProfileType::Cpu,
112 /// ProfileType::Wall,
113 /// ProfileType::Heap,
114 /// ]);
115 /// ```
116 pub fn set_profile_type<T, V>(mut self, v: T) -> Self
117 where
118 T: std::iter::IntoIterator<Item = V>,
119 V: std::convert::Into<crate::model::ProfileType>,
120 {
121 use std::iter::Iterator;
122 self.profile_type = v.into_iter().map(|i| i.into()).collect();
123 self
124 }
125}
126
127impl wkt::message::Message for CreateProfileRequest {
128 fn typename() -> &'static str {
129 "type.googleapis.com/google.devtools.cloudprofiler.v2.CreateProfileRequest"
130 }
131}
132
133/// CreateOfflineProfileRequest describes a profile resource offline creation
134/// request.
135#[derive(Clone, Default, PartialEq)]
136#[non_exhaustive]
137pub struct CreateOfflineProfileRequest {
138 /// Parent project to create the profile in.
139 pub parent: std::string::String,
140
141 /// Contents of the profile to create.
142 pub profile: std::option::Option<crate::model::Profile>,
143
144 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
145}
146
147impl CreateOfflineProfileRequest {
148 pub fn new() -> Self {
149 std::default::Default::default()
150 }
151
152 /// Sets the value of [parent][crate::model::CreateOfflineProfileRequest::parent].
153 ///
154 /// # Example
155 /// ```ignore,no_run
156 /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
157 /// let x = CreateOfflineProfileRequest::new().set_parent("example");
158 /// ```
159 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
160 self.parent = v.into();
161 self
162 }
163
164 /// Sets the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
165 ///
166 /// # Example
167 /// ```ignore,no_run
168 /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
169 /// use google_cloud_profiler_v2::model::Profile;
170 /// let x = CreateOfflineProfileRequest::new().set_profile(Profile::default()/* use setters */);
171 /// ```
172 pub fn set_profile<T>(mut self, v: T) -> Self
173 where
174 T: std::convert::Into<crate::model::Profile>,
175 {
176 self.profile = std::option::Option::Some(v.into());
177 self
178 }
179
180 /// Sets or clears the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
181 ///
182 /// # Example
183 /// ```ignore,no_run
184 /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
185 /// use google_cloud_profiler_v2::model::Profile;
186 /// let x = CreateOfflineProfileRequest::new().set_or_clear_profile(Some(Profile::default()/* use setters */));
187 /// let x = CreateOfflineProfileRequest::new().set_or_clear_profile(None::<Profile>);
188 /// ```
189 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
190 where
191 T: std::convert::Into<crate::model::Profile>,
192 {
193 self.profile = v.map(|x| x.into());
194 self
195 }
196}
197
198impl wkt::message::Message for CreateOfflineProfileRequest {
199 fn typename() -> &'static str {
200 "type.googleapis.com/google.devtools.cloudprofiler.v2.CreateOfflineProfileRequest"
201 }
202}
203
204/// UpdateProfileRequest contains the profile to update.
205#[derive(Clone, Default, PartialEq)]
206#[non_exhaustive]
207pub struct UpdateProfileRequest {
208 /// Profile to update.
209 pub profile: std::option::Option<crate::model::Profile>,
210
211 /// Field mask used to specify the fields to be overwritten. Currently only
212 /// profile_bytes and labels fields are supported by UpdateProfile, so only
213 /// those fields can be specified in the mask. When no mask is provided, all
214 /// fields are overwritten.
215 pub update_mask: std::option::Option<wkt::FieldMask>,
216
217 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
218}
219
220impl UpdateProfileRequest {
221 pub fn new() -> Self {
222 std::default::Default::default()
223 }
224
225 /// Sets the value of [profile][crate::model::UpdateProfileRequest::profile].
226 ///
227 /// # Example
228 /// ```ignore,no_run
229 /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
230 /// use google_cloud_profiler_v2::model::Profile;
231 /// let x = UpdateProfileRequest::new().set_profile(Profile::default()/* use setters */);
232 /// ```
233 pub fn set_profile<T>(mut self, v: T) -> Self
234 where
235 T: std::convert::Into<crate::model::Profile>,
236 {
237 self.profile = std::option::Option::Some(v.into());
238 self
239 }
240
241 /// Sets or clears the value of [profile][crate::model::UpdateProfileRequest::profile].
242 ///
243 /// # Example
244 /// ```ignore,no_run
245 /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
246 /// use google_cloud_profiler_v2::model::Profile;
247 /// let x = UpdateProfileRequest::new().set_or_clear_profile(Some(Profile::default()/* use setters */));
248 /// let x = UpdateProfileRequest::new().set_or_clear_profile(None::<Profile>);
249 /// ```
250 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
251 where
252 T: std::convert::Into<crate::model::Profile>,
253 {
254 self.profile = v.map(|x| x.into());
255 self
256 }
257
258 /// Sets the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
259 ///
260 /// # Example
261 /// ```ignore,no_run
262 /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
263 /// use wkt::FieldMask;
264 /// let x = UpdateProfileRequest::new().set_update_mask(FieldMask::default()/* use setters */);
265 /// ```
266 pub fn set_update_mask<T>(mut self, v: T) -> Self
267 where
268 T: std::convert::Into<wkt::FieldMask>,
269 {
270 self.update_mask = std::option::Option::Some(v.into());
271 self
272 }
273
274 /// Sets or clears the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
275 ///
276 /// # Example
277 /// ```ignore,no_run
278 /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
279 /// use wkt::FieldMask;
280 /// let x = UpdateProfileRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
281 /// let x = UpdateProfileRequest::new().set_or_clear_update_mask(None::<FieldMask>);
282 /// ```
283 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
284 where
285 T: std::convert::Into<wkt::FieldMask>,
286 {
287 self.update_mask = v.map(|x| x.into());
288 self
289 }
290}
291
292impl wkt::message::Message for UpdateProfileRequest {
293 fn typename() -> &'static str {
294 "type.googleapis.com/google.devtools.cloudprofiler.v2.UpdateProfileRequest"
295 }
296}
297
298/// Profile resource.
299#[derive(Clone, Default, PartialEq)]
300#[non_exhaustive]
301pub struct Profile {
302 /// Output only. Opaque, server-assigned, unique ID for this profile.
303 pub name: std::string::String,
304
305 /// Type of profile.
306 /// For offline mode, this must be specified when creating the profile. For
307 /// online mode it is assigned and returned by the server.
308 pub profile_type: crate::model::ProfileType,
309
310 /// Deployment this profile corresponds to.
311 pub deployment: std::option::Option<crate::model::Deployment>,
312
313 /// Duration of the profiling session.
314 /// Input (for the offline mode) or output (for the online mode).
315 /// The field represents requested profiling duration. It may slightly differ
316 /// from the effective profiling duration, which is recorded in the profile
317 /// data, in case the profiling can't be stopped immediately (e.g. in case
318 /// stopping the profiling is handled asynchronously).
319 pub duration: std::option::Option<wkt::Duration>,
320
321 /// Input only. Profile bytes, as a gzip compressed serialized proto, the
322 /// format is <https://github.com/google/pprof/blob/master/proto/profile.proto>.
323 pub profile_bytes: ::bytes::Bytes,
324
325 /// Input only. Labels associated to this specific profile. These labels will
326 /// get merged with the deployment labels for the final data set. See
327 /// documentation on deployment labels for validation rules and limits.
328 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
329
330 /// Output only. Start time for the profile.
331 /// This output is only present in response from the ListProfiles method.
332 pub start_time: std::option::Option<wkt::Timestamp>,
333
334 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
335}
336
337impl Profile {
338 pub fn new() -> Self {
339 std::default::Default::default()
340 }
341
342 /// Sets the value of [name][crate::model::Profile::name].
343 ///
344 /// # Example
345 /// ```ignore,no_run
346 /// # use google_cloud_profiler_v2::model::Profile;
347 /// let x = Profile::new().set_name("example");
348 /// ```
349 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
350 self.name = v.into();
351 self
352 }
353
354 /// Sets the value of [profile_type][crate::model::Profile::profile_type].
355 ///
356 /// # Example
357 /// ```ignore,no_run
358 /// # use google_cloud_profiler_v2::model::Profile;
359 /// use google_cloud_profiler_v2::model::ProfileType;
360 /// let x0 = Profile::new().set_profile_type(ProfileType::Cpu);
361 /// let x1 = Profile::new().set_profile_type(ProfileType::Wall);
362 /// let x2 = Profile::new().set_profile_type(ProfileType::Heap);
363 /// ```
364 pub fn set_profile_type<T: std::convert::Into<crate::model::ProfileType>>(
365 mut self,
366 v: T,
367 ) -> Self {
368 self.profile_type = v.into();
369 self
370 }
371
372 /// Sets the value of [deployment][crate::model::Profile::deployment].
373 ///
374 /// # Example
375 /// ```ignore,no_run
376 /// # use google_cloud_profiler_v2::model::Profile;
377 /// use google_cloud_profiler_v2::model::Deployment;
378 /// let x = Profile::new().set_deployment(Deployment::default()/* use setters */);
379 /// ```
380 pub fn set_deployment<T>(mut self, v: T) -> Self
381 where
382 T: std::convert::Into<crate::model::Deployment>,
383 {
384 self.deployment = std::option::Option::Some(v.into());
385 self
386 }
387
388 /// Sets or clears the value of [deployment][crate::model::Profile::deployment].
389 ///
390 /// # Example
391 /// ```ignore,no_run
392 /// # use google_cloud_profiler_v2::model::Profile;
393 /// use google_cloud_profiler_v2::model::Deployment;
394 /// let x = Profile::new().set_or_clear_deployment(Some(Deployment::default()/* use setters */));
395 /// let x = Profile::new().set_or_clear_deployment(None::<Deployment>);
396 /// ```
397 pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
398 where
399 T: std::convert::Into<crate::model::Deployment>,
400 {
401 self.deployment = v.map(|x| x.into());
402 self
403 }
404
405 /// Sets the value of [duration][crate::model::Profile::duration].
406 ///
407 /// # Example
408 /// ```ignore,no_run
409 /// # use google_cloud_profiler_v2::model::Profile;
410 /// use wkt::Duration;
411 /// let x = Profile::new().set_duration(Duration::default()/* use setters */);
412 /// ```
413 pub fn set_duration<T>(mut self, v: T) -> Self
414 where
415 T: std::convert::Into<wkt::Duration>,
416 {
417 self.duration = std::option::Option::Some(v.into());
418 self
419 }
420
421 /// Sets or clears the value of [duration][crate::model::Profile::duration].
422 ///
423 /// # Example
424 /// ```ignore,no_run
425 /// # use google_cloud_profiler_v2::model::Profile;
426 /// use wkt::Duration;
427 /// let x = Profile::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
428 /// let x = Profile::new().set_or_clear_duration(None::<Duration>);
429 /// ```
430 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
431 where
432 T: std::convert::Into<wkt::Duration>,
433 {
434 self.duration = v.map(|x| x.into());
435 self
436 }
437
438 /// Sets the value of [profile_bytes][crate::model::Profile::profile_bytes].
439 ///
440 /// # Example
441 /// ```ignore,no_run
442 /// # use google_cloud_profiler_v2::model::Profile;
443 /// let x = Profile::new().set_profile_bytes(bytes::Bytes::from_static(b"example"));
444 /// ```
445 pub fn set_profile_bytes<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
446 self.profile_bytes = v.into();
447 self
448 }
449
450 /// Sets the value of [labels][crate::model::Profile::labels].
451 ///
452 /// # Example
453 /// ```ignore,no_run
454 /// # use google_cloud_profiler_v2::model::Profile;
455 /// let x = Profile::new().set_labels([
456 /// ("key0", "abc"),
457 /// ("key1", "xyz"),
458 /// ]);
459 /// ```
460 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
461 where
462 T: std::iter::IntoIterator<Item = (K, V)>,
463 K: std::convert::Into<std::string::String>,
464 V: std::convert::Into<std::string::String>,
465 {
466 use std::iter::Iterator;
467 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
468 self
469 }
470
471 /// Sets the value of [start_time][crate::model::Profile::start_time].
472 ///
473 /// # Example
474 /// ```ignore,no_run
475 /// # use google_cloud_profiler_v2::model::Profile;
476 /// use wkt::Timestamp;
477 /// let x = Profile::new().set_start_time(Timestamp::default()/* use setters */);
478 /// ```
479 pub fn set_start_time<T>(mut self, v: T) -> Self
480 where
481 T: std::convert::Into<wkt::Timestamp>,
482 {
483 self.start_time = std::option::Option::Some(v.into());
484 self
485 }
486
487 /// Sets or clears the value of [start_time][crate::model::Profile::start_time].
488 ///
489 /// # Example
490 /// ```ignore,no_run
491 /// # use google_cloud_profiler_v2::model::Profile;
492 /// use wkt::Timestamp;
493 /// let x = Profile::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
494 /// let x = Profile::new().set_or_clear_start_time(None::<Timestamp>);
495 /// ```
496 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
497 where
498 T: std::convert::Into<wkt::Timestamp>,
499 {
500 self.start_time = v.map(|x| x.into());
501 self
502 }
503}
504
505impl wkt::message::Message for Profile {
506 fn typename() -> &'static str {
507 "type.googleapis.com/google.devtools.cloudprofiler.v2.Profile"
508 }
509}
510
511/// Deployment contains the deployment identification information.
512#[derive(Clone, Default, PartialEq)]
513#[non_exhaustive]
514pub struct Deployment {
515 /// Project ID is the ID of a cloud project.
516 /// Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`.
517 pub project_id: std::string::String,
518
519 /// Target is the service name used to group related deployments:
520 ///
521 /// * Service name for App Engine Flex / Standard.
522 /// * Cluster and container name for GKE.
523 /// * User-specified string for direct Compute Engine profiling (e.g. Java).
524 /// * Job name for Dataflow.
525 /// Validation regex: `^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
526 pub target: std::string::String,
527
528 /// Labels identify the deployment within the user universe and same target.
529 /// Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`.
530 /// Value for an individual label must be <= 512 bytes, the total
531 /// size of all label names and values must be <= 1024 bytes.
532 ///
533 /// Label named "language" can be used to record the programming language of
534 /// the profiled deployment. The standard choices for the value include "java",
535 /// "go", "python", "ruby", "nodejs", "php", "dotnet".
536 ///
537 /// For deployments running on Google Cloud Platform, "zone" or "region" label
538 /// should be present describing the deployment location. An example of a zone
539 /// is "us-central1-a", an example of a region is "us-central1" or
540 /// "us-central".
541 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
542
543 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
544}
545
546impl Deployment {
547 pub fn new() -> Self {
548 std::default::Default::default()
549 }
550
551 /// Sets the value of [project_id][crate::model::Deployment::project_id].
552 ///
553 /// # Example
554 /// ```ignore,no_run
555 /// # use google_cloud_profiler_v2::model::Deployment;
556 /// let x = Deployment::new().set_project_id("example");
557 /// ```
558 pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
559 self.project_id = v.into();
560 self
561 }
562
563 /// Sets the value of [target][crate::model::Deployment::target].
564 ///
565 /// # Example
566 /// ```ignore,no_run
567 /// # use google_cloud_profiler_v2::model::Deployment;
568 /// let x = Deployment::new().set_target("example");
569 /// ```
570 pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
571 self.target = v.into();
572 self
573 }
574
575 /// Sets the value of [labels][crate::model::Deployment::labels].
576 ///
577 /// # Example
578 /// ```ignore,no_run
579 /// # use google_cloud_profiler_v2::model::Deployment;
580 /// let x = Deployment::new().set_labels([
581 /// ("key0", "abc"),
582 /// ("key1", "xyz"),
583 /// ]);
584 /// ```
585 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
586 where
587 T: std::iter::IntoIterator<Item = (K, V)>,
588 K: std::convert::Into<std::string::String>,
589 V: std::convert::Into<std::string::String>,
590 {
591 use std::iter::Iterator;
592 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
593 self
594 }
595}
596
597impl wkt::message::Message for Deployment {
598 fn typename() -> &'static str {
599 "type.googleapis.com/google.devtools.cloudprofiler.v2.Deployment"
600 }
601}
602
603/// ListProfilesRequest contains request parameters for listing profiles for
604/// deployments in projects which the user has permissions to view.
605#[derive(Clone, Default, PartialEq)]
606#[non_exhaustive]
607pub struct ListProfilesRequest {
608 /// Required. The parent, which owns this collection of profiles.
609 /// Format: projects/{user_project_id}
610 pub parent: std::string::String,
611
612 /// The maximum number of items to return.
613 /// Default page_size is 1000.
614 /// Max limit is 1000.
615 pub page_size: i32,
616
617 /// The token to continue pagination and get profiles from a particular page.
618 /// When paginating, all other parameters provided to `ListProfiles` must match
619 /// the call that provided the page token.
620 pub page_token: std::string::String,
621
622 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
623}
624
625impl ListProfilesRequest {
626 pub fn new() -> Self {
627 std::default::Default::default()
628 }
629
630 /// Sets the value of [parent][crate::model::ListProfilesRequest::parent].
631 ///
632 /// # Example
633 /// ```ignore,no_run
634 /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
635 /// let x = ListProfilesRequest::new().set_parent("example");
636 /// ```
637 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
638 self.parent = v.into();
639 self
640 }
641
642 /// Sets the value of [page_size][crate::model::ListProfilesRequest::page_size].
643 ///
644 /// # Example
645 /// ```ignore,no_run
646 /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
647 /// let x = ListProfilesRequest::new().set_page_size(42);
648 /// ```
649 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
650 self.page_size = v.into();
651 self
652 }
653
654 /// Sets the value of [page_token][crate::model::ListProfilesRequest::page_token].
655 ///
656 /// # Example
657 /// ```ignore,no_run
658 /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
659 /// let x = ListProfilesRequest::new().set_page_token("example");
660 /// ```
661 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
662 self.page_token = v.into();
663 self
664 }
665}
666
667impl wkt::message::Message for ListProfilesRequest {
668 fn typename() -> &'static str {
669 "type.googleapis.com/google.devtools.cloudprofiler.v2.ListProfilesRequest"
670 }
671}
672
673/// ListProfileResponse contains the list of collected profiles for deployments
674/// in projects which the user has permissions to view.
675#[derive(Clone, Default, PartialEq)]
676#[non_exhaustive]
677pub struct ListProfilesResponse {
678 /// List of profiles fetched.
679 pub profiles: std::vec::Vec<crate::model::Profile>,
680
681 /// Token to receive the next page of results.
682 /// This field maybe empty if there are no more profiles to fetch.
683 pub next_page_token: std::string::String,
684
685 /// Number of profiles that were skipped in the current page since they were
686 /// not able to be fetched successfully. This should typically be zero. A
687 /// non-zero value may indicate a transient failure, in which case if the
688 /// number is too high for your use case, the call may be retried.
689 pub skipped_profiles: i32,
690
691 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
692}
693
694impl ListProfilesResponse {
695 pub fn new() -> Self {
696 std::default::Default::default()
697 }
698
699 /// Sets the value of [profiles][crate::model::ListProfilesResponse::profiles].
700 ///
701 /// # Example
702 /// ```ignore,no_run
703 /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
704 /// use google_cloud_profiler_v2::model::Profile;
705 /// let x = ListProfilesResponse::new()
706 /// .set_profiles([
707 /// Profile::default()/* use setters */,
708 /// Profile::default()/* use (different) setters */,
709 /// ]);
710 /// ```
711 pub fn set_profiles<T, V>(mut self, v: T) -> Self
712 where
713 T: std::iter::IntoIterator<Item = V>,
714 V: std::convert::Into<crate::model::Profile>,
715 {
716 use std::iter::Iterator;
717 self.profiles = v.into_iter().map(|i| i.into()).collect();
718 self
719 }
720
721 /// Sets the value of [next_page_token][crate::model::ListProfilesResponse::next_page_token].
722 ///
723 /// # Example
724 /// ```ignore,no_run
725 /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
726 /// let x = ListProfilesResponse::new().set_next_page_token("example");
727 /// ```
728 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
729 self.next_page_token = v.into();
730 self
731 }
732
733 /// Sets the value of [skipped_profiles][crate::model::ListProfilesResponse::skipped_profiles].
734 ///
735 /// # Example
736 /// ```ignore,no_run
737 /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
738 /// let x = ListProfilesResponse::new().set_skipped_profiles(42);
739 /// ```
740 pub fn set_skipped_profiles<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
741 self.skipped_profiles = v.into();
742 self
743 }
744}
745
746impl wkt::message::Message for ListProfilesResponse {
747 fn typename() -> &'static str {
748 "type.googleapis.com/google.devtools.cloudprofiler.v2.ListProfilesResponse"
749 }
750}
751
752#[doc(hidden)]
753impl google_cloud_gax::paginator::internal::PageableResponse for ListProfilesResponse {
754 type PageItem = crate::model::Profile;
755
756 fn items(self) -> std::vec::Vec<Self::PageItem> {
757 self.profiles
758 }
759
760 fn next_page_token(&self) -> std::string::String {
761 use std::clone::Clone;
762 self.next_page_token.clone()
763 }
764}
765
766/// ProfileType is type of profiling data.
767/// NOTE: the enumeration member names are used (in lowercase) as unique string
768/// identifiers of profile types, so they must not be renamed.
769///
770/// # Working with unknown values
771///
772/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
773/// additional enum variants at any time. Adding new variants is not considered
774/// a breaking change. Applications should write their code in anticipation of:
775///
776/// - New values appearing in future releases of the client library, **and**
777/// - New values received dynamically, without application changes.
778///
779/// Please consult the [Working with enums] section in the user guide for some
780/// guidelines.
781///
782/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
783#[derive(Clone, Debug, PartialEq)]
784#[non_exhaustive]
785pub enum ProfileType {
786 /// Unspecified profile type.
787 Unspecified,
788 /// Thread CPU time sampling.
789 Cpu,
790 /// Wallclock time sampling. More expensive as stops all threads.
791 Wall,
792 /// In-use heap profile. Represents a snapshot of the allocations that are
793 /// live at the time of the profiling.
794 Heap,
795 /// Single-shot collection of all thread stacks.
796 Threads,
797 /// Synchronization contention profile.
798 Contention,
799 /// Peak heap profile.
800 PeakHeap,
801 /// Heap allocation profile. It represents the aggregation of all allocations
802 /// made over the duration of the profile. All allocations are included,
803 /// including those that might have been freed by the end of the profiling
804 /// interval. The profile is in particular useful for garbage collecting
805 /// languages to understand which parts of the code create most of the garbage
806 /// collection pressure to see if those can be optimized.
807 HeapAlloc,
808 /// If set, the enum was initialized with an unknown value.
809 ///
810 /// Applications can examine the value using [ProfileType::value] or
811 /// [ProfileType::name].
812 UnknownValue(profile_type::UnknownValue),
813}
814
815#[doc(hidden)]
816pub mod profile_type {
817 #[allow(unused_imports)]
818 use super::*;
819 #[derive(Clone, Debug, PartialEq)]
820 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
821}
822
823impl ProfileType {
824 /// Gets the enum value.
825 ///
826 /// Returns `None` if the enum contains an unknown value deserialized from
827 /// the string representation of enums.
828 pub fn value(&self) -> std::option::Option<i32> {
829 match self {
830 Self::Unspecified => std::option::Option::Some(0),
831 Self::Cpu => std::option::Option::Some(1),
832 Self::Wall => std::option::Option::Some(2),
833 Self::Heap => std::option::Option::Some(3),
834 Self::Threads => std::option::Option::Some(4),
835 Self::Contention => std::option::Option::Some(5),
836 Self::PeakHeap => std::option::Option::Some(6),
837 Self::HeapAlloc => std::option::Option::Some(7),
838 Self::UnknownValue(u) => u.0.value(),
839 }
840 }
841
842 /// Gets the enum value as a string.
843 ///
844 /// Returns `None` if the enum contains an unknown value deserialized from
845 /// the integer representation of enums.
846 pub fn name(&self) -> std::option::Option<&str> {
847 match self {
848 Self::Unspecified => std::option::Option::Some("PROFILE_TYPE_UNSPECIFIED"),
849 Self::Cpu => std::option::Option::Some("CPU"),
850 Self::Wall => std::option::Option::Some("WALL"),
851 Self::Heap => std::option::Option::Some("HEAP"),
852 Self::Threads => std::option::Option::Some("THREADS"),
853 Self::Contention => std::option::Option::Some("CONTENTION"),
854 Self::PeakHeap => std::option::Option::Some("PEAK_HEAP"),
855 Self::HeapAlloc => std::option::Option::Some("HEAP_ALLOC"),
856 Self::UnknownValue(u) => u.0.name(),
857 }
858 }
859}
860
861impl std::default::Default for ProfileType {
862 fn default() -> Self {
863 use std::convert::From;
864 Self::from(0)
865 }
866}
867
868impl std::fmt::Display for ProfileType {
869 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
870 wkt::internal::display_enum(f, self.name(), self.value())
871 }
872}
873
874impl std::convert::From<i32> for ProfileType {
875 fn from(value: i32) -> Self {
876 match value {
877 0 => Self::Unspecified,
878 1 => Self::Cpu,
879 2 => Self::Wall,
880 3 => Self::Heap,
881 4 => Self::Threads,
882 5 => Self::Contention,
883 6 => Self::PeakHeap,
884 7 => Self::HeapAlloc,
885 _ => Self::UnknownValue(profile_type::UnknownValue(
886 wkt::internal::UnknownEnumValue::Integer(value),
887 )),
888 }
889 }
890}
891
892impl std::convert::From<&str> for ProfileType {
893 fn from(value: &str) -> Self {
894 use std::string::ToString;
895 match value {
896 "PROFILE_TYPE_UNSPECIFIED" => Self::Unspecified,
897 "CPU" => Self::Cpu,
898 "WALL" => Self::Wall,
899 "HEAP" => Self::Heap,
900 "THREADS" => Self::Threads,
901 "CONTENTION" => Self::Contention,
902 "PEAK_HEAP" => Self::PeakHeap,
903 "HEAP_ALLOC" => Self::HeapAlloc,
904 _ => Self::UnknownValue(profile_type::UnknownValue(
905 wkt::internal::UnknownEnumValue::String(value.to_string()),
906 )),
907 }
908 }
909}
910
911impl serde::ser::Serialize for ProfileType {
912 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
913 where
914 S: serde::Serializer,
915 {
916 match self {
917 Self::Unspecified => serializer.serialize_i32(0),
918 Self::Cpu => serializer.serialize_i32(1),
919 Self::Wall => serializer.serialize_i32(2),
920 Self::Heap => serializer.serialize_i32(3),
921 Self::Threads => serializer.serialize_i32(4),
922 Self::Contention => serializer.serialize_i32(5),
923 Self::PeakHeap => serializer.serialize_i32(6),
924 Self::HeapAlloc => serializer.serialize_i32(7),
925 Self::UnknownValue(u) => u.0.serialize(serializer),
926 }
927 }
928}
929
930impl<'de> serde::de::Deserialize<'de> for ProfileType {
931 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
932 where
933 D: serde::Deserializer<'de>,
934 {
935 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ProfileType>::new(
936 ".google.devtools.cloudprofiler.v2.ProfileType",
937 ))
938 }
939}