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 apikeys
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 = "apikeys:v2"
95 const apiName = "apikeys"
96 const apiVersion = "v2"
97 const basePath = "https://apikeys.googleapis.com/"
98 const basePathTemplate = "https://apikeys.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://apikeys.mtls.googleapis.com/"
100
101
102 const (
103
104
105 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
106
107
108
109 CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only"
110 )
111
112
113 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
114 scopesOption := internaloption.WithDefaultScopes(
115 "https://www.googleapis.com/auth/cloud-platform",
116 "https://www.googleapis.com/auth/cloud-platform.read-only",
117 )
118
119 opts = append([]option.ClientOption{scopesOption}, opts...)
120 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
121 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
122 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
123 opts = append(opts, internaloption.EnableNewAuthLibrary())
124 client, endpoint, err := htransport.NewClient(ctx, opts...)
125 if err != nil {
126 return nil, err
127 }
128 s, err := New(client)
129 if err != nil {
130 return nil, err
131 }
132 if endpoint != "" {
133 s.BasePath = endpoint
134 }
135 return s, nil
136 }
137
138
139
140
141
142
143 func New(client *http.Client) (*Service, error) {
144 if client == nil {
145 return nil, errors.New("client is nil")
146 }
147 s := &Service{client: client, BasePath: basePath}
148 s.Keys = NewKeysService(s)
149 s.Operations = NewOperationsService(s)
150 s.Projects = NewProjectsService(s)
151 return s, nil
152 }
153
154 type Service struct {
155 client *http.Client
156 BasePath string
157 UserAgent string
158
159 Keys *KeysService
160
161 Operations *OperationsService
162
163 Projects *ProjectsService
164 }
165
166 func (s *Service) userAgent() string {
167 if s.UserAgent == "" {
168 return googleapi.UserAgent
169 }
170 return googleapi.UserAgent + " " + s.UserAgent
171 }
172
173 func NewKeysService(s *Service) *KeysService {
174 rs := &KeysService{s: s}
175 return rs
176 }
177
178 type KeysService struct {
179 s *Service
180 }
181
182 func NewOperationsService(s *Service) *OperationsService {
183 rs := &OperationsService{s: s}
184 return rs
185 }
186
187 type OperationsService struct {
188 s *Service
189 }
190
191 func NewProjectsService(s *Service) *ProjectsService {
192 rs := &ProjectsService{s: s}
193 rs.Locations = NewProjectsLocationsService(s)
194 return rs
195 }
196
197 type ProjectsService struct {
198 s *Service
199
200 Locations *ProjectsLocationsService
201 }
202
203 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
204 rs := &ProjectsLocationsService{s: s}
205 rs.Keys = NewProjectsLocationsKeysService(s)
206 return rs
207 }
208
209 type ProjectsLocationsService struct {
210 s *Service
211
212 Keys *ProjectsLocationsKeysService
213 }
214
215 func NewProjectsLocationsKeysService(s *Service) *ProjectsLocationsKeysService {
216 rs := &ProjectsLocationsKeysService{s: s}
217 return rs
218 }
219
220 type ProjectsLocationsKeysService struct {
221 s *Service
222 }
223
224
225
226 type Operation struct {
227
228
229
230 Done bool `json:"done,omitempty"`
231
232 Error *Status `json:"error,omitempty"`
233
234
235
236
237 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
238
239
240
241 Name string `json:"name,omitempty"`
242
243
244
245
246
247
248
249 Response googleapi.RawMessage `json:"response,omitempty"`
250
251
252 googleapi.ServerResponse `json:"-"`
253
254
255
256
257
258 ForceSendFields []string `json:"-"`
259
260
261
262
263 NullFields []string `json:"-"`
264 }
265
266 func (s *Operation) MarshalJSON() ([]byte, error) {
267 type NoMethod Operation
268 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
269 }
270
271
272
273
274
275
276
277 type Status struct {
278
279 Code int64 `json:"code,omitempty"`
280
281
282 Details []googleapi.RawMessage `json:"details,omitempty"`
283
284
285
286 Message string `json:"message,omitempty"`
287
288
289
290
291
292 ForceSendFields []string `json:"-"`
293
294
295
296
297 NullFields []string `json:"-"`
298 }
299
300 func (s *Status) MarshalJSON() ([]byte, error) {
301 type NoMethod Status
302 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
303 }
304
305
306 type V2AndroidApplication struct {
307
308 PackageName string `json:"packageName,omitempty"`
309
310
311
312
313 Sha1Fingerprint string `json:"sha1Fingerprint,omitempty"`
314
315
316
317
318
319 ForceSendFields []string `json:"-"`
320
321
322
323
324 NullFields []string `json:"-"`
325 }
326
327 func (s *V2AndroidApplication) MarshalJSON() ([]byte, error) {
328 type NoMethod V2AndroidApplication
329 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
330 }
331
332
333 type V2AndroidKeyRestrictions struct {
334
335
336 AllowedApplications []*V2AndroidApplication `json:"allowedApplications,omitempty"`
337
338
339
340
341
342 ForceSendFields []string `json:"-"`
343
344
345
346
347 NullFields []string `json:"-"`
348 }
349
350 func (s *V2AndroidKeyRestrictions) MarshalJSON() ([]byte, error) {
351 type NoMethod V2AndroidKeyRestrictions
352 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
353 }
354
355
356
357 type V2ApiTarget struct {
358
359
360
361
362
363 Methods []string `json:"methods,omitempty"`
364
365
366
367
368 Service string `json:"service,omitempty"`
369
370
371
372
373
374 ForceSendFields []string `json:"-"`
375
376
377
378
379 NullFields []string `json:"-"`
380 }
381
382 func (s *V2ApiTarget) MarshalJSON() ([]byte, error) {
383 type NoMethod V2ApiTarget
384 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
385 }
386
387
388
389 type V2BrowserKeyRestrictions struct {
390
391
392 AllowedReferrers []string `json:"allowedReferrers,omitempty"`
393
394
395
396
397
398 ForceSendFields []string `json:"-"`
399
400
401
402
403 NullFields []string `json:"-"`
404 }
405
406 func (s *V2BrowserKeyRestrictions) MarshalJSON() ([]byte, error) {
407 type NoMethod V2BrowserKeyRestrictions
408 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
409 }
410
411
412 type V2GetKeyStringResponse struct {
413
414 KeyString string `json:"keyString,omitempty"`
415
416
417 googleapi.ServerResponse `json:"-"`
418
419
420
421
422
423 ForceSendFields []string `json:"-"`
424
425
426
427
428 NullFields []string `json:"-"`
429 }
430
431 func (s *V2GetKeyStringResponse) MarshalJSON() ([]byte, error) {
432 type NoMethod V2GetKeyStringResponse
433 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
434 }
435
436
437 type V2IosKeyRestrictions struct {
438
439
440 AllowedBundleIds []string `json:"allowedBundleIds,omitempty"`
441
442
443
444
445
446 ForceSendFields []string `json:"-"`
447
448
449
450
451 NullFields []string `json:"-"`
452 }
453
454 func (s *V2IosKeyRestrictions) MarshalJSON() ([]byte, error) {
455 type NoMethod V2IosKeyRestrictions
456 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
457 }
458
459
460 type V2Key struct {
461
462
463
464
465 Annotations map[string]string `json:"annotations,omitempty"`
466
467
468 CreateTime string `json:"createTime,omitempty"`
469
470
471 DeleteTime string `json:"deleteTime,omitempty"`
472
473
474 DisplayName string `json:"displayName,omitempty"`
475
476
477
478
479 Etag string `json:"etag,omitempty"`
480
481
482 KeyString string `json:"keyString,omitempty"`
483
484
485
486
487
488 Name string `json:"name,omitempty"`
489
490 Restrictions *V2Restrictions `json:"restrictions,omitempty"`
491
492 Uid string `json:"uid,omitempty"`
493
494
495 UpdateTime string `json:"updateTime,omitempty"`
496
497
498 googleapi.ServerResponse `json:"-"`
499
500
501
502
503
504 ForceSendFields []string `json:"-"`
505
506
507
508
509 NullFields []string `json:"-"`
510 }
511
512 func (s *V2Key) MarshalJSON() ([]byte, error) {
513 type NoMethod V2Key
514 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
515 }
516
517
518 type V2ListKeysResponse struct {
519
520 Keys []*V2Key `json:"keys,omitempty"`
521
522 NextPageToken string `json:"nextPageToken,omitempty"`
523
524
525 googleapi.ServerResponse `json:"-"`
526
527
528
529
530
531 ForceSendFields []string `json:"-"`
532
533
534
535
536 NullFields []string `json:"-"`
537 }
538
539 func (s *V2ListKeysResponse) MarshalJSON() ([]byte, error) {
540 type NoMethod V2ListKeysResponse
541 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
542 }
543
544
545 type V2LookupKeyResponse struct {
546
547
548 Name string `json:"name,omitempty"`
549
550
551 Parent string `json:"parent,omitempty"`
552
553
554 googleapi.ServerResponse `json:"-"`
555
556
557
558
559
560 ForceSendFields []string `json:"-"`
561
562
563
564
565 NullFields []string `json:"-"`
566 }
567
568 func (s *V2LookupKeyResponse) MarshalJSON() ([]byte, error) {
569 type NoMethod V2LookupKeyResponse
570 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
571 }
572
573
574 type V2Restrictions struct {
575
576 AndroidKeyRestrictions *V2AndroidKeyRestrictions `json:"androidKeyRestrictions,omitempty"`
577
578
579
580 ApiTargets []*V2ApiTarget `json:"apiTargets,omitempty"`
581
582
583 BrowserKeyRestrictions *V2BrowserKeyRestrictions `json:"browserKeyRestrictions,omitempty"`
584
585 IosKeyRestrictions *V2IosKeyRestrictions `json:"iosKeyRestrictions,omitempty"`
586
587
588 ServerKeyRestrictions *V2ServerKeyRestrictions `json:"serverKeyRestrictions,omitempty"`
589
590
591
592
593
594 ForceSendFields []string `json:"-"`
595
596
597
598
599 NullFields []string `json:"-"`
600 }
601
602 func (s *V2Restrictions) MarshalJSON() ([]byte, error) {
603 type NoMethod V2Restrictions
604 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
605 }
606
607
608
609 type V2ServerKeyRestrictions struct {
610
611
612 AllowedIps []string `json:"allowedIps,omitempty"`
613
614
615
616
617
618 ForceSendFields []string `json:"-"`
619
620
621
622
623 NullFields []string `json:"-"`
624 }
625
626 func (s *V2ServerKeyRestrictions) MarshalJSON() ([]byte, error) {
627 type NoMethod V2ServerKeyRestrictions
628 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
629 }
630
631
632 type V2UndeleteKeyRequest struct {
633 }
634
635 type KeysLookupKeyCall struct {
636 s *Service
637 urlParams_ gensupport.URLParams
638 ifNoneMatch_ string
639 ctx_ context.Context
640 header_ http.Header
641 }
642
643
644
645
646
647 func (r *KeysService) LookupKey() *KeysLookupKeyCall {
648 c := &KeysLookupKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
649 return c
650 }
651
652
653
654 func (c *KeysLookupKeyCall) KeyString(keyString string) *KeysLookupKeyCall {
655 c.urlParams_.Set("keyString", keyString)
656 return c
657 }
658
659
660
661
662 func (c *KeysLookupKeyCall) Fields(s ...googleapi.Field) *KeysLookupKeyCall {
663 c.urlParams_.Set("fields", googleapi.CombineFields(s))
664 return c
665 }
666
667
668
669
670 func (c *KeysLookupKeyCall) IfNoneMatch(entityTag string) *KeysLookupKeyCall {
671 c.ifNoneMatch_ = entityTag
672 return c
673 }
674
675
676 func (c *KeysLookupKeyCall) Context(ctx context.Context) *KeysLookupKeyCall {
677 c.ctx_ = ctx
678 return c
679 }
680
681
682
683 func (c *KeysLookupKeyCall) Header() http.Header {
684 if c.header_ == nil {
685 c.header_ = make(http.Header)
686 }
687 return c.header_
688 }
689
690 func (c *KeysLookupKeyCall) doRequest(alt string) (*http.Response, error) {
691 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
692 if c.ifNoneMatch_ != "" {
693 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
694 }
695 var body io.Reader = nil
696 c.urlParams_.Set("alt", alt)
697 c.urlParams_.Set("prettyPrint", "false")
698 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/keys:lookupKey")
699 urls += "?" + c.urlParams_.Encode()
700 req, err := http.NewRequest("GET", urls, body)
701 if err != nil {
702 return nil, err
703 }
704 req.Header = reqHeaders
705 return gensupport.SendRequest(c.ctx_, c.s.client, req)
706 }
707
708
709
710
711
712
713
714 func (c *KeysLookupKeyCall) Do(opts ...googleapi.CallOption) (*V2LookupKeyResponse, error) {
715 gensupport.SetOptions(c.urlParams_, opts...)
716 res, err := c.doRequest("json")
717 if res != nil && res.StatusCode == http.StatusNotModified {
718 if res.Body != nil {
719 res.Body.Close()
720 }
721 return nil, gensupport.WrapError(&googleapi.Error{
722 Code: res.StatusCode,
723 Header: res.Header,
724 })
725 }
726 if err != nil {
727 return nil, err
728 }
729 defer googleapi.CloseBody(res)
730 if err := googleapi.CheckResponse(res); err != nil {
731 return nil, gensupport.WrapError(err)
732 }
733 ret := &V2LookupKeyResponse{
734 ServerResponse: googleapi.ServerResponse{
735 Header: res.Header,
736 HTTPStatusCode: res.StatusCode,
737 },
738 }
739 target := &ret
740 if err := gensupport.DecodeResponse(target, res); err != nil {
741 return nil, err
742 }
743 return ret, nil
744 }
745
746 type OperationsGetCall struct {
747 s *Service
748 name string
749 urlParams_ gensupport.URLParams
750 ifNoneMatch_ string
751 ctx_ context.Context
752 header_ http.Header
753 }
754
755
756
757
758
759
760 func (r *OperationsService) Get(name string) *OperationsGetCall {
761 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
762 c.name = name
763 return c
764 }
765
766
767
768
769 func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall {
770 c.urlParams_.Set("fields", googleapi.CombineFields(s))
771 return c
772 }
773
774
775
776
777 func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall {
778 c.ifNoneMatch_ = entityTag
779 return c
780 }
781
782
783 func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall {
784 c.ctx_ = ctx
785 return c
786 }
787
788
789
790 func (c *OperationsGetCall) Header() http.Header {
791 if c.header_ == nil {
792 c.header_ = make(http.Header)
793 }
794 return c.header_
795 }
796
797 func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) {
798 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
799 if c.ifNoneMatch_ != "" {
800 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
801 }
802 var body io.Reader = nil
803 c.urlParams_.Set("alt", alt)
804 c.urlParams_.Set("prettyPrint", "false")
805 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
806 urls += "?" + c.urlParams_.Encode()
807 req, err := http.NewRequest("GET", urls, body)
808 if err != nil {
809 return nil, err
810 }
811 req.Header = reqHeaders
812 googleapi.Expand(req.URL, map[string]string{
813 "name": c.name,
814 })
815 return gensupport.SendRequest(c.ctx_, c.s.client, req)
816 }
817
818
819
820
821
822
823 func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
824 gensupport.SetOptions(c.urlParams_, opts...)
825 res, err := c.doRequest("json")
826 if res != nil && res.StatusCode == http.StatusNotModified {
827 if res.Body != nil {
828 res.Body.Close()
829 }
830 return nil, gensupport.WrapError(&googleapi.Error{
831 Code: res.StatusCode,
832 Header: res.Header,
833 })
834 }
835 if err != nil {
836 return nil, err
837 }
838 defer googleapi.CloseBody(res)
839 if err := googleapi.CheckResponse(res); err != nil {
840 return nil, gensupport.WrapError(err)
841 }
842 ret := &Operation{
843 ServerResponse: googleapi.ServerResponse{
844 Header: res.Header,
845 HTTPStatusCode: res.StatusCode,
846 },
847 }
848 target := &ret
849 if err := gensupport.DecodeResponse(target, res); err != nil {
850 return nil, err
851 }
852 return ret, nil
853 }
854
855 type ProjectsLocationsKeysCreateCall struct {
856 s *Service
857 parent string
858 v2key *V2Key
859 urlParams_ gensupport.URLParams
860 ctx_ context.Context
861 header_ http.Header
862 }
863
864
865
866
867
868 func (r *ProjectsLocationsKeysService) Create(parent string, v2key *V2Key) *ProjectsLocationsKeysCreateCall {
869 c := &ProjectsLocationsKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
870 c.parent = parent
871 c.v2key = v2key
872 return c
873 }
874
875
876
877
878
879
880
881 func (c *ProjectsLocationsKeysCreateCall) KeyId(keyId string) *ProjectsLocationsKeysCreateCall {
882 c.urlParams_.Set("keyId", keyId)
883 return c
884 }
885
886
887
888
889 func (c *ProjectsLocationsKeysCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysCreateCall {
890 c.urlParams_.Set("fields", googleapi.CombineFields(s))
891 return c
892 }
893
894
895 func (c *ProjectsLocationsKeysCreateCall) Context(ctx context.Context) *ProjectsLocationsKeysCreateCall {
896 c.ctx_ = ctx
897 return c
898 }
899
900
901
902 func (c *ProjectsLocationsKeysCreateCall) Header() http.Header {
903 if c.header_ == nil {
904 c.header_ = make(http.Header)
905 }
906 return c.header_
907 }
908
909 func (c *ProjectsLocationsKeysCreateCall) doRequest(alt string) (*http.Response, error) {
910 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
911 var body io.Reader = nil
912 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key)
913 if err != nil {
914 return nil, err
915 }
916 c.urlParams_.Set("alt", alt)
917 c.urlParams_.Set("prettyPrint", "false")
918 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys")
919 urls += "?" + c.urlParams_.Encode()
920 req, err := http.NewRequest("POST", urls, body)
921 if err != nil {
922 return nil, err
923 }
924 req.Header = reqHeaders
925 googleapi.Expand(req.URL, map[string]string{
926 "parent": c.parent,
927 })
928 return gensupport.SendRequest(c.ctx_, c.s.client, req)
929 }
930
931
932
933
934
935
936 func (c *ProjectsLocationsKeysCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
937 gensupport.SetOptions(c.urlParams_, opts...)
938 res, err := c.doRequest("json")
939 if res != nil && res.StatusCode == http.StatusNotModified {
940 if res.Body != nil {
941 res.Body.Close()
942 }
943 return nil, gensupport.WrapError(&googleapi.Error{
944 Code: res.StatusCode,
945 Header: res.Header,
946 })
947 }
948 if err != nil {
949 return nil, err
950 }
951 defer googleapi.CloseBody(res)
952 if err := googleapi.CheckResponse(res); err != nil {
953 return nil, gensupport.WrapError(err)
954 }
955 ret := &Operation{
956 ServerResponse: googleapi.ServerResponse{
957 Header: res.Header,
958 HTTPStatusCode: res.StatusCode,
959 },
960 }
961 target := &ret
962 if err := gensupport.DecodeResponse(target, res); err != nil {
963 return nil, err
964 }
965 return ret, nil
966 }
967
968 type ProjectsLocationsKeysDeleteCall struct {
969 s *Service
970 name string
971 urlParams_ gensupport.URLParams
972 ctx_ context.Context
973 header_ http.Header
974 }
975
976
977
978
979
980
981 func (r *ProjectsLocationsKeysService) Delete(name string) *ProjectsLocationsKeysDeleteCall {
982 c := &ProjectsLocationsKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
983 c.name = name
984 return c
985 }
986
987
988
989
990 func (c *ProjectsLocationsKeysDeleteCall) Etag(etag string) *ProjectsLocationsKeysDeleteCall {
991 c.urlParams_.Set("etag", etag)
992 return c
993 }
994
995
996
997
998 func (c *ProjectsLocationsKeysDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysDeleteCall {
999 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1000 return c
1001 }
1002
1003
1004 func (c *ProjectsLocationsKeysDeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysDeleteCall {
1005 c.ctx_ = ctx
1006 return c
1007 }
1008
1009
1010
1011 func (c *ProjectsLocationsKeysDeleteCall) Header() http.Header {
1012 if c.header_ == nil {
1013 c.header_ = make(http.Header)
1014 }
1015 return c.header_
1016 }
1017
1018 func (c *ProjectsLocationsKeysDeleteCall) doRequest(alt string) (*http.Response, error) {
1019 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1020 var body io.Reader = nil
1021 c.urlParams_.Set("alt", alt)
1022 c.urlParams_.Set("prettyPrint", "false")
1023 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
1024 urls += "?" + c.urlParams_.Encode()
1025 req, err := http.NewRequest("DELETE", urls, body)
1026 if err != nil {
1027 return nil, err
1028 }
1029 req.Header = reqHeaders
1030 googleapi.Expand(req.URL, map[string]string{
1031 "name": c.name,
1032 })
1033 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1034 }
1035
1036
1037
1038
1039
1040
1041 func (c *ProjectsLocationsKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1042 gensupport.SetOptions(c.urlParams_, opts...)
1043 res, err := c.doRequest("json")
1044 if res != nil && res.StatusCode == http.StatusNotModified {
1045 if res.Body != nil {
1046 res.Body.Close()
1047 }
1048 return nil, gensupport.WrapError(&googleapi.Error{
1049 Code: res.StatusCode,
1050 Header: res.Header,
1051 })
1052 }
1053 if err != nil {
1054 return nil, err
1055 }
1056 defer googleapi.CloseBody(res)
1057 if err := googleapi.CheckResponse(res); err != nil {
1058 return nil, gensupport.WrapError(err)
1059 }
1060 ret := &Operation{
1061 ServerResponse: googleapi.ServerResponse{
1062 Header: res.Header,
1063 HTTPStatusCode: res.StatusCode,
1064 },
1065 }
1066 target := &ret
1067 if err := gensupport.DecodeResponse(target, res); err != nil {
1068 return nil, err
1069 }
1070 return ret, nil
1071 }
1072
1073 type ProjectsLocationsKeysGetCall struct {
1074 s *Service
1075 name string
1076 urlParams_ gensupport.URLParams
1077 ifNoneMatch_ string
1078 ctx_ context.Context
1079 header_ http.Header
1080 }
1081
1082
1083
1084
1085
1086
1087 func (r *ProjectsLocationsKeysService) Get(name string) *ProjectsLocationsKeysGetCall {
1088 c := &ProjectsLocationsKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1089 c.name = name
1090 return c
1091 }
1092
1093
1094
1095
1096 func (c *ProjectsLocationsKeysGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetCall {
1097 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1098 return c
1099 }
1100
1101
1102
1103
1104 func (c *ProjectsLocationsKeysGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetCall {
1105 c.ifNoneMatch_ = entityTag
1106 return c
1107 }
1108
1109
1110 func (c *ProjectsLocationsKeysGetCall) Context(ctx context.Context) *ProjectsLocationsKeysGetCall {
1111 c.ctx_ = ctx
1112 return c
1113 }
1114
1115
1116
1117 func (c *ProjectsLocationsKeysGetCall) Header() http.Header {
1118 if c.header_ == nil {
1119 c.header_ = make(http.Header)
1120 }
1121 return c.header_
1122 }
1123
1124 func (c *ProjectsLocationsKeysGetCall) doRequest(alt string) (*http.Response, error) {
1125 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1126 if c.ifNoneMatch_ != "" {
1127 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1128 }
1129 var body io.Reader = nil
1130 c.urlParams_.Set("alt", alt)
1131 c.urlParams_.Set("prettyPrint", "false")
1132 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
1133 urls += "?" + c.urlParams_.Encode()
1134 req, err := http.NewRequest("GET", urls, body)
1135 if err != nil {
1136 return nil, err
1137 }
1138 req.Header = reqHeaders
1139 googleapi.Expand(req.URL, map[string]string{
1140 "name": c.name,
1141 })
1142 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1143 }
1144
1145
1146
1147
1148
1149
1150 func (c *ProjectsLocationsKeysGetCall) Do(opts ...googleapi.CallOption) (*V2Key, error) {
1151 gensupport.SetOptions(c.urlParams_, opts...)
1152 res, err := c.doRequest("json")
1153 if res != nil && res.StatusCode == http.StatusNotModified {
1154 if res.Body != nil {
1155 res.Body.Close()
1156 }
1157 return nil, gensupport.WrapError(&googleapi.Error{
1158 Code: res.StatusCode,
1159 Header: res.Header,
1160 })
1161 }
1162 if err != nil {
1163 return nil, err
1164 }
1165 defer googleapi.CloseBody(res)
1166 if err := googleapi.CheckResponse(res); err != nil {
1167 return nil, gensupport.WrapError(err)
1168 }
1169 ret := &V2Key{
1170 ServerResponse: googleapi.ServerResponse{
1171 Header: res.Header,
1172 HTTPStatusCode: res.StatusCode,
1173 },
1174 }
1175 target := &ret
1176 if err := gensupport.DecodeResponse(target, res); err != nil {
1177 return nil, err
1178 }
1179 return ret, nil
1180 }
1181
1182 type ProjectsLocationsKeysGetKeyStringCall struct {
1183 s *Service
1184 name string
1185 urlParams_ gensupport.URLParams
1186 ifNoneMatch_ string
1187 ctx_ context.Context
1188 header_ http.Header
1189 }
1190
1191
1192
1193
1194
1195 func (r *ProjectsLocationsKeysService) GetKeyString(name string) *ProjectsLocationsKeysGetKeyStringCall {
1196 c := &ProjectsLocationsKeysGetKeyStringCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1197 c.name = name
1198 return c
1199 }
1200
1201
1202
1203
1204 func (c *ProjectsLocationsKeysGetKeyStringCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetKeyStringCall {
1205 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1206 return c
1207 }
1208
1209
1210
1211
1212 func (c *ProjectsLocationsKeysGetKeyStringCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetKeyStringCall {
1213 c.ifNoneMatch_ = entityTag
1214 return c
1215 }
1216
1217
1218 func (c *ProjectsLocationsKeysGetKeyStringCall) Context(ctx context.Context) *ProjectsLocationsKeysGetKeyStringCall {
1219 c.ctx_ = ctx
1220 return c
1221 }
1222
1223
1224
1225 func (c *ProjectsLocationsKeysGetKeyStringCall) Header() http.Header {
1226 if c.header_ == nil {
1227 c.header_ = make(http.Header)
1228 }
1229 return c.header_
1230 }
1231
1232 func (c *ProjectsLocationsKeysGetKeyStringCall) doRequest(alt string) (*http.Response, error) {
1233 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1234 if c.ifNoneMatch_ != "" {
1235 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1236 }
1237 var body io.Reader = nil
1238 c.urlParams_.Set("alt", alt)
1239 c.urlParams_.Set("prettyPrint", "false")
1240 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}/keyString")
1241 urls += "?" + c.urlParams_.Encode()
1242 req, err := http.NewRequest("GET", urls, body)
1243 if err != nil {
1244 return nil, err
1245 }
1246 req.Header = reqHeaders
1247 googleapi.Expand(req.URL, map[string]string{
1248 "name": c.name,
1249 })
1250 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1251 }
1252
1253
1254
1255
1256
1257
1258
1259 func (c *ProjectsLocationsKeysGetKeyStringCall) Do(opts ...googleapi.CallOption) (*V2GetKeyStringResponse, error) {
1260 gensupport.SetOptions(c.urlParams_, opts...)
1261 res, err := c.doRequest("json")
1262 if res != nil && res.StatusCode == http.StatusNotModified {
1263 if res.Body != nil {
1264 res.Body.Close()
1265 }
1266 return nil, gensupport.WrapError(&googleapi.Error{
1267 Code: res.StatusCode,
1268 Header: res.Header,
1269 })
1270 }
1271 if err != nil {
1272 return nil, err
1273 }
1274 defer googleapi.CloseBody(res)
1275 if err := googleapi.CheckResponse(res); err != nil {
1276 return nil, gensupport.WrapError(err)
1277 }
1278 ret := &V2GetKeyStringResponse{
1279 ServerResponse: googleapi.ServerResponse{
1280 Header: res.Header,
1281 HTTPStatusCode: res.StatusCode,
1282 },
1283 }
1284 target := &ret
1285 if err := gensupport.DecodeResponse(target, res); err != nil {
1286 return nil, err
1287 }
1288 return ret, nil
1289 }
1290
1291 type ProjectsLocationsKeysListCall struct {
1292 s *Service
1293 parent string
1294 urlParams_ gensupport.URLParams
1295 ifNoneMatch_ string
1296 ctx_ context.Context
1297 header_ http.Header
1298 }
1299
1300
1301
1302
1303
1304
1305 func (r *ProjectsLocationsKeysService) List(parent string) *ProjectsLocationsKeysListCall {
1306 c := &ProjectsLocationsKeysListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1307 c.parent = parent
1308 return c
1309 }
1310
1311
1312
1313 func (c *ProjectsLocationsKeysListCall) PageSize(pageSize int64) *ProjectsLocationsKeysListCall {
1314 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
1315 return c
1316 }
1317
1318
1319
1320 func (c *ProjectsLocationsKeysListCall) PageToken(pageToken string) *ProjectsLocationsKeysListCall {
1321 c.urlParams_.Set("pageToken", pageToken)
1322 return c
1323 }
1324
1325
1326
1327 func (c *ProjectsLocationsKeysListCall) ShowDeleted(showDeleted bool) *ProjectsLocationsKeysListCall {
1328 c.urlParams_.Set("showDeleted", fmt.Sprint(showDeleted))
1329 return c
1330 }
1331
1332
1333
1334
1335 func (c *ProjectsLocationsKeysListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysListCall {
1336 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1337 return c
1338 }
1339
1340
1341
1342
1343 func (c *ProjectsLocationsKeysListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysListCall {
1344 c.ifNoneMatch_ = entityTag
1345 return c
1346 }
1347
1348
1349 func (c *ProjectsLocationsKeysListCall) Context(ctx context.Context) *ProjectsLocationsKeysListCall {
1350 c.ctx_ = ctx
1351 return c
1352 }
1353
1354
1355
1356 func (c *ProjectsLocationsKeysListCall) Header() http.Header {
1357 if c.header_ == nil {
1358 c.header_ = make(http.Header)
1359 }
1360 return c.header_
1361 }
1362
1363 func (c *ProjectsLocationsKeysListCall) doRequest(alt string) (*http.Response, error) {
1364 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1365 if c.ifNoneMatch_ != "" {
1366 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1367 }
1368 var body io.Reader = nil
1369 c.urlParams_.Set("alt", alt)
1370 c.urlParams_.Set("prettyPrint", "false")
1371 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys")
1372 urls += "?" + c.urlParams_.Encode()
1373 req, err := http.NewRequest("GET", urls, body)
1374 if err != nil {
1375 return nil, err
1376 }
1377 req.Header = reqHeaders
1378 googleapi.Expand(req.URL, map[string]string{
1379 "parent": c.parent,
1380 })
1381 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1382 }
1383
1384
1385
1386
1387
1388
1389
1390 func (c *ProjectsLocationsKeysListCall) Do(opts ...googleapi.CallOption) (*V2ListKeysResponse, error) {
1391 gensupport.SetOptions(c.urlParams_, opts...)
1392 res, err := c.doRequest("json")
1393 if res != nil && res.StatusCode == http.StatusNotModified {
1394 if res.Body != nil {
1395 res.Body.Close()
1396 }
1397 return nil, gensupport.WrapError(&googleapi.Error{
1398 Code: res.StatusCode,
1399 Header: res.Header,
1400 })
1401 }
1402 if err != nil {
1403 return nil, err
1404 }
1405 defer googleapi.CloseBody(res)
1406 if err := googleapi.CheckResponse(res); err != nil {
1407 return nil, gensupport.WrapError(err)
1408 }
1409 ret := &V2ListKeysResponse{
1410 ServerResponse: googleapi.ServerResponse{
1411 Header: res.Header,
1412 HTTPStatusCode: res.StatusCode,
1413 },
1414 }
1415 target := &ret
1416 if err := gensupport.DecodeResponse(target, res); err != nil {
1417 return nil, err
1418 }
1419 return ret, nil
1420 }
1421
1422
1423
1424
1425 func (c *ProjectsLocationsKeysListCall) Pages(ctx context.Context, f func(*V2ListKeysResponse) error) error {
1426 c.ctx_ = ctx
1427 defer c.PageToken(c.urlParams_.Get("pageToken"))
1428 for {
1429 x, err := c.Do()
1430 if err != nil {
1431 return err
1432 }
1433 if err := f(x); err != nil {
1434 return err
1435 }
1436 if x.NextPageToken == "" {
1437 return nil
1438 }
1439 c.PageToken(x.NextPageToken)
1440 }
1441 }
1442
1443 type ProjectsLocationsKeysPatchCall struct {
1444 s *Service
1445 name string
1446 v2key *V2Key
1447 urlParams_ gensupport.URLParams
1448 ctx_ context.Context
1449 header_ http.Header
1450 }
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461 func (r *ProjectsLocationsKeysService) Patch(name string, v2key *V2Key) *ProjectsLocationsKeysPatchCall {
1462 c := &ProjectsLocationsKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1463 c.name = name
1464 c.v2key = v2key
1465 return c
1466 }
1467
1468
1469
1470
1471
1472
1473
1474
1475 func (c *ProjectsLocationsKeysPatchCall) UpdateMask(updateMask string) *ProjectsLocationsKeysPatchCall {
1476 c.urlParams_.Set("updateMask", updateMask)
1477 return c
1478 }
1479
1480
1481
1482
1483 func (c *ProjectsLocationsKeysPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysPatchCall {
1484 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1485 return c
1486 }
1487
1488
1489 func (c *ProjectsLocationsKeysPatchCall) Context(ctx context.Context) *ProjectsLocationsKeysPatchCall {
1490 c.ctx_ = ctx
1491 return c
1492 }
1493
1494
1495
1496 func (c *ProjectsLocationsKeysPatchCall) Header() http.Header {
1497 if c.header_ == nil {
1498 c.header_ = make(http.Header)
1499 }
1500 return c.header_
1501 }
1502
1503 func (c *ProjectsLocationsKeysPatchCall) doRequest(alt string) (*http.Response, error) {
1504 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1505 var body io.Reader = nil
1506 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key)
1507 if err != nil {
1508 return nil, err
1509 }
1510 c.urlParams_.Set("alt", alt)
1511 c.urlParams_.Set("prettyPrint", "false")
1512 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
1513 urls += "?" + c.urlParams_.Encode()
1514 req, err := http.NewRequest("PATCH", urls, body)
1515 if err != nil {
1516 return nil, err
1517 }
1518 req.Header = reqHeaders
1519 googleapi.Expand(req.URL, map[string]string{
1520 "name": c.name,
1521 })
1522 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1523 }
1524
1525
1526
1527
1528
1529
1530 func (c *ProjectsLocationsKeysPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1531 gensupport.SetOptions(c.urlParams_, opts...)
1532 res, err := c.doRequest("json")
1533 if res != nil && res.StatusCode == http.StatusNotModified {
1534 if res.Body != nil {
1535 res.Body.Close()
1536 }
1537 return nil, gensupport.WrapError(&googleapi.Error{
1538 Code: res.StatusCode,
1539 Header: res.Header,
1540 })
1541 }
1542 if err != nil {
1543 return nil, err
1544 }
1545 defer googleapi.CloseBody(res)
1546 if err := googleapi.CheckResponse(res); err != nil {
1547 return nil, gensupport.WrapError(err)
1548 }
1549 ret := &Operation{
1550 ServerResponse: googleapi.ServerResponse{
1551 Header: res.Header,
1552 HTTPStatusCode: res.StatusCode,
1553 },
1554 }
1555 target := &ret
1556 if err := gensupport.DecodeResponse(target, res); err != nil {
1557 return nil, err
1558 }
1559 return ret, nil
1560 }
1561
1562 type ProjectsLocationsKeysUndeleteCall struct {
1563 s *Service
1564 name string
1565 v2undeletekeyrequest *V2UndeleteKeyRequest
1566 urlParams_ gensupport.URLParams
1567 ctx_ context.Context
1568 header_ http.Header
1569 }
1570
1571
1572
1573
1574
1575
1576 func (r *ProjectsLocationsKeysService) Undelete(name string, v2undeletekeyrequest *V2UndeleteKeyRequest) *ProjectsLocationsKeysUndeleteCall {
1577 c := &ProjectsLocationsKeysUndeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1578 c.name = name
1579 c.v2undeletekeyrequest = v2undeletekeyrequest
1580 return c
1581 }
1582
1583
1584
1585
1586 func (c *ProjectsLocationsKeysUndeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysUndeleteCall {
1587 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1588 return c
1589 }
1590
1591
1592 func (c *ProjectsLocationsKeysUndeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysUndeleteCall {
1593 c.ctx_ = ctx
1594 return c
1595 }
1596
1597
1598
1599 func (c *ProjectsLocationsKeysUndeleteCall) Header() http.Header {
1600 if c.header_ == nil {
1601 c.header_ = make(http.Header)
1602 }
1603 return c.header_
1604 }
1605
1606 func (c *ProjectsLocationsKeysUndeleteCall) doRequest(alt string) (*http.Response, error) {
1607 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1608 var body io.Reader = nil
1609 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2undeletekeyrequest)
1610 if err != nil {
1611 return nil, err
1612 }
1613 c.urlParams_.Set("alt", alt)
1614 c.urlParams_.Set("prettyPrint", "false")
1615 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}:undelete")
1616 urls += "?" + c.urlParams_.Encode()
1617 req, err := http.NewRequest("POST", urls, body)
1618 if err != nil {
1619 return nil, err
1620 }
1621 req.Header = reqHeaders
1622 googleapi.Expand(req.URL, map[string]string{
1623 "name": c.name,
1624 })
1625 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1626 }
1627
1628
1629
1630
1631
1632
1633 func (c *ProjectsLocationsKeysUndeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1634 gensupport.SetOptions(c.urlParams_, opts...)
1635 res, err := c.doRequest("json")
1636 if res != nil && res.StatusCode == http.StatusNotModified {
1637 if res.Body != nil {
1638 res.Body.Close()
1639 }
1640 return nil, gensupport.WrapError(&googleapi.Error{
1641 Code: res.StatusCode,
1642 Header: res.Header,
1643 })
1644 }
1645 if err != nil {
1646 return nil, err
1647 }
1648 defer googleapi.CloseBody(res)
1649 if err := googleapi.CheckResponse(res); err != nil {
1650 return nil, gensupport.WrapError(err)
1651 }
1652 ret := &Operation{
1653 ServerResponse: googleapi.ServerResponse{
1654 Header: res.Header,
1655 HTTPStatusCode: res.StatusCode,
1656 },
1657 }
1658 target := &ret
1659 if err := gensupport.DecodeResponse(target, res); err != nil {
1660 return nil, err
1661 }
1662 return ret, nil
1663 }
1664
View as plain text