google-cloud-profiler-v2 1.8.0

Google Cloud Client Libraries for Rust - Cloud Profiler API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gaxi;
extern crate google_cloud_gax;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// CreateProfileRequest describes a profile resource online creation request.
/// The deployment field must be populated. The profile_type specifies the list
/// of profile types supported by the agent. The creation call will hang until a
/// profile of one of these types needs to be collected.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateProfileRequest {
    /// Parent project to create the profile in.
    pub parent: std::string::String,

    /// Deployment details.
    pub deployment: std::option::Option<crate::model::Deployment>,

    /// One or more profile types that the agent is capable of providing.
    pub profile_type: std::vec::Vec<crate::model::ProfileType>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateProfileRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateProfileRequest::parent].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
    /// let x = CreateProfileRequest::new().set_parent("example");
    /// ```
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [deployment][crate::model::CreateProfileRequest::deployment].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
    /// use google_cloud_profiler_v2::model::Deployment;
    /// let x = CreateProfileRequest::new().set_deployment(Deployment::default()/* use setters */);
    /// ```
    pub fn set_deployment<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Deployment>,
    {
        self.deployment = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [deployment][crate::model::CreateProfileRequest::deployment].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
    /// use google_cloud_profiler_v2::model::Deployment;
    /// let x = CreateProfileRequest::new().set_or_clear_deployment(Some(Deployment::default()/* use setters */));
    /// let x = CreateProfileRequest::new().set_or_clear_deployment(None::<Deployment>);
    /// ```
    pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Deployment>,
    {
        self.deployment = v.map(|x| x.into());
        self
    }

    /// Sets the value of [profile_type][crate::model::CreateProfileRequest::profile_type].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateProfileRequest;
    /// use google_cloud_profiler_v2::model::ProfileType;
    /// let x = CreateProfileRequest::new().set_profile_type([
    ///     ProfileType::Cpu,
    ///     ProfileType::Wall,
    ///     ProfileType::Heap,
    /// ]);
    /// ```
    pub fn set_profile_type<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ProfileType>,
    {
        use std::iter::Iterator;
        self.profile_type = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for CreateProfileRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.CreateProfileRequest"
    }
}

/// CreateOfflineProfileRequest describes a profile resource offline creation
/// request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateOfflineProfileRequest {
    /// Parent project to create the profile in.
    pub parent: std::string::String,

    /// Contents of the profile to create.
    pub profile: std::option::Option<crate::model::Profile>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateOfflineProfileRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateOfflineProfileRequest::parent].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
    /// let x = CreateOfflineProfileRequest::new().set_parent("example");
    /// ```
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
    /// use google_cloud_profiler_v2::model::Profile;
    /// let x = CreateOfflineProfileRequest::new().set_profile(Profile::default()/* use setters */);
    /// ```
    pub fn set_profile<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Profile>,
    {
        self.profile = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::CreateOfflineProfileRequest;
    /// use google_cloud_profiler_v2::model::Profile;
    /// let x = CreateOfflineProfileRequest::new().set_or_clear_profile(Some(Profile::default()/* use setters */));
    /// let x = CreateOfflineProfileRequest::new().set_or_clear_profile(None::<Profile>);
    /// ```
    pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Profile>,
    {
        self.profile = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateOfflineProfileRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.CreateOfflineProfileRequest"
    }
}

/// UpdateProfileRequest contains the profile to update.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateProfileRequest {
    /// Profile to update.
    pub profile: std::option::Option<crate::model::Profile>,

    /// Field mask used to specify the fields to be overwritten. Currently only
    /// profile_bytes and labels fields are supported by UpdateProfile, so only
    /// those fields can be specified in the mask. When no mask is provided, all
    /// fields are overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateProfileRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [profile][crate::model::UpdateProfileRequest::profile].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
    /// use google_cloud_profiler_v2::model::Profile;
    /// let x = UpdateProfileRequest::new().set_profile(Profile::default()/* use setters */);
    /// ```
    pub fn set_profile<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Profile>,
    {
        self.profile = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [profile][crate::model::UpdateProfileRequest::profile].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
    /// use google_cloud_profiler_v2::model::Profile;
    /// let x = UpdateProfileRequest::new().set_or_clear_profile(Some(Profile::default()/* use setters */));
    /// let x = UpdateProfileRequest::new().set_or_clear_profile(None::<Profile>);
    /// ```
    pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Profile>,
    {
        self.profile = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
    /// use wkt::FieldMask;
    /// let x = UpdateProfileRequest::new().set_update_mask(FieldMask::default()/* use setters */);
    /// ```
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::UpdateProfileRequest;
    /// use wkt::FieldMask;
    /// let x = UpdateProfileRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
    /// let x = UpdateProfileRequest::new().set_or_clear_update_mask(None::<FieldMask>);
    /// ```
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateProfileRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.UpdateProfileRequest"
    }
}

/// Profile resource.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Profile {
    /// Output only. Opaque, server-assigned, unique ID for this profile.
    pub name: std::string::String,

    /// Type of profile.
    /// For offline mode, this must be specified when creating the profile. For
    /// online mode it is assigned and returned by the server.
    pub profile_type: crate::model::ProfileType,

    /// Deployment this profile corresponds to.
    pub deployment: std::option::Option<crate::model::Deployment>,

    /// Duration of the profiling session.
    /// Input (for the offline mode) or output (for the online mode).
    /// The field represents requested profiling duration. It may slightly differ
    /// from the effective profiling duration, which is recorded in the profile
    /// data, in case the profiling can't be stopped immediately (e.g. in case
    /// stopping the profiling is handled asynchronously).
    pub duration: std::option::Option<wkt::Duration>,

    /// Input only. Profile bytes, as a gzip compressed serialized proto, the
    /// format is <https://github.com/google/pprof/blob/master/proto/profile.proto>.
    pub profile_bytes: ::bytes::Bytes,

    /// Input only. Labels associated to this specific profile. These labels will
    /// get merged with the deployment labels for the final data set. See
    /// documentation on deployment labels for validation rules and limits.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Output only. Start time for the profile.
    /// This output is only present in response from the ListProfiles method.
    pub start_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Profile {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Profile::name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// let x = Profile::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [profile_type][crate::model::Profile::profile_type].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use google_cloud_profiler_v2::model::ProfileType;
    /// let x0 = Profile::new().set_profile_type(ProfileType::Cpu);
    /// let x1 = Profile::new().set_profile_type(ProfileType::Wall);
    /// let x2 = Profile::new().set_profile_type(ProfileType::Heap);
    /// ```
    pub fn set_profile_type<T: std::convert::Into<crate::model::ProfileType>>(
        mut self,
        v: T,
    ) -> Self {
        self.profile_type = v.into();
        self
    }

    /// Sets the value of [deployment][crate::model::Profile::deployment].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use google_cloud_profiler_v2::model::Deployment;
    /// let x = Profile::new().set_deployment(Deployment::default()/* use setters */);
    /// ```
    pub fn set_deployment<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Deployment>,
    {
        self.deployment = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [deployment][crate::model::Profile::deployment].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use google_cloud_profiler_v2::model::Deployment;
    /// let x = Profile::new().set_or_clear_deployment(Some(Deployment::default()/* use setters */));
    /// let x = Profile::new().set_or_clear_deployment(None::<Deployment>);
    /// ```
    pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Deployment>,
    {
        self.deployment = v.map(|x| x.into());
        self
    }

    /// Sets the value of [duration][crate::model::Profile::duration].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use wkt::Duration;
    /// let x = Profile::new().set_duration(Duration::default()/* use setters */);
    /// ```
    pub fn set_duration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.duration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [duration][crate::model::Profile::duration].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use wkt::Duration;
    /// let x = Profile::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
    /// let x = Profile::new().set_or_clear_duration(None::<Duration>);
    /// ```
    pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.duration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [profile_bytes][crate::model::Profile::profile_bytes].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// let x = Profile::new().set_profile_bytes(bytes::Bytes::from_static(b"example"));
    /// ```
    pub fn set_profile_bytes<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.profile_bytes = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::Profile::labels].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// let x = Profile::new().set_labels([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [start_time][crate::model::Profile::start_time].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use wkt::Timestamp;
    /// let x = Profile::new().set_start_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::Profile::start_time].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Profile;
    /// use wkt::Timestamp;
    /// let x = Profile::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
    /// let x = Profile::new().set_or_clear_start_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for Profile {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.Profile"
    }
}

/// Deployment contains the deployment identification information.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Deployment {
    /// Project ID is the ID of a cloud project.
    /// Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`.
    pub project_id: std::string::String,

    /// Target is the service name used to group related deployments:
    ///
    /// * Service name for App Engine Flex / Standard.
    /// * Cluster and container name for GKE.
    /// * User-specified string for direct Compute Engine profiling (e.g. Java).
    /// * Job name for Dataflow.
    ///   Validation regex: `^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
    pub target: std::string::String,

    /// Labels identify the deployment within the user universe and same target.
    /// Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`.
    /// Value for an individual label must be <= 512 bytes, the total
    /// size of all label names and values must be <= 1024 bytes.
    ///
    /// Label named "language" can be used to record the programming language of
    /// the profiled deployment. The standard choices for the value include "java",
    /// "go", "python", "ruby", "nodejs", "php", "dotnet".
    ///
    /// For deployments running on Google Cloud Platform, "zone" or "region" label
    /// should be present describing the deployment location. An example of a zone
    /// is "us-central1-a", an example of a region is "us-central1" or
    /// "us-central".
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Deployment {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [project_id][crate::model::Deployment::project_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Deployment;
    /// let x = Deployment::new().set_project_id("example");
    /// ```
    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.project_id = v.into();
        self
    }

    /// Sets the value of [target][crate::model::Deployment::target].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Deployment;
    /// let x = Deployment::new().set_target("example");
    /// ```
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::Deployment::labels].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::Deployment;
    /// let x = Deployment::new().set_labels([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for Deployment {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.Deployment"
    }
}

/// ListProfilesRequest contains request parameters for listing profiles for
/// deployments in projects which the user has permissions to view.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListProfilesRequest {
    /// Required. The parent, which owns this collection of profiles.
    /// Format: projects/{user_project_id}
    pub parent: std::string::String,

    /// The maximum number of items to return.
    /// Default page_size is 1000.
    /// Max limit is 1000.
    pub page_size: i32,

    /// The token to continue pagination and get profiles from a particular page.
    /// When paginating, all other parameters provided to `ListProfiles` must match
    /// the call that provided the page token.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListProfilesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListProfilesRequest::parent].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
    /// let x = ListProfilesRequest::new().set_parent("example");
    /// ```
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListProfilesRequest::page_size].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
    /// let x = ListProfilesRequest::new().set_page_size(42);
    /// ```
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListProfilesRequest::page_token].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesRequest;
    /// let x = ListProfilesRequest::new().set_page_token("example");
    /// ```
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListProfilesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.ListProfilesRequest"
    }
}

/// ListProfileResponse contains the list of collected profiles for deployments
/// in projects which the user has permissions to view.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListProfilesResponse {
    /// List of profiles fetched.
    pub profiles: std::vec::Vec<crate::model::Profile>,

    /// Token to receive the next page of results.
    /// This field maybe empty if there are no more profiles to fetch.
    pub next_page_token: std::string::String,

    /// Number of profiles that were skipped in the current page since they were
    /// not able to be fetched successfully. This should typically be zero. A
    /// non-zero value may indicate a transient failure, in which case if the
    /// number is too high for your use case, the call may be retried.
    pub skipped_profiles: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListProfilesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [profiles][crate::model::ListProfilesResponse::profiles].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
    /// use google_cloud_profiler_v2::model::Profile;
    /// let x = ListProfilesResponse::new()
    ///     .set_profiles([
    ///         Profile::default()/* use setters */,
    ///         Profile::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_profiles<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Profile>,
    {
        use std::iter::Iterator;
        self.profiles = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListProfilesResponse::next_page_token].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
    /// let x = ListProfilesResponse::new().set_next_page_token("example");
    /// ```
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [skipped_profiles][crate::model::ListProfilesResponse::skipped_profiles].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_profiler_v2::model::ListProfilesResponse;
    /// let x = ListProfilesResponse::new().set_skipped_profiles(42);
    /// ```
    pub fn set_skipped_profiles<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.skipped_profiles = v.into();
        self
    }
}

impl wkt::message::Message for ListProfilesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.cloudprofiler.v2.ListProfilesResponse"
    }
}

#[doc(hidden)]
impl google_cloud_gax::paginator::internal::PageableResponse for ListProfilesResponse {
    type PageItem = crate::model::Profile;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.profiles
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// ProfileType is type of profiling data.
/// NOTE: the enumeration member names are used (in lowercase) as unique string
/// identifiers of profile types, so they must not be renamed.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ProfileType {
    /// Unspecified profile type.
    Unspecified,
    /// Thread CPU time sampling.
    Cpu,
    /// Wallclock time sampling. More expensive as stops all threads.
    Wall,
    /// In-use heap profile. Represents a snapshot of the allocations that are
    /// live at the time of the profiling.
    Heap,
    /// Single-shot collection of all thread stacks.
    Threads,
    /// Synchronization contention profile.
    Contention,
    /// Peak heap profile.
    PeakHeap,
    /// Heap allocation profile. It represents the aggregation of all allocations
    /// made over the duration of the profile. All allocations are included,
    /// including those that might have been freed by the end of the profiling
    /// interval. The profile is in particular useful for garbage collecting
    /// languages to understand which parts of the code create most of the garbage
    /// collection pressure to see if those can be optimized.
    HeapAlloc,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ProfileType::value] or
    /// [ProfileType::name].
    UnknownValue(profile_type::UnknownValue),
}

#[doc(hidden)]
pub mod profile_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ProfileType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Cpu => std::option::Option::Some(1),
            Self::Wall => std::option::Option::Some(2),
            Self::Heap => std::option::Option::Some(3),
            Self::Threads => std::option::Option::Some(4),
            Self::Contention => std::option::Option::Some(5),
            Self::PeakHeap => std::option::Option::Some(6),
            Self::HeapAlloc => std::option::Option::Some(7),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("PROFILE_TYPE_UNSPECIFIED"),
            Self::Cpu => std::option::Option::Some("CPU"),
            Self::Wall => std::option::Option::Some("WALL"),
            Self::Heap => std::option::Option::Some("HEAP"),
            Self::Threads => std::option::Option::Some("THREADS"),
            Self::Contention => std::option::Option::Some("CONTENTION"),
            Self::PeakHeap => std::option::Option::Some("PEAK_HEAP"),
            Self::HeapAlloc => std::option::Option::Some("HEAP_ALLOC"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ProfileType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ProfileType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ProfileType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Cpu,
            2 => Self::Wall,
            3 => Self::Heap,
            4 => Self::Threads,
            5 => Self::Contention,
            6 => Self::PeakHeap,
            7 => Self::HeapAlloc,
            _ => Self::UnknownValue(profile_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ProfileType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "PROFILE_TYPE_UNSPECIFIED" => Self::Unspecified,
            "CPU" => Self::Cpu,
            "WALL" => Self::Wall,
            "HEAP" => Self::Heap,
            "THREADS" => Self::Threads,
            "CONTENTION" => Self::Contention,
            "PEAK_HEAP" => Self::PeakHeap,
            "HEAP_ALLOC" => Self::HeapAlloc,
            _ => Self::UnknownValue(profile_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ProfileType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Cpu => serializer.serialize_i32(1),
            Self::Wall => serializer.serialize_i32(2),
            Self::Heap => serializer.serialize_i32(3),
            Self::Threads => serializer.serialize_i32(4),
            Self::Contention => serializer.serialize_i32(5),
            Self::PeakHeap => serializer.serialize_i32(6),
            Self::HeapAlloc => serializer.serialize_i32(7),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ProfileType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ProfileType>::new(
            ".google.devtools.cloudprofiler.v2.ProfileType",
        ))
    }
}