Skip to main content

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