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 firebasedatabase
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 = "firebasedatabase:v1beta"
95 const apiName = "firebasedatabase"
96 const apiVersion = "v1beta"
97 const basePath = "https://firebasedatabase.googleapis.com/"
98 const basePathTemplate = "https://firebasedatabase.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://firebasedatabase.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 FirebaseScope = "https://www.googleapis.com/auth/firebase"
113
114
115 FirebaseReadonlyScope = "https://www.googleapis.com/auth/firebase.readonly"
116 )
117
118
119 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
120 scopesOption := internaloption.WithDefaultScopes(
121 "https://www.googleapis.com/auth/cloud-platform",
122 "https://www.googleapis.com/auth/cloud-platform.read-only",
123 "https://www.googleapis.com/auth/firebase",
124 "https://www.googleapis.com/auth/firebase.readonly",
125 )
126
127 opts = append([]option.ClientOption{scopesOption}, opts...)
128 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
129 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
130 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
131 opts = append(opts, internaloption.EnableNewAuthLibrary())
132 client, endpoint, err := htransport.NewClient(ctx, opts...)
133 if err != nil {
134 return nil, err
135 }
136 s, err := New(client)
137 if err != nil {
138 return nil, err
139 }
140 if endpoint != "" {
141 s.BasePath = endpoint
142 }
143 return s, nil
144 }
145
146
147
148
149
150
151 func New(client *http.Client) (*Service, error) {
152 if client == nil {
153 return nil, errors.New("client is nil")
154 }
155 s := &Service{client: client, BasePath: basePath}
156 s.Projects = NewProjectsService(s)
157 return s, nil
158 }
159
160 type Service struct {
161 client *http.Client
162 BasePath string
163 UserAgent string
164
165 Projects *ProjectsService
166 }
167
168 func (s *Service) userAgent() string {
169 if s.UserAgent == "" {
170 return googleapi.UserAgent
171 }
172 return googleapi.UserAgent + " " + s.UserAgent
173 }
174
175 func NewProjectsService(s *Service) *ProjectsService {
176 rs := &ProjectsService{s: s}
177 rs.Locations = NewProjectsLocationsService(s)
178 return rs
179 }
180
181 type ProjectsService struct {
182 s *Service
183
184 Locations *ProjectsLocationsService
185 }
186
187 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
188 rs := &ProjectsLocationsService{s: s}
189 rs.Instances = NewProjectsLocationsInstancesService(s)
190 return rs
191 }
192
193 type ProjectsLocationsService struct {
194 s *Service
195
196 Instances *ProjectsLocationsInstancesService
197 }
198
199 func NewProjectsLocationsInstancesService(s *Service) *ProjectsLocationsInstancesService {
200 rs := &ProjectsLocationsInstancesService{s: s}
201 return rs
202 }
203
204 type ProjectsLocationsInstancesService struct {
205 s *Service
206 }
207
208
209
210
211 type DatabaseInstance struct {
212
213
214 DatabaseUrl string `json:"databaseUrl,omitempty"`
215
216
217
218 Name string `json:"name,omitempty"`
219
220
221 Project string `json:"project,omitempty"`
222
223
224
225
226
227
228
229
230
231 State string `json:"state,omitempty"`
232
233
234
235
236
237
238
239
240
241 Type string `json:"type,omitempty"`
242
243
244 googleapi.ServerResponse `json:"-"`
245
246
247
248
249
250 ForceSendFields []string `json:"-"`
251
252
253
254
255 NullFields []string `json:"-"`
256 }
257
258 func (s *DatabaseInstance) MarshalJSON() ([]byte, error) {
259 type NoMethod DatabaseInstance
260 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
261 }
262
263
264
265 type DisableDatabaseInstanceRequest struct {
266 }
267
268
269
270 type ListDatabaseInstancesResponse struct {
271
272
273 Instances []*DatabaseInstance `json:"instances,omitempty"`
274
275
276
277
278
279 NextPageToken string `json:"nextPageToken,omitempty"`
280
281
282 googleapi.ServerResponse `json:"-"`
283
284
285
286
287
288 ForceSendFields []string `json:"-"`
289
290
291
292
293 NullFields []string `json:"-"`
294 }
295
296 func (s *ListDatabaseInstancesResponse) MarshalJSON() ([]byte, error) {
297 type NoMethod ListDatabaseInstancesResponse
298 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
299 }
300
301
302
303 type ReenableDatabaseInstanceRequest struct {
304 }
305
306
307
308 type UndeleteDatabaseInstanceRequest struct {
309 }
310
311 type ProjectsLocationsInstancesCreateCall struct {
312 s *Service
313 parent string
314 databaseinstance *DatabaseInstance
315 urlParams_ gensupport.URLParams
316 ctx_ context.Context
317 header_ http.Header
318 }
319
320
321
322
323
324
325
326
327
328
329 func (r *ProjectsLocationsInstancesService) Create(parent string, databaseinstance *DatabaseInstance) *ProjectsLocationsInstancesCreateCall {
330 c := &ProjectsLocationsInstancesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
331 c.parent = parent
332 c.databaseinstance = databaseinstance
333 return c
334 }
335
336
337
338 func (c *ProjectsLocationsInstancesCreateCall) DatabaseId(databaseId string) *ProjectsLocationsInstancesCreateCall {
339 c.urlParams_.Set("databaseId", databaseId)
340 return c
341 }
342
343
344
345 func (c *ProjectsLocationsInstancesCreateCall) ValidateOnly(validateOnly bool) *ProjectsLocationsInstancesCreateCall {
346 c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly))
347 return c
348 }
349
350
351
352
353 func (c *ProjectsLocationsInstancesCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesCreateCall {
354 c.urlParams_.Set("fields", googleapi.CombineFields(s))
355 return c
356 }
357
358
359 func (c *ProjectsLocationsInstancesCreateCall) Context(ctx context.Context) *ProjectsLocationsInstancesCreateCall {
360 c.ctx_ = ctx
361 return c
362 }
363
364
365
366 func (c *ProjectsLocationsInstancesCreateCall) Header() http.Header {
367 if c.header_ == nil {
368 c.header_ = make(http.Header)
369 }
370 return c.header_
371 }
372
373 func (c *ProjectsLocationsInstancesCreateCall) doRequest(alt string) (*http.Response, error) {
374 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
375 var body io.Reader = nil
376 body, err := googleapi.WithoutDataWrapper.JSONReader(c.databaseinstance)
377 if err != nil {
378 return nil, err
379 }
380 c.urlParams_.Set("alt", alt)
381 c.urlParams_.Set("prettyPrint", "false")
382 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}/instances")
383 urls += "?" + c.urlParams_.Encode()
384 req, err := http.NewRequest("POST", urls, body)
385 if err != nil {
386 return nil, err
387 }
388 req.Header = reqHeaders
389 googleapi.Expand(req.URL, map[string]string{
390 "parent": c.parent,
391 })
392 return gensupport.SendRequest(c.ctx_, c.s.client, req)
393 }
394
395
396
397
398
399
400
401 func (c *ProjectsLocationsInstancesCreateCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
402 gensupport.SetOptions(c.urlParams_, opts...)
403 res, err := c.doRequest("json")
404 if res != nil && res.StatusCode == http.StatusNotModified {
405 if res.Body != nil {
406 res.Body.Close()
407 }
408 return nil, gensupport.WrapError(&googleapi.Error{
409 Code: res.StatusCode,
410 Header: res.Header,
411 })
412 }
413 if err != nil {
414 return nil, err
415 }
416 defer googleapi.CloseBody(res)
417 if err := googleapi.CheckResponse(res); err != nil {
418 return nil, gensupport.WrapError(err)
419 }
420 ret := &DatabaseInstance{
421 ServerResponse: googleapi.ServerResponse{
422 Header: res.Header,
423 HTTPStatusCode: res.StatusCode,
424 },
425 }
426 target := &ret
427 if err := gensupport.DecodeResponse(target, res); err != nil {
428 return nil, err
429 }
430 return ret, nil
431 }
432
433 type ProjectsLocationsInstancesDeleteCall struct {
434 s *Service
435 name string
436 urlParams_ gensupport.URLParams
437 ctx_ context.Context
438 header_ http.Header
439 }
440
441
442
443
444
445
446
447
448
449
450 func (r *ProjectsLocationsInstancesService) Delete(name string) *ProjectsLocationsInstancesDeleteCall {
451 c := &ProjectsLocationsInstancesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
452 c.name = name
453 return c
454 }
455
456
457
458
459 func (c *ProjectsLocationsInstancesDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesDeleteCall {
460 c.urlParams_.Set("fields", googleapi.CombineFields(s))
461 return c
462 }
463
464
465 func (c *ProjectsLocationsInstancesDeleteCall) Context(ctx context.Context) *ProjectsLocationsInstancesDeleteCall {
466 c.ctx_ = ctx
467 return c
468 }
469
470
471
472 func (c *ProjectsLocationsInstancesDeleteCall) Header() http.Header {
473 if c.header_ == nil {
474 c.header_ = make(http.Header)
475 }
476 return c.header_
477 }
478
479 func (c *ProjectsLocationsInstancesDeleteCall) doRequest(alt string) (*http.Response, error) {
480 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
481 var body io.Reader = nil
482 c.urlParams_.Set("alt", alt)
483 c.urlParams_.Set("prettyPrint", "false")
484 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
485 urls += "?" + c.urlParams_.Encode()
486 req, err := http.NewRequest("DELETE", urls, body)
487 if err != nil {
488 return nil, err
489 }
490 req.Header = reqHeaders
491 googleapi.Expand(req.URL, map[string]string{
492 "name": c.name,
493 })
494 return gensupport.SendRequest(c.ctx_, c.s.client, req)
495 }
496
497
498
499
500
501
502
503 func (c *ProjectsLocationsInstancesDeleteCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
504 gensupport.SetOptions(c.urlParams_, opts...)
505 res, err := c.doRequest("json")
506 if res != nil && res.StatusCode == http.StatusNotModified {
507 if res.Body != nil {
508 res.Body.Close()
509 }
510 return nil, gensupport.WrapError(&googleapi.Error{
511 Code: res.StatusCode,
512 Header: res.Header,
513 })
514 }
515 if err != nil {
516 return nil, err
517 }
518 defer googleapi.CloseBody(res)
519 if err := googleapi.CheckResponse(res); err != nil {
520 return nil, gensupport.WrapError(err)
521 }
522 ret := &DatabaseInstance{
523 ServerResponse: googleapi.ServerResponse{
524 Header: res.Header,
525 HTTPStatusCode: res.StatusCode,
526 },
527 }
528 target := &ret
529 if err := gensupport.DecodeResponse(target, res); err != nil {
530 return nil, err
531 }
532 return ret, nil
533 }
534
535 type ProjectsLocationsInstancesDisableCall struct {
536 s *Service
537 name string
538 disabledatabaseinstancerequest *DisableDatabaseInstanceRequest
539 urlParams_ gensupport.URLParams
540 ctx_ context.Context
541 header_ http.Header
542 }
543
544
545
546
547
548
549
550
551 func (r *ProjectsLocationsInstancesService) Disable(name string, disabledatabaseinstancerequest *DisableDatabaseInstanceRequest) *ProjectsLocationsInstancesDisableCall {
552 c := &ProjectsLocationsInstancesDisableCall{s: r.s, urlParams_: make(gensupport.URLParams)}
553 c.name = name
554 c.disabledatabaseinstancerequest = disabledatabaseinstancerequest
555 return c
556 }
557
558
559
560
561 func (c *ProjectsLocationsInstancesDisableCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesDisableCall {
562 c.urlParams_.Set("fields", googleapi.CombineFields(s))
563 return c
564 }
565
566
567 func (c *ProjectsLocationsInstancesDisableCall) Context(ctx context.Context) *ProjectsLocationsInstancesDisableCall {
568 c.ctx_ = ctx
569 return c
570 }
571
572
573
574 func (c *ProjectsLocationsInstancesDisableCall) Header() http.Header {
575 if c.header_ == nil {
576 c.header_ = make(http.Header)
577 }
578 return c.header_
579 }
580
581 func (c *ProjectsLocationsInstancesDisableCall) doRequest(alt string) (*http.Response, error) {
582 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
583 var body io.Reader = nil
584 body, err := googleapi.WithoutDataWrapper.JSONReader(c.disabledatabaseinstancerequest)
585 if err != nil {
586 return nil, err
587 }
588 c.urlParams_.Set("alt", alt)
589 c.urlParams_.Set("prettyPrint", "false")
590 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}:disable")
591 urls += "?" + c.urlParams_.Encode()
592 req, err := http.NewRequest("POST", urls, body)
593 if err != nil {
594 return nil, err
595 }
596 req.Header = reqHeaders
597 googleapi.Expand(req.URL, map[string]string{
598 "name": c.name,
599 })
600 return gensupport.SendRequest(c.ctx_, c.s.client, req)
601 }
602
603
604
605
606
607
608
609 func (c *ProjectsLocationsInstancesDisableCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
610 gensupport.SetOptions(c.urlParams_, opts...)
611 res, err := c.doRequest("json")
612 if res != nil && res.StatusCode == http.StatusNotModified {
613 if res.Body != nil {
614 res.Body.Close()
615 }
616 return nil, gensupport.WrapError(&googleapi.Error{
617 Code: res.StatusCode,
618 Header: res.Header,
619 })
620 }
621 if err != nil {
622 return nil, err
623 }
624 defer googleapi.CloseBody(res)
625 if err := googleapi.CheckResponse(res); err != nil {
626 return nil, gensupport.WrapError(err)
627 }
628 ret := &DatabaseInstance{
629 ServerResponse: googleapi.ServerResponse{
630 Header: res.Header,
631 HTTPStatusCode: res.StatusCode,
632 },
633 }
634 target := &ret
635 if err := gensupport.DecodeResponse(target, res); err != nil {
636 return nil, err
637 }
638 return ret, nil
639 }
640
641 type ProjectsLocationsInstancesGetCall struct {
642 s *Service
643 nameid string
644 urlParams_ gensupport.URLParams
645 ifNoneMatch_ string
646 ctx_ context.Context
647 header_ http.Header
648 }
649
650
651
652
653
654
655
656
657
658
659
660 func (r *ProjectsLocationsInstancesService) Get(nameid string) *ProjectsLocationsInstancesGetCall {
661 c := &ProjectsLocationsInstancesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
662 c.nameid = nameid
663 return c
664 }
665
666
667
668
669 func (c *ProjectsLocationsInstancesGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesGetCall {
670 c.urlParams_.Set("fields", googleapi.CombineFields(s))
671 return c
672 }
673
674
675
676
677 func (c *ProjectsLocationsInstancesGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsInstancesGetCall {
678 c.ifNoneMatch_ = entityTag
679 return c
680 }
681
682
683 func (c *ProjectsLocationsInstancesGetCall) Context(ctx context.Context) *ProjectsLocationsInstancesGetCall {
684 c.ctx_ = ctx
685 return c
686 }
687
688
689
690 func (c *ProjectsLocationsInstancesGetCall) Header() http.Header {
691 if c.header_ == nil {
692 c.header_ = make(http.Header)
693 }
694 return c.header_
695 }
696
697 func (c *ProjectsLocationsInstancesGetCall) doRequest(alt string) (*http.Response, error) {
698 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
699 if c.ifNoneMatch_ != "" {
700 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
701 }
702 var body io.Reader = nil
703 c.urlParams_.Set("alt", alt)
704 c.urlParams_.Set("prettyPrint", "false")
705 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
706 urls += "?" + c.urlParams_.Encode()
707 req, err := http.NewRequest("GET", urls, body)
708 if err != nil {
709 return nil, err
710 }
711 req.Header = reqHeaders
712 googleapi.Expand(req.URL, map[string]string{
713 "name": c.nameid,
714 })
715 return gensupport.SendRequest(c.ctx_, c.s.client, req)
716 }
717
718
719
720
721
722
723
724 func (c *ProjectsLocationsInstancesGetCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
725 gensupport.SetOptions(c.urlParams_, opts...)
726 res, err := c.doRequest("json")
727 if res != nil && res.StatusCode == http.StatusNotModified {
728 if res.Body != nil {
729 res.Body.Close()
730 }
731 return nil, gensupport.WrapError(&googleapi.Error{
732 Code: res.StatusCode,
733 Header: res.Header,
734 })
735 }
736 if err != nil {
737 return nil, err
738 }
739 defer googleapi.CloseBody(res)
740 if err := googleapi.CheckResponse(res); err != nil {
741 return nil, gensupport.WrapError(err)
742 }
743 ret := &DatabaseInstance{
744 ServerResponse: googleapi.ServerResponse{
745 Header: res.Header,
746 HTTPStatusCode: res.StatusCode,
747 },
748 }
749 target := &ret
750 if err := gensupport.DecodeResponse(target, res); err != nil {
751 return nil, err
752 }
753 return ret, nil
754 }
755
756 type ProjectsLocationsInstancesListCall struct {
757 s *Service
758 parent string
759 urlParams_ gensupport.URLParams
760 ifNoneMatch_ string
761 ctx_ context.Context
762 header_ http.Header
763 }
764
765
766
767
768
769
770
771
772
773
774
775
776 func (r *ProjectsLocationsInstancesService) List(parent string) *ProjectsLocationsInstancesListCall {
777 c := &ProjectsLocationsInstancesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
778 c.parent = parent
779 return c
780 }
781
782
783
784
785
786 func (c *ProjectsLocationsInstancesListCall) PageSize(pageSize int64) *ProjectsLocationsInstancesListCall {
787 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
788 return c
789 }
790
791
792
793
794 func (c *ProjectsLocationsInstancesListCall) PageToken(pageToken string) *ProjectsLocationsInstancesListCall {
795 c.urlParams_.Set("pageToken", pageToken)
796 return c
797 }
798
799
800
801 func (c *ProjectsLocationsInstancesListCall) ShowDeleted(showDeleted bool) *ProjectsLocationsInstancesListCall {
802 c.urlParams_.Set("showDeleted", fmt.Sprint(showDeleted))
803 return c
804 }
805
806
807
808
809 func (c *ProjectsLocationsInstancesListCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesListCall {
810 c.urlParams_.Set("fields", googleapi.CombineFields(s))
811 return c
812 }
813
814
815
816
817 func (c *ProjectsLocationsInstancesListCall) IfNoneMatch(entityTag string) *ProjectsLocationsInstancesListCall {
818 c.ifNoneMatch_ = entityTag
819 return c
820 }
821
822
823 func (c *ProjectsLocationsInstancesListCall) Context(ctx context.Context) *ProjectsLocationsInstancesListCall {
824 c.ctx_ = ctx
825 return c
826 }
827
828
829
830 func (c *ProjectsLocationsInstancesListCall) Header() http.Header {
831 if c.header_ == nil {
832 c.header_ = make(http.Header)
833 }
834 return c.header_
835 }
836
837 func (c *ProjectsLocationsInstancesListCall) doRequest(alt string) (*http.Response, error) {
838 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
839 if c.ifNoneMatch_ != "" {
840 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
841 }
842 var body io.Reader = nil
843 c.urlParams_.Set("alt", alt)
844 c.urlParams_.Set("prettyPrint", "false")
845 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}/instances")
846 urls += "?" + c.urlParams_.Encode()
847 req, err := http.NewRequest("GET", urls, body)
848 if err != nil {
849 return nil, err
850 }
851 req.Header = reqHeaders
852 googleapi.Expand(req.URL, map[string]string{
853 "parent": c.parent,
854 })
855 return gensupport.SendRequest(c.ctx_, c.s.client, req)
856 }
857
858
859
860
861
862
863
864 func (c *ProjectsLocationsInstancesListCall) Do(opts ...googleapi.CallOption) (*ListDatabaseInstancesResponse, error) {
865 gensupport.SetOptions(c.urlParams_, opts...)
866 res, err := c.doRequest("json")
867 if res != nil && res.StatusCode == http.StatusNotModified {
868 if res.Body != nil {
869 res.Body.Close()
870 }
871 return nil, gensupport.WrapError(&googleapi.Error{
872 Code: res.StatusCode,
873 Header: res.Header,
874 })
875 }
876 if err != nil {
877 return nil, err
878 }
879 defer googleapi.CloseBody(res)
880 if err := googleapi.CheckResponse(res); err != nil {
881 return nil, gensupport.WrapError(err)
882 }
883 ret := &ListDatabaseInstancesResponse{
884 ServerResponse: googleapi.ServerResponse{
885 Header: res.Header,
886 HTTPStatusCode: res.StatusCode,
887 },
888 }
889 target := &ret
890 if err := gensupport.DecodeResponse(target, res); err != nil {
891 return nil, err
892 }
893 return ret, nil
894 }
895
896
897
898
899 func (c *ProjectsLocationsInstancesListCall) Pages(ctx context.Context, f func(*ListDatabaseInstancesResponse) error) error {
900 c.ctx_ = ctx
901 defer c.PageToken(c.urlParams_.Get("pageToken"))
902 for {
903 x, err := c.Do()
904 if err != nil {
905 return err
906 }
907 if err := f(x); err != nil {
908 return err
909 }
910 if x.NextPageToken == "" {
911 return nil
912 }
913 c.PageToken(x.NextPageToken)
914 }
915 }
916
917 type ProjectsLocationsInstancesReenableCall struct {
918 s *Service
919 name string
920 reenabledatabaseinstancerequest *ReenableDatabaseInstanceRequest
921 urlParams_ gensupport.URLParams
922 ctx_ context.Context
923 header_ http.Header
924 }
925
926
927
928
929
930
931
932
933 func (r *ProjectsLocationsInstancesService) Reenable(name string, reenabledatabaseinstancerequest *ReenableDatabaseInstanceRequest) *ProjectsLocationsInstancesReenableCall {
934 c := &ProjectsLocationsInstancesReenableCall{s: r.s, urlParams_: make(gensupport.URLParams)}
935 c.name = name
936 c.reenabledatabaseinstancerequest = reenabledatabaseinstancerequest
937 return c
938 }
939
940
941
942
943 func (c *ProjectsLocationsInstancesReenableCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesReenableCall {
944 c.urlParams_.Set("fields", googleapi.CombineFields(s))
945 return c
946 }
947
948
949 func (c *ProjectsLocationsInstancesReenableCall) Context(ctx context.Context) *ProjectsLocationsInstancesReenableCall {
950 c.ctx_ = ctx
951 return c
952 }
953
954
955
956 func (c *ProjectsLocationsInstancesReenableCall) Header() http.Header {
957 if c.header_ == nil {
958 c.header_ = make(http.Header)
959 }
960 return c.header_
961 }
962
963 func (c *ProjectsLocationsInstancesReenableCall) doRequest(alt string) (*http.Response, error) {
964 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
965 var body io.Reader = nil
966 body, err := googleapi.WithoutDataWrapper.JSONReader(c.reenabledatabaseinstancerequest)
967 if err != nil {
968 return nil, err
969 }
970 c.urlParams_.Set("alt", alt)
971 c.urlParams_.Set("prettyPrint", "false")
972 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}:reenable")
973 urls += "?" + c.urlParams_.Encode()
974 req, err := http.NewRequest("POST", urls, body)
975 if err != nil {
976 return nil, err
977 }
978 req.Header = reqHeaders
979 googleapi.Expand(req.URL, map[string]string{
980 "name": c.name,
981 })
982 return gensupport.SendRequest(c.ctx_, c.s.client, req)
983 }
984
985
986
987
988
989
990
991 func (c *ProjectsLocationsInstancesReenableCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
992 gensupport.SetOptions(c.urlParams_, opts...)
993 res, err := c.doRequest("json")
994 if res != nil && res.StatusCode == http.StatusNotModified {
995 if res.Body != nil {
996 res.Body.Close()
997 }
998 return nil, gensupport.WrapError(&googleapi.Error{
999 Code: res.StatusCode,
1000 Header: res.Header,
1001 })
1002 }
1003 if err != nil {
1004 return nil, err
1005 }
1006 defer googleapi.CloseBody(res)
1007 if err := googleapi.CheckResponse(res); err != nil {
1008 return nil, gensupport.WrapError(err)
1009 }
1010 ret := &DatabaseInstance{
1011 ServerResponse: googleapi.ServerResponse{
1012 Header: res.Header,
1013 HTTPStatusCode: res.StatusCode,
1014 },
1015 }
1016 target := &ret
1017 if err := gensupport.DecodeResponse(target, res); err != nil {
1018 return nil, err
1019 }
1020 return ret, nil
1021 }
1022
1023 type ProjectsLocationsInstancesUndeleteCall struct {
1024 s *Service
1025 name string
1026 undeletedatabaseinstancerequest *UndeleteDatabaseInstanceRequest
1027 urlParams_ gensupport.URLParams
1028 ctx_ context.Context
1029 header_ http.Header
1030 }
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042 func (r *ProjectsLocationsInstancesService) Undelete(name string, undeletedatabaseinstancerequest *UndeleteDatabaseInstanceRequest) *ProjectsLocationsInstancesUndeleteCall {
1043 c := &ProjectsLocationsInstancesUndeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1044 c.name = name
1045 c.undeletedatabaseinstancerequest = undeletedatabaseinstancerequest
1046 return c
1047 }
1048
1049
1050
1051
1052 func (c *ProjectsLocationsInstancesUndeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsInstancesUndeleteCall {
1053 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1054 return c
1055 }
1056
1057
1058 func (c *ProjectsLocationsInstancesUndeleteCall) Context(ctx context.Context) *ProjectsLocationsInstancesUndeleteCall {
1059 c.ctx_ = ctx
1060 return c
1061 }
1062
1063
1064
1065 func (c *ProjectsLocationsInstancesUndeleteCall) Header() http.Header {
1066 if c.header_ == nil {
1067 c.header_ = make(http.Header)
1068 }
1069 return c.header_
1070 }
1071
1072 func (c *ProjectsLocationsInstancesUndeleteCall) doRequest(alt string) (*http.Response, error) {
1073 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1074 var body io.Reader = nil
1075 body, err := googleapi.WithoutDataWrapper.JSONReader(c.undeletedatabaseinstancerequest)
1076 if err != nil {
1077 return nil, err
1078 }
1079 c.urlParams_.Set("alt", alt)
1080 c.urlParams_.Set("prettyPrint", "false")
1081 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}:undelete")
1082 urls += "?" + c.urlParams_.Encode()
1083 req, err := http.NewRequest("POST", urls, body)
1084 if err != nil {
1085 return nil, err
1086 }
1087 req.Header = reqHeaders
1088 googleapi.Expand(req.URL, map[string]string{
1089 "name": c.name,
1090 })
1091 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1092 }
1093
1094
1095
1096
1097
1098
1099
1100 func (c *ProjectsLocationsInstancesUndeleteCall) Do(opts ...googleapi.CallOption) (*DatabaseInstance, error) {
1101 gensupport.SetOptions(c.urlParams_, opts...)
1102 res, err := c.doRequest("json")
1103 if res != nil && res.StatusCode == http.StatusNotModified {
1104 if res.Body != nil {
1105 res.Body.Close()
1106 }
1107 return nil, gensupport.WrapError(&googleapi.Error{
1108 Code: res.StatusCode,
1109 Header: res.Header,
1110 })
1111 }
1112 if err != nil {
1113 return nil, err
1114 }
1115 defer googleapi.CloseBody(res)
1116 if err := googleapi.CheckResponse(res); err != nil {
1117 return nil, gensupport.WrapError(err)
1118 }
1119 ret := &DatabaseInstance{
1120 ServerResponse: googleapi.ServerResponse{
1121 Header: res.Header,
1122 HTTPStatusCode: res.StatusCode,
1123 },
1124 }
1125 target := &ret
1126 if err := gensupport.DecodeResponse(target, res); err != nil {
1127 return nil, err
1128 }
1129 return ret, nil
1130 }
1131
View as plain text