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