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 package cloudprofiler
57
58 import (
59 "bytes"
60 "context"
61 "encoding/json"
62 "errors"
63 "fmt"
64 "io"
65 "net/http"
66 "net/url"
67 "strconv"
68 "strings"
69
70 googleapi "google.golang.org/api/googleapi"
71 internal "google.golang.org/api/internal"
72 gensupport "google.golang.org/api/internal/gensupport"
73 option "google.golang.org/api/option"
74 internaloption "google.golang.org/api/option/internaloption"
75 htransport "google.golang.org/api/transport/http"
76 )
77
78
79
80 var _ = bytes.NewBuffer
81 var _ = strconv.Itoa
82 var _ = fmt.Sprintf
83 var _ = json.NewDecoder
84 var _ = io.Copy
85 var _ = url.Parse
86 var _ = gensupport.MarshalJSON
87 var _ = googleapi.Version
88 var _ = errors.New
89 var _ = strings.Replace
90 var _ = context.Canceled
91 var _ = internaloption.WithDefaultEndpoint
92 var _ = internal.Version
93
94 const apiId = "cloudprofiler:v2"
95 const apiName = "cloudprofiler"
96 const apiVersion = "v2"
97 const basePath = "https://cloudprofiler.googleapis.com/"
98 const basePathTemplate = "https://cloudprofiler.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://cloudprofiler.mtls.googleapis.com/"
100
101
102 const (
103
104
105 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
106
107
108
109 MonitoringScope = "https://www.googleapis.com/auth/monitoring"
110
111
112 MonitoringWriteScope = "https://www.googleapis.com/auth/monitoring.write"
113 )
114
115
116 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
117 scopesOption := internaloption.WithDefaultScopes(
118 "https://www.googleapis.com/auth/cloud-platform",
119 "https://www.googleapis.com/auth/monitoring",
120 "https://www.googleapis.com/auth/monitoring.write",
121 )
122
123 opts = append([]option.ClientOption{scopesOption}, opts...)
124 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
125 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
126 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
127 opts = append(opts, internaloption.EnableNewAuthLibrary())
128 client, endpoint, err := htransport.NewClient(ctx, opts...)
129 if err != nil {
130 return nil, err
131 }
132 s, err := New(client)
133 if err != nil {
134 return nil, err
135 }
136 if endpoint != "" {
137 s.BasePath = endpoint
138 }
139 return s, nil
140 }
141
142
143
144
145
146
147 func New(client *http.Client) (*Service, error) {
148 if client == nil {
149 return nil, errors.New("client is nil")
150 }
151 s := &Service{client: client, BasePath: basePath}
152 s.Projects = NewProjectsService(s)
153 return s, nil
154 }
155
156 type Service struct {
157 client *http.Client
158 BasePath string
159 UserAgent string
160
161 Projects *ProjectsService
162 }
163
164 func (s *Service) userAgent() string {
165 if s.UserAgent == "" {
166 return googleapi.UserAgent
167 }
168 return googleapi.UserAgent + " " + s.UserAgent
169 }
170
171 func NewProjectsService(s *Service) *ProjectsService {
172 rs := &ProjectsService{s: s}
173 rs.Profiles = NewProjectsProfilesService(s)
174 return rs
175 }
176
177 type ProjectsService struct {
178 s *Service
179
180 Profiles *ProjectsProfilesService
181 }
182
183 func NewProjectsProfilesService(s *Service) *ProjectsProfilesService {
184 rs := &ProjectsProfilesService{s: s}
185 return rs
186 }
187
188 type ProjectsProfilesService struct {
189 s *Service
190 }
191
192
193
194
195
196
197 type CreateProfileRequest struct {
198
199 Deployment *Deployment `json:"deployment,omitempty"`
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218 ProfileType []string `json:"profileType,omitempty"`
219
220
221
222
223
224 ForceSendFields []string `json:"-"`
225
226
227
228
229 NullFields []string `json:"-"`
230 }
231
232 func (s *CreateProfileRequest) MarshalJSON() ([]byte, error) {
233 type NoMethod CreateProfileRequest
234 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
235 }
236
237
238 type Deployment struct {
239
240
241
242
243
244
245
246
247
248
249 Labels map[string]string `json:"labels,omitempty"`
250
251
252 ProjectId string `json:"projectId,omitempty"`
253
254
255
256
257
258 Target string `json:"target,omitempty"`
259
260
261
262
263
264 ForceSendFields []string `json:"-"`
265
266
267
268
269 NullFields []string `json:"-"`
270 }
271
272 func (s *Deployment) MarshalJSON() ([]byte, error) {
273 type NoMethod Deployment
274 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
275 }
276
277
278
279 type ListProfilesResponse struct {
280
281
282 NextPageToken string `json:"nextPageToken,omitempty"`
283
284 Profiles []*Profile `json:"profiles,omitempty"`
285
286
287
288
289 SkippedProfiles int64 `json:"skippedProfiles,omitempty"`
290
291
292 googleapi.ServerResponse `json:"-"`
293
294
295
296
297
298 ForceSendFields []string `json:"-"`
299
300
301
302
303 NullFields []string `json:"-"`
304 }
305
306 func (s *ListProfilesResponse) MarshalJSON() ([]byte, error) {
307 type NoMethod ListProfilesResponse
308 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
309 }
310
311
312 type Profile struct {
313
314 Deployment *Deployment `json:"deployment,omitempty"`
315
316
317
318
319
320
321 Duration string `json:"duration,omitempty"`
322
323
324
325 Labels map[string]string `json:"labels,omitempty"`
326
327 Name string `json:"name,omitempty"`
328
329
330
331 ProfileBytes string `json:"profileBytes,omitempty"`
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351 ProfileType string `json:"profileType,omitempty"`
352
353
354 StartTime string `json:"startTime,omitempty"`
355
356
357 googleapi.ServerResponse `json:"-"`
358
359
360
361
362
363 ForceSendFields []string `json:"-"`
364
365
366
367
368 NullFields []string `json:"-"`
369 }
370
371 func (s *Profile) MarshalJSON() ([]byte, error) {
372 type NoMethod Profile
373 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
374 }
375
376 type ProjectsProfilesCreateCall struct {
377 s *Service
378 parent string
379 createprofilerequest *CreateProfileRequest
380 urlParams_ gensupport.URLParams
381 ctx_ context.Context
382 header_ http.Header
383 }
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400 func (r *ProjectsProfilesService) Create(parent string, createprofilerequest *CreateProfileRequest) *ProjectsProfilesCreateCall {
401 c := &ProjectsProfilesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
402 c.parent = parent
403 c.createprofilerequest = createprofilerequest
404 return c
405 }
406
407
408
409
410 func (c *ProjectsProfilesCreateCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateCall {
411 c.urlParams_.Set("fields", googleapi.CombineFields(s))
412 return c
413 }
414
415
416 func (c *ProjectsProfilesCreateCall) Context(ctx context.Context) *ProjectsProfilesCreateCall {
417 c.ctx_ = ctx
418 return c
419 }
420
421
422
423 func (c *ProjectsProfilesCreateCall) Header() http.Header {
424 if c.header_ == nil {
425 c.header_ = make(http.Header)
426 }
427 return c.header_
428 }
429
430 func (c *ProjectsProfilesCreateCall) doRequest(alt string) (*http.Response, error) {
431 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
432 var body io.Reader = nil
433 body, err := googleapi.WithoutDataWrapper.JSONReader(c.createprofilerequest)
434 if err != nil {
435 return nil, err
436 }
437 c.urlParams_.Set("alt", alt)
438 c.urlParams_.Set("prettyPrint", "false")
439 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/profiles")
440 urls += "?" + c.urlParams_.Encode()
441 req, err := http.NewRequest("POST", urls, body)
442 if err != nil {
443 return nil, err
444 }
445 req.Header = reqHeaders
446 googleapi.Expand(req.URL, map[string]string{
447 "parent": c.parent,
448 })
449 return gensupport.SendRequest(c.ctx_, c.s.client, req)
450 }
451
452
453
454
455
456
457 func (c *ProjectsProfilesCreateCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
458 gensupport.SetOptions(c.urlParams_, opts...)
459 res, err := c.doRequest("json")
460 if res != nil && res.StatusCode == http.StatusNotModified {
461 if res.Body != nil {
462 res.Body.Close()
463 }
464 return nil, gensupport.WrapError(&googleapi.Error{
465 Code: res.StatusCode,
466 Header: res.Header,
467 })
468 }
469 if err != nil {
470 return nil, err
471 }
472 defer googleapi.CloseBody(res)
473 if err := googleapi.CheckResponse(res); err != nil {
474 return nil, gensupport.WrapError(err)
475 }
476 ret := &Profile{
477 ServerResponse: googleapi.ServerResponse{
478 Header: res.Header,
479 HTTPStatusCode: res.StatusCode,
480 },
481 }
482 target := &ret
483 if err := gensupport.DecodeResponse(target, res); err != nil {
484 return nil, err
485 }
486 return ret, nil
487 }
488
489 type ProjectsProfilesCreateOfflineCall struct {
490 s *Service
491 parent string
492 profile *Profile
493 urlParams_ gensupport.URLParams
494 ctx_ context.Context
495 header_ http.Header
496 }
497
498
499
500
501
502
503
504
505
506 func (r *ProjectsProfilesService) CreateOffline(parent string, profile *Profile) *ProjectsProfilesCreateOfflineCall {
507 c := &ProjectsProfilesCreateOfflineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
508 c.parent = parent
509 c.profile = profile
510 return c
511 }
512
513
514
515
516 func (c *ProjectsProfilesCreateOfflineCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateOfflineCall {
517 c.urlParams_.Set("fields", googleapi.CombineFields(s))
518 return c
519 }
520
521
522 func (c *ProjectsProfilesCreateOfflineCall) Context(ctx context.Context) *ProjectsProfilesCreateOfflineCall {
523 c.ctx_ = ctx
524 return c
525 }
526
527
528
529 func (c *ProjectsProfilesCreateOfflineCall) Header() http.Header {
530 if c.header_ == nil {
531 c.header_ = make(http.Header)
532 }
533 return c.header_
534 }
535
536 func (c *ProjectsProfilesCreateOfflineCall) doRequest(alt string) (*http.Response, error) {
537 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
538 var body io.Reader = nil
539 body, err := googleapi.WithoutDataWrapper.JSONReader(c.profile)
540 if err != nil {
541 return nil, err
542 }
543 c.urlParams_.Set("alt", alt)
544 c.urlParams_.Set("prettyPrint", "false")
545 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/profiles:createOffline")
546 urls += "?" + c.urlParams_.Encode()
547 req, err := http.NewRequest("POST", urls, body)
548 if err != nil {
549 return nil, err
550 }
551 req.Header = reqHeaders
552 googleapi.Expand(req.URL, map[string]string{
553 "parent": c.parent,
554 })
555 return gensupport.SendRequest(c.ctx_, c.s.client, req)
556 }
557
558
559
560
561
562
563 func (c *ProjectsProfilesCreateOfflineCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
564 gensupport.SetOptions(c.urlParams_, opts...)
565 res, err := c.doRequest("json")
566 if res != nil && res.StatusCode == http.StatusNotModified {
567 if res.Body != nil {
568 res.Body.Close()
569 }
570 return nil, gensupport.WrapError(&googleapi.Error{
571 Code: res.StatusCode,
572 Header: res.Header,
573 })
574 }
575 if err != nil {
576 return nil, err
577 }
578 defer googleapi.CloseBody(res)
579 if err := googleapi.CheckResponse(res); err != nil {
580 return nil, gensupport.WrapError(err)
581 }
582 ret := &Profile{
583 ServerResponse: googleapi.ServerResponse{
584 Header: res.Header,
585 HTTPStatusCode: res.StatusCode,
586 },
587 }
588 target := &ret
589 if err := gensupport.DecodeResponse(target, res); err != nil {
590 return nil, err
591 }
592 return ret, nil
593 }
594
595 type ProjectsProfilesListCall struct {
596 s *Service
597 parent string
598 urlParams_ gensupport.URLParams
599 ifNoneMatch_ string
600 ctx_ context.Context
601 header_ http.Header
602 }
603
604
605
606
607
608
609 func (r *ProjectsProfilesService) List(parent string) *ProjectsProfilesListCall {
610 c := &ProjectsProfilesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
611 c.parent = parent
612 return c
613 }
614
615
616
617 func (c *ProjectsProfilesListCall) PageSize(pageSize int64) *ProjectsProfilesListCall {
618 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
619 return c
620 }
621
622
623
624
625
626 func (c *ProjectsProfilesListCall) PageToken(pageToken string) *ProjectsProfilesListCall {
627 c.urlParams_.Set("pageToken", pageToken)
628 return c
629 }
630
631
632
633
634 func (c *ProjectsProfilesListCall) Fields(s ...googleapi.Field) *ProjectsProfilesListCall {
635 c.urlParams_.Set("fields", googleapi.CombineFields(s))
636 return c
637 }
638
639
640
641
642 func (c *ProjectsProfilesListCall) IfNoneMatch(entityTag string) *ProjectsProfilesListCall {
643 c.ifNoneMatch_ = entityTag
644 return c
645 }
646
647
648 func (c *ProjectsProfilesListCall) Context(ctx context.Context) *ProjectsProfilesListCall {
649 c.ctx_ = ctx
650 return c
651 }
652
653
654
655 func (c *ProjectsProfilesListCall) Header() http.Header {
656 if c.header_ == nil {
657 c.header_ = make(http.Header)
658 }
659 return c.header_
660 }
661
662 func (c *ProjectsProfilesListCall) doRequest(alt string) (*http.Response, error) {
663 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
664 if c.ifNoneMatch_ != "" {
665 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
666 }
667 var body io.Reader = nil
668 c.urlParams_.Set("alt", alt)
669 c.urlParams_.Set("prettyPrint", "false")
670 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/profiles")
671 urls += "?" + c.urlParams_.Encode()
672 req, err := http.NewRequest("GET", urls, body)
673 if err != nil {
674 return nil, err
675 }
676 req.Header = reqHeaders
677 googleapi.Expand(req.URL, map[string]string{
678 "parent": c.parent,
679 })
680 return gensupport.SendRequest(c.ctx_, c.s.client, req)
681 }
682
683
684
685
686
687
688
689 func (c *ProjectsProfilesListCall) Do(opts ...googleapi.CallOption) (*ListProfilesResponse, error) {
690 gensupport.SetOptions(c.urlParams_, opts...)
691 res, err := c.doRequest("json")
692 if res != nil && res.StatusCode == http.StatusNotModified {
693 if res.Body != nil {
694 res.Body.Close()
695 }
696 return nil, gensupport.WrapError(&googleapi.Error{
697 Code: res.StatusCode,
698 Header: res.Header,
699 })
700 }
701 if err != nil {
702 return nil, err
703 }
704 defer googleapi.CloseBody(res)
705 if err := googleapi.CheckResponse(res); err != nil {
706 return nil, gensupport.WrapError(err)
707 }
708 ret := &ListProfilesResponse{
709 ServerResponse: googleapi.ServerResponse{
710 Header: res.Header,
711 HTTPStatusCode: res.StatusCode,
712 },
713 }
714 target := &ret
715 if err := gensupport.DecodeResponse(target, res); err != nil {
716 return nil, err
717 }
718 return ret, nil
719 }
720
721
722
723
724 func (c *ProjectsProfilesListCall) Pages(ctx context.Context, f func(*ListProfilesResponse) error) error {
725 c.ctx_ = ctx
726 defer c.PageToken(c.urlParams_.Get("pageToken"))
727 for {
728 x, err := c.Do()
729 if err != nil {
730 return err
731 }
732 if err := f(x); err != nil {
733 return err
734 }
735 if x.NextPageToken == "" {
736 return nil
737 }
738 c.PageToken(x.NextPageToken)
739 }
740 }
741
742 type ProjectsProfilesPatchCall struct {
743 s *Service
744 name string
745 profile *Profile
746 urlParams_ gensupport.URLParams
747 ctx_ context.Context
748 header_ http.Header
749 }
750
751
752
753
754
755
756
757
758
759
760 func (r *ProjectsProfilesService) Patch(name string, profile *Profile) *ProjectsProfilesPatchCall {
761 c := &ProjectsProfilesPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
762 c.name = name
763 c.profile = profile
764 return c
765 }
766
767
768
769
770
771 func (c *ProjectsProfilesPatchCall) UpdateMask(updateMask string) *ProjectsProfilesPatchCall {
772 c.urlParams_.Set("updateMask", updateMask)
773 return c
774 }
775
776
777
778
779 func (c *ProjectsProfilesPatchCall) Fields(s ...googleapi.Field) *ProjectsProfilesPatchCall {
780 c.urlParams_.Set("fields", googleapi.CombineFields(s))
781 return c
782 }
783
784
785 func (c *ProjectsProfilesPatchCall) Context(ctx context.Context) *ProjectsProfilesPatchCall {
786 c.ctx_ = ctx
787 return c
788 }
789
790
791
792 func (c *ProjectsProfilesPatchCall) Header() http.Header {
793 if c.header_ == nil {
794 c.header_ = make(http.Header)
795 }
796 return c.header_
797 }
798
799 func (c *ProjectsProfilesPatchCall) doRequest(alt string) (*http.Response, error) {
800 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
801 var body io.Reader = nil
802 body, err := googleapi.WithoutDataWrapper.JSONReader(c.profile)
803 if err != nil {
804 return nil, err
805 }
806 c.urlParams_.Set("alt", alt)
807 c.urlParams_.Set("prettyPrint", "false")
808 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
809 urls += "?" + c.urlParams_.Encode()
810 req, err := http.NewRequest("PATCH", urls, body)
811 if err != nil {
812 return nil, err
813 }
814 req.Header = reqHeaders
815 googleapi.Expand(req.URL, map[string]string{
816 "name": c.name,
817 })
818 return gensupport.SendRequest(c.ctx_, c.s.client, req)
819 }
820
821
822
823
824
825
826 func (c *ProjectsProfilesPatchCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
827 gensupport.SetOptions(c.urlParams_, opts...)
828 res, err := c.doRequest("json")
829 if res != nil && res.StatusCode == http.StatusNotModified {
830 if res.Body != nil {
831 res.Body.Close()
832 }
833 return nil, gensupport.WrapError(&googleapi.Error{
834 Code: res.StatusCode,
835 Header: res.Header,
836 })
837 }
838 if err != nil {
839 return nil, err
840 }
841 defer googleapi.CloseBody(res)
842 if err := googleapi.CheckResponse(res); err != nil {
843 return nil, gensupport.WrapError(err)
844 }
845 ret := &Profile{
846 ServerResponse: googleapi.ServerResponse{
847 Header: res.Header,
848 HTTPStatusCode: res.StatusCode,
849 },
850 }
851 target := &ret
852 if err := gensupport.DecodeResponse(target, res); err != nil {
853 return nil, err
854 }
855 return ret, nil
856 }
857
View as plain text