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