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