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