Debian Codegraph @

alloydb/apiv1beta/alloydb_admin_client.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package alloydb
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 alloydbpb "cloud.google.com/go/alloydb/apiv1beta/alloydbpb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 locationpb "google.golang.org/genproto/googleapis/cloud/location"
40 "google.golang.org/grpc"
41 "google.golang.org/grpc/codes"
42 "google.golang.org/protobuf/encoding/protojson"
43 "google.golang.org/protobuf/proto"
44 )
45
46 var newAlloyDBAdminClientHook clientHook
47
48 // AlloyDBAdminCallOptions contains the retry settings for each method of AlloyDBAdminClient.
49 type AlloyDBAdminCallOptions struct {
50 ListClusters []gax.CallOption
51 GetCluster []gax.CallOption
52 CreateCluster []gax.CallOption
53 UpdateCluster []gax.CallOption
54 ExportCluster []gax.CallOption
55 ImportCluster []gax.CallOption
56 UpgradeCluster []gax.CallOption
57 DeleteCluster []gax.CallOption
58 PromoteCluster []gax.CallOption
59 SwitchoverCluster []gax.CallOption
60 RestoreCluster []gax.CallOption
61 CreateSecondaryCluster []gax.CallOption
62 ListInstances []gax.CallOption
63 GetInstance []gax.CallOption
64 CreateInstance []gax.CallOption
65 CreateSecondaryInstance []gax.CallOption
66 BatchCreateInstances []gax.CallOption
67 UpdateInstance []gax.CallOption
68 DeleteInstance []gax.CallOption
69 FailoverInstance []gax.CallOption
70 InjectFault []gax.CallOption
71 RestartInstance []gax.CallOption
72 ExecuteSql []gax.CallOption
73 ListBackups []gax.CallOption
74 GetBackup []gax.CallOption
75 CreateBackup []gax.CallOption
76 UpdateBackup []gax.CallOption
77 DeleteBackup []gax.CallOption
78 ListSupportedDatabaseFlags []gax.CallOption
79 GenerateClientCertificate []gax.CallOption
80 GetConnectionInfo []gax.CallOption
81 ListUsers []gax.CallOption
82 GetUser []gax.CallOption
83 CreateUser []gax.CallOption
84 UpdateUser []gax.CallOption
85 DeleteUser []gax.CallOption
86 ListDatabases []gax.CallOption
87 GetLocation []gax.CallOption
88 ListLocations []gax.CallOption
89 CancelOperation []gax.CallOption
90 DeleteOperation []gax.CallOption
91 GetOperation []gax.CallOption
92 ListOperations []gax.CallOption
93 }
94
95 func defaultAlloyDBAdminGRPCClientOptions() []option.ClientOption {
96 return []option.ClientOption{
97 internaloption.WithDefaultEndpoint("alloydb.googleapis.com:443"),
98 internaloption.WithDefaultEndpointTemplate("alloydb.UNIVERSE_DOMAIN:443"),
99 internaloption.WithDefaultMTLSEndpoint("alloydb.mtls.googleapis.com:443"),
100 internaloption.WithDefaultUniverseDomain("googleapis.com"),
101 internaloption.WithDefaultAudience("https://alloydb.googleapis.com/"),
102 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
103 internaloption.EnableJwtWithScope(),
104 internaloption.EnableNewAuthLibrary(),
105 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
106 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
107 }
108 }
109
110 func defaultAlloyDBAdminCallOptions() *AlloyDBAdminCallOptions {
111 return &AlloyDBAdminCallOptions{
112 ListClusters: []gax.CallOption{
113 gax.WithTimeout(60000 * time.Millisecond),
114 gax.WithRetry(func() gax.Retryer {
115 return gax.OnCodes([]codes.Code{
116 codes.Unavailable,
117 }, gax.Backoff{
118 Initial: 1000 * time.Millisecond,
119 Max: 60000 * time.Millisecond,
120 Multiplier: 1.30,
121 })
122 }),
123 },
124 GetCluster: []gax.CallOption{
125 gax.WithTimeout(60000 * time.Millisecond),
126 gax.WithRetry(func() gax.Retryer {
127 return gax.OnCodes([]codes.Code{
128 codes.Unavailable,
129 }, gax.Backoff{
130 Initial: 1000 * time.Millisecond,
131 Max: 60000 * time.Millisecond,
132 Multiplier: 1.30,
133 })
134 }),
135 },
136 CreateCluster: []gax.CallOption{
137 gax.WithTimeout(60000 * time.Millisecond),
138 },
139 UpdateCluster: []gax.CallOption{
140 gax.WithTimeout(60000 * time.Millisecond),
141 },
142 ExportCluster: []gax.CallOption{
143 gax.WithTimeout(60000 * time.Millisecond),
144 },
145 ImportCluster: []gax.CallOption{
146 gax.WithTimeout(60000 * time.Millisecond),
147 },
148 UpgradeCluster: []gax.CallOption{
149 gax.WithTimeout(60000 * time.Millisecond),
150 },
151 DeleteCluster: []gax.CallOption{
152 gax.WithTimeout(60000 * time.Millisecond),
153 },
154 PromoteCluster: []gax.CallOption{
155 gax.WithTimeout(60000 * time.Millisecond),
156 },
157 SwitchoverCluster: []gax.CallOption{
158 gax.WithTimeout(60000 * time.Millisecond),
159 },
160 RestoreCluster: []gax.CallOption{
161 gax.WithTimeout(60000 * time.Millisecond),
162 },
163 CreateSecondaryCluster: []gax.CallOption{
164 gax.WithTimeout(60000 * time.Millisecond),
165 },
166 ListInstances: []gax.CallOption{
167 gax.WithTimeout(60000 * time.Millisecond),
168 gax.WithRetry(func() gax.Retryer {
169 return gax.OnCodes([]codes.Code{
170 codes.Unavailable,
171 }, gax.Backoff{
172 Initial: 1000 * time.Millisecond,
173 Max: 60000 * time.Millisecond,
174 Multiplier: 1.30,
175 })
176 }),
177 },
178 GetInstance: []gax.CallOption{
179 gax.WithTimeout(60000 * time.Millisecond),
180 gax.WithRetry(func() gax.Retryer {
181 return gax.OnCodes([]codes.Code{
182 codes.Unavailable,
183 }, gax.Backoff{
184 Initial: 1000 * time.Millisecond,
185 Max: 60000 * time.Millisecond,
186 Multiplier: 1.30,
187 })
188 }),
189 },
190 CreateInstance: []gax.CallOption{
191 gax.WithTimeout(60000 * time.Millisecond),
192 },
193 CreateSecondaryInstance: []gax.CallOption{
194 gax.WithTimeout(60000 * time.Millisecond),
195 },
196 BatchCreateInstances: []gax.CallOption{
197 gax.WithTimeout(60000 * time.Millisecond),
198 },
199 UpdateInstance: []gax.CallOption{
200 gax.WithTimeout(60000 * time.Millisecond),
201 },
202 DeleteInstance: []gax.CallOption{
203 gax.WithTimeout(60000 * time.Millisecond),
204 },
205 FailoverInstance: []gax.CallOption{
206 gax.WithTimeout(60000 * time.Millisecond),
207 },
208 InjectFault: []gax.CallOption{
209 gax.WithTimeout(60000 * time.Millisecond),
210 },
211 RestartInstance: []gax.CallOption{
212 gax.WithTimeout(60000 * time.Millisecond),
213 },
214 ExecuteSql: []gax.CallOption{
215 gax.WithTimeout(60000 * time.Millisecond),
216 },
217 ListBackups: []gax.CallOption{
218 gax.WithTimeout(60000 * time.Millisecond),
219 gax.WithRetry(func() gax.Retryer {
220 return gax.OnCodes([]codes.Code{
221 codes.Unavailable,
222 }, gax.Backoff{
223 Initial: 1000 * time.Millisecond,
224 Max: 60000 * time.Millisecond,
225 Multiplier: 1.30,
226 })
227 }),
228 },
229 GetBackup: []gax.CallOption{
230 gax.WithTimeout(60000 * time.Millisecond),
231 gax.WithRetry(func() gax.Retryer {
232 return gax.OnCodes([]codes.Code{
233 codes.Unavailable,
234 }, gax.Backoff{
235 Initial: 1000 * time.Millisecond,
236 Max: 60000 * time.Millisecond,
237 Multiplier: 1.30,
238 })
239 }),
240 },
241 CreateBackup: []gax.CallOption{
242 gax.WithTimeout(60000 * time.Millisecond),
243 },
244 UpdateBackup: []gax.CallOption{
245 gax.WithTimeout(60000 * time.Millisecond),
246 },
247 DeleteBackup: []gax.CallOption{
248 gax.WithTimeout(60000 * time.Millisecond),
249 },
250 ListSupportedDatabaseFlags: []gax.CallOption{
251 gax.WithTimeout(60000 * time.Millisecond),
252 gax.WithRetry(func() gax.Retryer {
253 return gax.OnCodes([]codes.Code{
254 codes.Unavailable,
255 }, gax.Backoff{
256 Initial: 1000 * time.Millisecond,
257 Max: 60000 * time.Millisecond,
258 Multiplier: 1.30,
259 })
260 }),
261 },
262 GenerateClientCertificate: []gax.CallOption{
263 gax.WithTimeout(60000 * time.Millisecond),
264 gax.WithRetry(func() gax.Retryer {
265 return gax.OnCodes([]codes.Code{
266 codes.Unavailable,
267 }, gax.Backoff{
268 Initial: 1000 * time.Millisecond,
269 Max: 60000 * time.Millisecond,
270 Multiplier: 1.30,
271 })
272 }),
273 },
274 GetConnectionInfo: []gax.CallOption{
275 gax.WithTimeout(60000 * time.Millisecond),
276 gax.WithRetry(func() gax.Retryer {
277 return gax.OnCodes([]codes.Code{
278 codes.Unavailable,
279 }, gax.Backoff{
280 Initial: 1000 * time.Millisecond,
281 Max: 60000 * time.Millisecond,
282 Multiplier: 1.30,
283 })
284 }),
285 },
286 ListUsers: []gax.CallOption{
287 gax.WithTimeout(60000 * time.Millisecond),
288 gax.WithRetry(func() gax.Retryer {
289 return gax.OnCodes([]codes.Code{
290 codes.Unavailable,
291 }, gax.Backoff{
292 Initial: 1000 * time.Millisecond,
293 Max: 60000 * time.Millisecond,
294 Multiplier: 1.30,
295 })
296 }),
297 },
298 GetUser: []gax.CallOption{
299 gax.WithTimeout(60000 * time.Millisecond),
300 gax.WithRetry(func() gax.Retryer {
301 return gax.OnCodes([]codes.Code{
302 codes.Unavailable,
303 }, gax.Backoff{
304 Initial: 1000 * time.Millisecond,
305 Max: 60000 * time.Millisecond,
306 Multiplier: 1.30,
307 })
308 }),
309 },
310 CreateUser: []gax.CallOption{
311 gax.WithTimeout(60000 * time.Millisecond),
312 },
313 UpdateUser: []gax.CallOption{
314 gax.WithTimeout(60000 * time.Millisecond),
315 },
316 DeleteUser: []gax.CallOption{
317 gax.WithTimeout(60000 * time.Millisecond),
318 },
319 ListDatabases: []gax.CallOption{
320 gax.WithTimeout(60000 * time.Millisecond),
321 gax.WithRetry(func() gax.Retryer {
322 return gax.OnCodes([]codes.Code{
323 codes.Unavailable,
324 }, gax.Backoff{
325 Initial: 1000 * time.Millisecond,
326 Max: 60000 * time.Millisecond,
327 Multiplier: 1.30,
328 })
329 }),
330 },
331 GetLocation: []gax.CallOption{},
332 ListLocations: []gax.CallOption{},
333 CancelOperation: []gax.CallOption{},
334 DeleteOperation: []gax.CallOption{},
335 GetOperation: []gax.CallOption{},
336 ListOperations: []gax.CallOption{},
337 }
338 }
339
340 func defaultAlloyDBAdminRESTCallOptions() *AlloyDBAdminCallOptions {
341 return &AlloyDBAdminCallOptions{
342 ListClusters: []gax.CallOption{
343 gax.WithTimeout(60000 * time.Millisecond),
344 gax.WithRetry(func() gax.Retryer {
345 return gax.OnHTTPCodes(gax.Backoff{
346 Initial: 1000 * time.Millisecond,
347 Max: 60000 * time.Millisecond,
348 Multiplier: 1.30,
349 },
350 http.StatusServiceUnavailable)
351 }),
352 },
353 GetCluster: []gax.CallOption{
354 gax.WithTimeout(60000 * time.Millisecond),
355 gax.WithRetry(func() gax.Retryer {
356 return gax.OnHTTPCodes(gax.Backoff{
357 Initial: 1000 * time.Millisecond,
358 Max: 60000 * time.Millisecond,
359 Multiplier: 1.30,
360 },
361 http.StatusServiceUnavailable)
362 }),
363 },
364 CreateCluster: []gax.CallOption{
365 gax.WithTimeout(60000 * time.Millisecond),
366 },
367 UpdateCluster: []gax.CallOption{
368 gax.WithTimeout(60000 * time.Millisecond),
369 },
370 ExportCluster: []gax.CallOption{
371 gax.WithTimeout(60000 * time.Millisecond),
372 },
373 ImportCluster: []gax.CallOption{
374 gax.WithTimeout(60000 * time.Millisecond),
375 },
376 UpgradeCluster: []gax.CallOption{
377 gax.WithTimeout(60000 * time.Millisecond),
378 },
379 DeleteCluster: []gax.CallOption{
380 gax.WithTimeout(60000 * time.Millisecond),
381 },
382 PromoteCluster: []gax.CallOption{
383 gax.WithTimeout(60000 * time.Millisecond),
384 },
385 SwitchoverCluster: []gax.CallOption{
386 gax.WithTimeout(60000 * time.Millisecond),
387 },
388 RestoreCluster: []gax.CallOption{
389 gax.WithTimeout(60000 * time.Millisecond),
390 },
391 CreateSecondaryCluster: []gax.CallOption{
392 gax.WithTimeout(60000 * time.Millisecond),
393 },
394 ListInstances: []gax.CallOption{
395 gax.WithTimeout(60000 * time.Millisecond),
396 gax.WithRetry(func() gax.Retryer {
397 return gax.OnHTTPCodes(gax.Backoff{
398 Initial: 1000 * time.Millisecond,
399 Max: 60000 * time.Millisecond,
400 Multiplier: 1.30,
401 },
402 http.StatusServiceUnavailable)
403 }),
404 },
405 GetInstance: []gax.CallOption{
406 gax.WithTimeout(60000 * time.Millisecond),
407 gax.WithRetry(func() gax.Retryer {
408 return gax.OnHTTPCodes(gax.Backoff{
409 Initial: 1000 * time.Millisecond,
410 Max: 60000 * time.Millisecond,
411 Multiplier: 1.30,
412 },
413 http.StatusServiceUnavailable)
414 }),
415 },
416 CreateInstance: []gax.CallOption{
417 gax.WithTimeout(60000 * time.Millisecond),
418 },
419 CreateSecondaryInstance: []gax.CallOption{
420 gax.WithTimeout(60000 * time.Millisecond),
421 },
422 BatchCreateInstances: []gax.CallOption{
423 gax.WithTimeout(60000 * time.Millisecond),
424 },
425 UpdateInstance: []gax.CallOption{
426 gax.WithTimeout(60000 * time.Millisecond),
427 },
428 DeleteInstance: []gax.CallOption{
429 gax.WithTimeout(60000 * time.Millisecond),
430 },
431 FailoverInstance: []gax.CallOption{
432 gax.WithTimeout(60000 * time.Millisecond),
433 },
434 InjectFault: []gax.CallOption{
435 gax.WithTimeout(60000 * time.Millisecond),
436 },
437 RestartInstance: []gax.CallOption{
438 gax.WithTimeout(60000 * time.Millisecond),
439 },
440 ExecuteSql: []gax.CallOption{
441 gax.WithTimeout(60000 * time.Millisecond),
442 },
443 ListBackups: []gax.CallOption{
444 gax.WithTimeout(60000 * time.Millisecond),
445 gax.WithRetry(func() gax.Retryer {
446 return gax.OnHTTPCodes(gax.Backoff{
447 Initial: 1000 * time.Millisecond,
448 Max: 60000 * time.Millisecond,
449 Multiplier: 1.30,
450 },
451 http.StatusServiceUnavailable)
452 }),
453 },
454 GetBackup: []gax.CallOption{
455 gax.WithTimeout(60000 * time.Millisecond),
456 gax.WithRetry(func() gax.Retryer {
457 return gax.OnHTTPCodes(gax.Backoff{
458 Initial: 1000 * time.Millisecond,
459 Max: 60000 * time.Millisecond,
460 Multiplier: 1.30,
461 },
462 http.StatusServiceUnavailable)
463 }),
464 },
465 CreateBackup: []gax.CallOption{
466 gax.WithTimeout(60000 * time.Millisecond),
467 },
468 UpdateBackup: []gax.CallOption{
469 gax.WithTimeout(60000 * time.Millisecond),
470 },
471 DeleteBackup: []gax.CallOption{
472 gax.WithTimeout(60000 * time.Millisecond),
473 },
474 ListSupportedDatabaseFlags: []gax.CallOption{
475 gax.WithTimeout(60000 * time.Millisecond),
476 gax.WithRetry(func() gax.Retryer {
477 return gax.OnHTTPCodes(gax.Backoff{
478 Initial: 1000 * time.Millisecond,
479 Max: 60000 * time.Millisecond,
480 Multiplier: 1.30,
481 },
482 http.StatusServiceUnavailable)
483 }),
484 },
485 GenerateClientCertificate: []gax.CallOption{
486 gax.WithTimeout(60000 * time.Millisecond),
487 gax.WithRetry(func() gax.Retryer {
488 return gax.OnHTTPCodes(gax.Backoff{
489 Initial: 1000 * time.Millisecond,
490 Max: 60000 * time.Millisecond,
491 Multiplier: 1.30,
492 },
493 http.StatusServiceUnavailable)
494 }),
495 },
496 GetConnectionInfo: []gax.CallOption{
497 gax.WithTimeout(60000 * time.Millisecond),
498 gax.WithRetry(func() gax.Retryer {
499 return gax.OnHTTPCodes(gax.Backoff{
500 Initial: 1000 * time.Millisecond,
501 Max: 60000 * time.Millisecond,
502 Multiplier: 1.30,
503 },
504 http.StatusServiceUnavailable)
505 }),
506 },
507 ListUsers: []gax.CallOption{
508 gax.WithTimeout(60000 * time.Millisecond),
509 gax.WithRetry(func() gax.Retryer {
510 return gax.OnHTTPCodes(gax.Backoff{
511 Initial: 1000 * time.Millisecond,
512 Max: 60000 * time.Millisecond,
513 Multiplier: 1.30,
514 },
515 http.StatusServiceUnavailable)
516 }),
517 },
518 GetUser: []gax.CallOption{
519 gax.WithTimeout(60000 * time.Millisecond),
520 gax.WithRetry(func() gax.Retryer {
521 return gax.OnHTTPCodes(gax.Backoff{
522 Initial: 1000 * time.Millisecond,
523 Max: 60000 * time.Millisecond,
524 Multiplier: 1.30,
525 },
526 http.StatusServiceUnavailable)
527 }),
528 },
529 CreateUser: []gax.CallOption{
530 gax.WithTimeout(60000 * time.Millisecond),
531 },
532 UpdateUser: []gax.CallOption{
533 gax.WithTimeout(60000 * time.Millisecond),
534 },
535 DeleteUser: []gax.CallOption{
536 gax.WithTimeout(60000 * time.Millisecond),
537 },
538 ListDatabases: []gax.CallOption{
539 gax.WithTimeout(60000 * time.Millisecond),
540 gax.WithRetry(func() gax.Retryer {
541 return gax.OnHTTPCodes(gax.Backoff{
542 Initial: 1000 * time.Millisecond,
543 Max: 60000 * time.Millisecond,
544 Multiplier: 1.30,
545 },
546 http.StatusServiceUnavailable)
547 }),
548 },
549 GetLocation: []gax.CallOption{},
550 ListLocations: []gax.CallOption{},
551 CancelOperation: []gax.CallOption{},
552 DeleteOperation: []gax.CallOption{},
553 GetOperation: []gax.CallOption{},
554 ListOperations: []gax.CallOption{},
555 }
556 }
557
558 // internalAlloyDBAdminClient is an interface that defines the methods available from AlloyDB API.
559 type internalAlloyDBAdminClient interface {
560 Close() error
561 setGoogleClientInfo(...string)
562 Connection() *grpc.ClientConn
563 ListClusters(context.Context, *alloydbpb.ListClustersRequest, ...gax.CallOption) *ClusterIterator
564 GetCluster(context.Context, *alloydbpb.GetClusterRequest, ...gax.CallOption) (*alloydbpb.Cluster, error)
565 CreateCluster(context.Context, *alloydbpb.CreateClusterRequest, ...gax.CallOption) (*CreateClusterOperation, error)
566 CreateClusterOperation(name string) *CreateClusterOperation
567 UpdateCluster(context.Context, *alloydbpb.UpdateClusterRequest, ...gax.CallOption) (*UpdateClusterOperation, error)
568 UpdateClusterOperation(name string) *UpdateClusterOperation
569 ExportCluster(context.Context, *alloydbpb.ExportClusterRequest, ...gax.CallOption) (*ExportClusterOperation, error)
570 ExportClusterOperation(name string) *ExportClusterOperation
571 ImportCluster(context.Context, *alloydbpb.ImportClusterRequest, ...gax.CallOption) (*ImportClusterOperation, error)
572 ImportClusterOperation(name string) *ImportClusterOperation
573 UpgradeCluster(context.Context, *alloydbpb.UpgradeClusterRequest, ...gax.CallOption) (*UpgradeClusterOperation, error)
574 UpgradeClusterOperation(name string) *UpgradeClusterOperation
575 DeleteCluster(context.Context, *alloydbpb.DeleteClusterRequest, ...gax.CallOption) (*DeleteClusterOperation, error)
576 DeleteClusterOperation(name string) *DeleteClusterOperation
577 PromoteCluster(context.Context, *alloydbpb.PromoteClusterRequest, ...gax.CallOption) (*PromoteClusterOperation, error)
578 PromoteClusterOperation(name string) *PromoteClusterOperation
579 SwitchoverCluster(context.Context, *alloydbpb.SwitchoverClusterRequest, ...gax.CallOption) (*SwitchoverClusterOperation, error)
580 SwitchoverClusterOperation(name string) *SwitchoverClusterOperation
581 RestoreCluster(context.Context, *alloydbpb.RestoreClusterRequest, ...gax.CallOption) (*RestoreClusterOperation, error)
582 RestoreClusterOperation(name string) *RestoreClusterOperation
583 CreateSecondaryCluster(context.Context, *alloydbpb.CreateSecondaryClusterRequest, ...gax.CallOption) (*CreateSecondaryClusterOperation, error)
584 CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation
585 ListInstances(context.Context, *alloydbpb.ListInstancesRequest, ...gax.CallOption) *InstanceIterator
586 GetInstance(context.Context, *alloydbpb.GetInstanceRequest, ...gax.CallOption) (*alloydbpb.Instance, error)
587 CreateInstance(context.Context, *alloydbpb.CreateInstanceRequest, ...gax.CallOption) (*CreateInstanceOperation, error)
588 CreateInstanceOperation(name string) *CreateInstanceOperation
589 CreateSecondaryInstance(context.Context, *alloydbpb.CreateSecondaryInstanceRequest, ...gax.CallOption) (*CreateSecondaryInstanceOperation, error)
590 CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation
591 BatchCreateInstances(context.Context, *alloydbpb.BatchCreateInstancesRequest, ...gax.CallOption) (*BatchCreateInstancesOperation, error)
592 BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation
593 UpdateInstance(context.Context, *alloydbpb.UpdateInstanceRequest, ...gax.CallOption) (*UpdateInstanceOperation, error)
594 UpdateInstanceOperation(name string) *UpdateInstanceOperation
595 DeleteInstance(context.Context, *alloydbpb.DeleteInstanceRequest, ...gax.CallOption) (*DeleteInstanceOperation, error)
596 DeleteInstanceOperation(name string) *DeleteInstanceOperation
597 FailoverInstance(context.Context, *alloydbpb.FailoverInstanceRequest, ...gax.CallOption) (*FailoverInstanceOperation, error)
598 FailoverInstanceOperation(name string) *FailoverInstanceOperation
599 InjectFault(context.Context, *alloydbpb.InjectFaultRequest, ...gax.CallOption) (*InjectFaultOperation, error)
600 InjectFaultOperation(name string) *InjectFaultOperation
601 RestartInstance(context.Context, *alloydbpb.RestartInstanceRequest, ...gax.CallOption) (*RestartInstanceOperation, error)
602 RestartInstanceOperation(name string) *RestartInstanceOperation
603 ExecuteSql(context.Context, *alloydbpb.ExecuteSqlRequest, ...gax.CallOption) (*alloydbpb.ExecuteSqlResponse, error)
604 ListBackups(context.Context, *alloydbpb.ListBackupsRequest, ...gax.CallOption) *BackupIterator
605 GetBackup(context.Context, *alloydbpb.GetBackupRequest, ...gax.CallOption) (*alloydbpb.Backup, error)
606 CreateBackup(context.Context, *alloydbpb.CreateBackupRequest, ...gax.CallOption) (*CreateBackupOperation, error)
607 CreateBackupOperation(name string) *CreateBackupOperation
608 UpdateBackup(context.Context, *alloydbpb.UpdateBackupRequest, ...gax.CallOption) (*UpdateBackupOperation, error)
609 UpdateBackupOperation(name string) *UpdateBackupOperation
610 DeleteBackup(context.Context, *alloydbpb.DeleteBackupRequest, ...gax.CallOption) (*DeleteBackupOperation, error)
611 DeleteBackupOperation(name string) *DeleteBackupOperation
612 ListSupportedDatabaseFlags(context.Context, *alloydbpb.ListSupportedDatabaseFlagsRequest, ...gax.CallOption) *SupportedDatabaseFlagIterator
613 GenerateClientCertificate(context.Context, *alloydbpb.GenerateClientCertificateRequest, ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error)
614 GetConnectionInfo(context.Context, *alloydbpb.GetConnectionInfoRequest, ...gax.CallOption) (*alloydbpb.ConnectionInfo, error)
615 ListUsers(context.Context, *alloydbpb.ListUsersRequest, ...gax.CallOption) *UserIterator
616 GetUser(context.Context, *alloydbpb.GetUserRequest, ...gax.CallOption) (*alloydbpb.User, error)
617 CreateUser(context.Context, *alloydbpb.CreateUserRequest, ...gax.CallOption) (*alloydbpb.User, error)
618 UpdateUser(context.Context, *alloydbpb.UpdateUserRequest, ...gax.CallOption) (*alloydbpb.User, error)
619 DeleteUser(context.Context, *alloydbpb.DeleteUserRequest, ...gax.CallOption) error
620 ListDatabases(context.Context, *alloydbpb.ListDatabasesRequest, ...gax.CallOption) *DatabaseIterator
621 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
622 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
623 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
624 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
625 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
626 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
627 }
628
629 // AlloyDBAdminClient is a client for interacting with AlloyDB API.
630 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
631 //
632 // Service describing handlers for resources
633 type AlloyDBAdminClient struct {
634 // The internal transport-dependent client.
635 internalClient internalAlloyDBAdminClient
636
637 // The call options for this service.
638 CallOptions *AlloyDBAdminCallOptions
639
640 // LROClient is used internally to handle long-running operations.
641 // It is exposed so that its CallOptions can be modified if required.
642 // Users should not Close this client.
643 LROClient *lroauto.OperationsClient
644 }
645
646 // Wrapper methods routed to the internal client.
647
648 // Close closes the connection to the API service. The user should invoke this when
649 // the client is no longer required.
650 func (c *AlloyDBAdminClient) Close() error {
651 return c.internalClient.Close()
652 }
653
654 // setGoogleClientInfo sets the name and version of the application in
655 // the `x-goog-api-client` header passed on each request. Intended for
656 // use by Google-written clients.
657 func (c *AlloyDBAdminClient) setGoogleClientInfo(keyval ...string) {
658 c.internalClient.setGoogleClientInfo(keyval...)
659 }
660
661 // Connection returns a connection to the API service.
662 //
663 // Deprecated: Connections are now pooled so this method does not always
664 // return the same resource.
665 func (c *AlloyDBAdminClient) Connection() *grpc.ClientConn {
666 return c.internalClient.Connection()
667 }
668
669 // ListClusters lists Clusters in a given project and location.
670 func (c *AlloyDBAdminClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
671 return c.internalClient.ListClusters(ctx, req, opts...)
672 }
673
674 // GetCluster gets details of a single Cluster.
675 func (c *AlloyDBAdminClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
676 return c.internalClient.GetCluster(ctx, req, opts...)
677 }
678
679 // CreateCluster creates a new Cluster in a given project and location.
680 func (c *AlloyDBAdminClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
681 return c.internalClient.CreateCluster(ctx, req, opts...)
682 }
683
684 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
685 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
686 func (c *AlloyDBAdminClient) CreateClusterOperation(name string) *CreateClusterOperation {
687 return c.internalClient.CreateClusterOperation(name)
688 }
689
690 // UpdateCluster updates the parameters of a single Cluster.
691 func (c *AlloyDBAdminClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
692 return c.internalClient.UpdateCluster(ctx, req, opts...)
693 }
694
695 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
696 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
697 func (c *AlloyDBAdminClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
698 return c.internalClient.UpdateClusterOperation(name)
699 }
700
701 // ExportCluster exports data from the cluster.
702 // Imperative only.
703 func (c *AlloyDBAdminClient) ExportCluster(ctx context.Context, req *alloydbpb.ExportClusterRequest, opts ...gax.CallOption) (*ExportClusterOperation, error) {
704 return c.internalClient.ExportCluster(ctx, req, opts...)
705 }
706
707 // ExportClusterOperation returns a new ExportClusterOperation from a given name.
708 // The name must be that of a previously created ExportClusterOperation, possibly from a different process.
709 func (c *AlloyDBAdminClient) ExportClusterOperation(name string) *ExportClusterOperation {
710 return c.internalClient.ExportClusterOperation(name)
711 }
712
713 // ImportCluster imports data to the cluster.
714 // Imperative only.
715 func (c *AlloyDBAdminClient) ImportCluster(ctx context.Context, req *alloydbpb.ImportClusterRequest, opts ...gax.CallOption) (*ImportClusterOperation, error) {
716 return c.internalClient.ImportCluster(ctx, req, opts...)
717 }
718
719 // ImportClusterOperation returns a new ImportClusterOperation from a given name.
720 // The name must be that of a previously created ImportClusterOperation, possibly from a different process.
721 func (c *AlloyDBAdminClient) ImportClusterOperation(name string) *ImportClusterOperation {
722 return c.internalClient.ImportClusterOperation(name)
723 }
724
725 // UpgradeCluster upgrades a single Cluster.
726 // Imperative only.
727 func (c *AlloyDBAdminClient) UpgradeCluster(ctx context.Context, req *alloydbpb.UpgradeClusterRequest, opts ...gax.CallOption) (*UpgradeClusterOperation, error) {
728 return c.internalClient.UpgradeCluster(ctx, req, opts...)
729 }
730
731 // UpgradeClusterOperation returns a new UpgradeClusterOperation from a given name.
732 // The name must be that of a previously created UpgradeClusterOperation, possibly from a different process.
733 func (c *AlloyDBAdminClient) UpgradeClusterOperation(name string) *UpgradeClusterOperation {
734 return c.internalClient.UpgradeClusterOperation(name)
735 }
736
737 // DeleteCluster deletes a single Cluster.
738 func (c *AlloyDBAdminClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
739 return c.internalClient.DeleteCluster(ctx, req, opts...)
740 }
741
742 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
743 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
744 func (c *AlloyDBAdminClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
745 return c.internalClient.DeleteClusterOperation(name)
746 }
747
748 // PromoteCluster promotes a SECONDARY cluster. This turns down replication
749 // from the PRIMARY cluster and promotes a secondary cluster
750 // into its own standalone cluster.
751 // Imperative only.
752 func (c *AlloyDBAdminClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
753 return c.internalClient.PromoteCluster(ctx, req, opts...)
754 }
755
756 // PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
757 // The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
758 func (c *AlloyDBAdminClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
759 return c.internalClient.PromoteClusterOperation(name)
760 }
761
762 // SwitchoverCluster switches the roles of PRIMARY and SECONDARY clusters without any data loss.
763 // This promotes the SECONDARY cluster to PRIMARY and sets up the original
764 // PRIMARY cluster to replicate from this newly promoted cluster.
765 func (c *AlloyDBAdminClient) SwitchoverCluster(ctx context.Context, req *alloydbpb.SwitchoverClusterRequest, opts ...gax.CallOption) (*SwitchoverClusterOperation, error) {
766 return c.internalClient.SwitchoverCluster(ctx, req, opts...)
767 }
768
769 // SwitchoverClusterOperation returns a new SwitchoverClusterOperation from a given name.
770 // The name must be that of a previously created SwitchoverClusterOperation, possibly from a different process.
771 func (c *AlloyDBAdminClient) SwitchoverClusterOperation(name string) *SwitchoverClusterOperation {
772 return c.internalClient.SwitchoverClusterOperation(name)
773 }
774
775 // RestoreCluster creates a new Cluster in a given project and location, with a volume
776 // restored from the provided source, either a backup ID or a point-in-time
777 // and a source cluster.
778 func (c *AlloyDBAdminClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
779 return c.internalClient.RestoreCluster(ctx, req, opts...)
780 }
781
782 // RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
783 // The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
784 func (c *AlloyDBAdminClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
785 return c.internalClient.RestoreClusterOperation(name)
786 }
787
788 // CreateSecondaryCluster creates a cluster of type SECONDARY in the given location using
789 // the primary cluster as the source.
790 func (c *AlloyDBAdminClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
791 return c.internalClient.CreateSecondaryCluster(ctx, req, opts...)
792 }
793
794 // CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
795 // The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
796 func (c *AlloyDBAdminClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
797 return c.internalClient.CreateSecondaryClusterOperation(name)
798 }
799
800 // ListInstances lists Instances in a given project and location.
801 func (c *AlloyDBAdminClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
802 return c.internalClient.ListInstances(ctx, req, opts...)
803 }
804
805 // GetInstance gets details of a single Instance.
806 func (c *AlloyDBAdminClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
807 return c.internalClient.GetInstance(ctx, req, opts...)
808 }
809
810 // CreateInstance creates a new Instance in a given project and location.
811 func (c *AlloyDBAdminClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
812 return c.internalClient.CreateInstance(ctx, req, opts...)
813 }
814
815 // CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
816 // The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
817 func (c *AlloyDBAdminClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
818 return c.internalClient.CreateInstanceOperation(name)
819 }
820
821 // CreateSecondaryInstance creates a new SECONDARY Instance in a given project and location.
822 func (c *AlloyDBAdminClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
823 return c.internalClient.CreateSecondaryInstance(ctx, req, opts...)
824 }
825
826 // CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
827 // The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
828 func (c *AlloyDBAdminClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
829 return c.internalClient.CreateSecondaryInstanceOperation(name)
830 }
831
832 // BatchCreateInstances creates new instances under the given project, location and cluster.
833 // There can be only one primary instance in a cluster. If the primary
834 // instance exists in the cluster as well as this request, then API will
835 // throw an error.
836 // The primary instance should exist before any read pool instance is
837 // created. If the primary instance is a part of the request payload, then
838 // the API will take care of creating instances in the correct order.
839 // This method is here to support Google-internal use cases, and is not meant
840 // for external customers to consume. Please do not start relying on it; its
841 // behavior is subject to change without notice.
842 func (c *AlloyDBAdminClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
843 return c.internalClient.BatchCreateInstances(ctx, req, opts...)
844 }
845
846 // BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
847 // The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
848 func (c *AlloyDBAdminClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
849 return c.internalClient.BatchCreateInstancesOperation(name)
850 }
851
852 // UpdateInstance updates the parameters of a single Instance.
853 func (c *AlloyDBAdminClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
854 return c.internalClient.UpdateInstance(ctx, req, opts...)
855 }
856
857 // UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
858 // The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
859 func (c *AlloyDBAdminClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
860 return c.internalClient.UpdateInstanceOperation(name)
861 }
862
863 // DeleteInstance deletes a single Instance.
864 func (c *AlloyDBAdminClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
865 return c.internalClient.DeleteInstance(ctx, req, opts...)
866 }
867
868 // DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
869 // The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
870 func (c *AlloyDBAdminClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
871 return c.internalClient.DeleteInstanceOperation(name)
872 }
873
874 // FailoverInstance forces a Failover for a highly available instance.
875 // Failover promotes the HA standby instance as the new primary.
876 // Imperative only.
877 func (c *AlloyDBAdminClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
878 return c.internalClient.FailoverInstance(ctx, req, opts...)
879 }
880
881 // FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
882 // The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
883 func (c *AlloyDBAdminClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
884 return c.internalClient.FailoverInstanceOperation(name)
885 }
886
887 // InjectFault injects fault in an instance.
888 // Imperative only.
889 func (c *AlloyDBAdminClient) InjectFault(ctx context.Context, req *alloydbpb.InjectFaultRequest, opts ...gax.CallOption) (*InjectFaultOperation, error) {
890 return c.internalClient.InjectFault(ctx, req, opts...)
891 }
892
893 // InjectFaultOperation returns a new InjectFaultOperation from a given name.
894 // The name must be that of a previously created InjectFaultOperation, possibly from a different process.
895 func (c *AlloyDBAdminClient) InjectFaultOperation(name string) *InjectFaultOperation {
896 return c.internalClient.InjectFaultOperation(name)
897 }
898
899 // RestartInstance restart an Instance in a cluster.
900 // Imperative only.
901 func (c *AlloyDBAdminClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
902 return c.internalClient.RestartInstance(ctx, req, opts...)
903 }
904
905 // RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
906 // The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
907 func (c *AlloyDBAdminClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
908 return c.internalClient.RestartInstanceOperation(name)
909 }
910
911 // ExecuteSql executes a SQL statement in a database inside an AlloyDB instance.
912 func (c *AlloyDBAdminClient) ExecuteSql(ctx context.Context, req *alloydbpb.ExecuteSqlRequest, opts ...gax.CallOption) (*alloydbpb.ExecuteSqlResponse, error) {
913 return c.internalClient.ExecuteSql(ctx, req, opts...)
914 }
915
916 // ListBackups lists Backups in a given project and location.
917 func (c *AlloyDBAdminClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
918 return c.internalClient.ListBackups(ctx, req, opts...)
919 }
920
921 // GetBackup gets details of a single Backup.
922 func (c *AlloyDBAdminClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
923 return c.internalClient.GetBackup(ctx, req, opts...)
924 }
925
926 // CreateBackup creates a new Backup in a given project and location.
927 func (c *AlloyDBAdminClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
928 return c.internalClient.CreateBackup(ctx, req, opts...)
929 }
930
931 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
932 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
933 func (c *AlloyDBAdminClient) CreateBackupOperation(name string) *CreateBackupOperation {
934 return c.internalClient.CreateBackupOperation(name)
935 }
936
937 // UpdateBackup updates the parameters of a single Backup.
938 func (c *AlloyDBAdminClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
939 return c.internalClient.UpdateBackup(ctx, req, opts...)
940 }
941
942 // UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
943 // The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
944 func (c *AlloyDBAdminClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
945 return c.internalClient.UpdateBackupOperation(name)
946 }
947
948 // DeleteBackup deletes a single Backup.
949 func (c *AlloyDBAdminClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
950 return c.internalClient.DeleteBackup(ctx, req, opts...)
951 }
952
953 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
954 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
955 func (c *AlloyDBAdminClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
956 return c.internalClient.DeleteBackupOperation(name)
957 }
958
959 // ListSupportedDatabaseFlags lists SupportedDatabaseFlags for a given project and location.
960 func (c *AlloyDBAdminClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
961 return c.internalClient.ListSupportedDatabaseFlags(ctx, req, opts...)
962 }
963
964 // GenerateClientCertificate generate a client certificate signed by a Cluster CA.
965 // The sole purpose of this endpoint is to support AlloyDB connectors and the
966 // Auth Proxy client. The endpoint’s behavior is subject to change without
967 // notice, so do not rely on its behavior remaining constant. Future changes
968 // will not break AlloyDB connectors or the Auth Proxy client.
969 func (c *AlloyDBAdminClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
970 return c.internalClient.GenerateClientCertificate(ctx, req, opts...)
971 }
972
973 // GetConnectionInfo get instance metadata used for a connection.
974 func (c *AlloyDBAdminClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
975 return c.internalClient.GetConnectionInfo(ctx, req, opts...)
976 }
977
978 // ListUsers lists Users in a given project and location.
979 func (c *AlloyDBAdminClient) ListUsers(ctx context.Context, req *alloydbpb.ListUsersRequest, opts ...gax.CallOption) *UserIterator {
980 return c.internalClient.ListUsers(ctx, req, opts...)
981 }
982
983 // GetUser gets details of a single User.
984 func (c *AlloyDBAdminClient) GetUser(ctx context.Context, req *alloydbpb.GetUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
985 return c.internalClient.GetUser(ctx, req, opts...)
986 }
987
988 // CreateUser creates a new User in a given project, location, and cluster.
989 func (c *AlloyDBAdminClient) CreateUser(ctx context.Context, req *alloydbpb.CreateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
990 return c.internalClient.CreateUser(ctx, req, opts...)
991 }
992
993 // UpdateUser updates the parameters of a single User.
994 func (c *AlloyDBAdminClient) UpdateUser(ctx context.Context, req *alloydbpb.UpdateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
995 return c.internalClient.UpdateUser(ctx, req, opts...)
996 }
997
998 // DeleteUser deletes a single User.
999 func (c *AlloyDBAdminClient) DeleteUser(ctx context.Context, req *alloydbpb.DeleteUserRequest, opts ...gax.CallOption) error {
1000 return c.internalClient.DeleteUser(ctx, req, opts...)
1001 }
1002
1003 // ListDatabases lists Databases in a given project and location.
1004 func (c *AlloyDBAdminClient) ListDatabases(ctx context.Context, req *alloydbpb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
1005 return c.internalClient.ListDatabases(ctx, req, opts...)
1006 }
1007
1008 // GetLocation gets information about a location.
1009 func (c *AlloyDBAdminClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1010 return c.internalClient.GetLocation(ctx, req, opts...)
1011 }
1012
1013 // ListLocations lists information about the supported locations for this service.
1014 func (c *AlloyDBAdminClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1015 return c.internalClient.ListLocations(ctx, req, opts...)
1016 }
1017
1018 // CancelOperation is a utility method from google.longrunning.Operations.
1019 func (c *AlloyDBAdminClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1020 return c.internalClient.CancelOperation(ctx, req, opts...)
1021 }
1022
1023 // DeleteOperation is a utility method from google.longrunning.Operations.
1024 func (c *AlloyDBAdminClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1025 return c.internalClient.DeleteOperation(ctx, req, opts...)
1026 }
1027
1028 // GetOperation is a utility method from google.longrunning.Operations.
1029 func (c *AlloyDBAdminClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1030 return c.internalClient.GetOperation(ctx, req, opts...)
1031 }
1032
1033 // ListOperations is a utility method from google.longrunning.Operations.
1034 func (c *AlloyDBAdminClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1035 return c.internalClient.ListOperations(ctx, req, opts...)
1036 }
1037
1038 // alloyDBAdminGRPCClient is a client for interacting with AlloyDB API over gRPC transport.
1039 //
1040 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
1041 type alloyDBAdminGRPCClient struct {
1042 // Connection pool of gRPC connections to the service.
1043 connPool gtransport.ConnPool
1044
1045 // Points back to the CallOptions field of the containing AlloyDBAdminClient
1046 CallOptions **AlloyDBAdminCallOptions
1047
1048 // The gRPC API client.
1049 alloyDBAdminClient alloydbpb.AlloyDBAdminClient
1050
1051 // LROClient is used internally to handle long-running operations.
1052 // It is exposed so that its CallOptions can be modified if required.
1053 // Users should not Close this client.
1054 LROClient **lroauto.OperationsClient
1055
1056 operationsClient longrunningpb.OperationsClient
1057
1058 locationsClient locationpb.LocationsClient
1059
1060 // The x-goog-* metadata to be sent with each request.
1061 xGoogHeaders []string
1062
1063 logger *slog.Logger
1064 }
1065
1066 // NewAlloyDBAdminClient creates a new alloydb admin client based on gRPC.
1067 // The returned client must be Closed when it is done being used to clean up its underlying connections.
1068 //
1069 // Service describing handlers for resources
1070 func NewAlloyDBAdminClient(ctx context.Context, opts ...option.ClientOption) (*AlloyDBAdminClient, error) {
1071 clientOpts := defaultAlloyDBAdminGRPCClientOptions()
1072 if newAlloyDBAdminClientHook != nil {
1073 hookOpts, err := newAlloyDBAdminClientHook(ctx, clientHookParams{})
1074 if err != nil {
1075 return nil, err
1076 }
1077 clientOpts = append(clientOpts, hookOpts...)
1078 }
1079
1080 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
1081 if err != nil {
1082 return nil, err
1083 }
1084 client := AlloyDBAdminClient{CallOptions: defaultAlloyDBAdminCallOptions()}
1085
1086 c := &alloyDBAdminGRPCClient{
1087 connPool: connPool,
1088 alloyDBAdminClient: alloydbpb.NewAlloyDBAdminClient(connPool),
1089 CallOptions: &client.CallOptions,
1090 logger: internaloption.GetLogger(opts),
1091 operationsClient: longrunningpb.NewOperationsClient(connPool),
1092 locationsClient: locationpb.NewLocationsClient(connPool),
1093 }
1094 c.setGoogleClientInfo()
1095
1096 client.internalClient = c
1097
1098 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
1099 if err != nil {
1100 // This error "should not happen", since we are just reusing old connection pool
1101 // and never actually need to dial.
1102 // If this does happen, we could leak connp. However, we cannot close conn:
1103 // If the user invoked the constructor with option.WithGRPCConn,
1104 // we would close a connection that's still in use.
1105 // TODO: investigate error conditions.
1106 return nil, err
1107 }
1108 c.LROClient = &client.LROClient
1109 return &client, nil
1110 }
1111
1112 // Connection returns a connection to the API service.
1113 //
1114 // Deprecated: Connections are now pooled so this method does not always
1115 // return the same resource.
1116 func (c *alloyDBAdminGRPCClient) Connection() *grpc.ClientConn {
1117 return c.connPool.Conn()
1118 }
1119
1120 // setGoogleClientInfo sets the name and version of the application in
1121 // the `x-goog-api-client` header passed on each request. Intended for
1122 // use by Google-written clients.
1123 func (c *alloyDBAdminGRPCClient) setGoogleClientInfo(keyval ...string) {
1124 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1125 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
1126 c.xGoogHeaders = []string{
1127 "x-goog-api-client", gax.XGoogHeader(kv...),
1128 }
1129 }
1130
1131 // Close closes the connection to the API service. The user should invoke this when
1132 // the client is no longer required.
1133 func (c *alloyDBAdminGRPCClient) Close() error {
1134 return c.connPool.Close()
1135 }
1136
1137 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
1138 type alloyDBAdminRESTClient struct {
1139 // The http endpoint to connect to.
1140 endpoint string
1141
1142 // The http client.
1143 httpClient *http.Client
1144
1145 // LROClient is used internally to handle long-running operations.
1146 // It is exposed so that its CallOptions can be modified if required.
1147 // Users should not Close this client.
1148 LROClient **lroauto.OperationsClient
1149
1150 // The x-goog-* headers to be sent with each request.
1151 xGoogHeaders []string
1152
1153 // Points back to the CallOptions field of the containing AlloyDBAdminClient
1154 CallOptions **AlloyDBAdminCallOptions
1155
1156 logger *slog.Logger
1157 }
1158
1159 // NewAlloyDBAdminRESTClient creates a new alloydb admin rest client.
1160 //
1161 // Service describing handlers for resources
1162 func NewAlloyDBAdminRESTClient(ctx context.Context, opts ...option.ClientOption) (*AlloyDBAdminClient, error) {
1163 clientOpts := append(defaultAlloyDBAdminRESTClientOptions(), opts...)
1164 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
1165 if err != nil {
1166 return nil, err
1167 }
1168
1169 callOpts := defaultAlloyDBAdminRESTCallOptions()
1170 c := &alloyDBAdminRESTClient{
1171 endpoint: endpoint,
1172 httpClient: httpClient,
1173 CallOptions: &callOpts,
1174 logger: internaloption.GetLogger(opts),
1175 }
1176 c.setGoogleClientInfo()
1177
1178 lroOpts := []option.ClientOption{
1179 option.WithHTTPClient(httpClient),
1180 option.WithEndpoint(endpoint),
1181 }
1182 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
1183 if err != nil {
1184 return nil, err
1185 }
1186 c.LROClient = &opClient
1187
1188 return &AlloyDBAdminClient{internalClient: c, CallOptions: callOpts}, nil
1189 }
1190
1191 func defaultAlloyDBAdminRESTClientOptions() []option.ClientOption {
1192 return []option.ClientOption{
1193 internaloption.WithDefaultEndpoint("https://alloydb.googleapis.com"),
1194 internaloption.WithDefaultEndpointTemplate("https://alloydb.UNIVERSE_DOMAIN"),
1195 internaloption.WithDefaultMTLSEndpoint("https://alloydb.mtls.googleapis.com"),
1196 internaloption.WithDefaultUniverseDomain("googleapis.com"),
1197 internaloption.WithDefaultAudience("https://alloydb.googleapis.com/"),
1198 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
1199 internaloption.EnableNewAuthLibrary(),
1200 }
1201 }
1202
1203 // setGoogleClientInfo sets the name and version of the application in
1204 // the `x-goog-api-client` header passed on each request. Intended for
1205 // use by Google-written clients.
1206 func (c *alloyDBAdminRESTClient) setGoogleClientInfo(keyval ...string) {
1207 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1208 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
1209 c.xGoogHeaders = []string{
1210 "x-goog-api-client", gax.XGoogHeader(kv...),
1211 }
1212 }
1213
1214 // Close closes the connection to the API service. The user should invoke this when
1215 // the client is no longer required.
1216 func (c *alloyDBAdminRESTClient) Close() error {
1217 // Replace httpClient with nil to force cleanup.
1218 c.httpClient = nil
1219 return nil
1220 }
1221
1222 // Connection returns a connection to the API service.
1223 //
1224 // Deprecated: This method always returns nil.
1225 func (c *alloyDBAdminRESTClient) Connection() *grpc.ClientConn {
1226 return nil
1227 }
1228 func (c *alloyDBAdminGRPCClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
1229 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1230
1231 hds = append(c.xGoogHeaders, hds...)
1232 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1233 opts = append((*c.CallOptions).ListClusters[0:len((*c.CallOptions).ListClusters):len((*c.CallOptions).ListClusters)], opts...)
1234 it := &ClusterIterator{}
1235 req = proto.Clone(req).(*alloydbpb.ListClustersRequest)
1236 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Cluster, string, error) {
1237 resp := &alloydbpb.ListClustersResponse{}
1238 if pageToken != "" {
1239 req.PageToken = pageToken
1240 }
1241 if pageSize > math.MaxInt32 {
1242 req.PageSize = math.MaxInt32
1243 } else if pageSize != 0 {
1244 req.PageSize = int32(pageSize)
1245 }
1246 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1247 var err error
1248 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListClusters, req, settings.GRPC, c.logger, "ListClusters")
1249 return err
1250 }, opts...)
1251 if err != nil {
1252 return nil, "", err
1253 }
1254
1255 it.Response = resp
1256 return resp.GetClusters(), resp.GetNextPageToken(), nil
1257 }
1258 fetch := func(pageSize int, pageToken string) (string, error) {
1259 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1260 if err != nil {
1261 return "", err
1262 }
1263 it.items = append(it.items, items...)
1264 return nextPageToken, nil
1265 }
1266
1267 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1268 it.pageInfo.MaxSize = int(req.GetPageSize())
1269 it.pageInfo.Token = req.GetPageToken()
1270
1271 return it
1272 }
1273
1274 func (c *alloyDBAdminGRPCClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
1275 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1276
1277 hds = append(c.xGoogHeaders, hds...)
1278 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1279 opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
1280 var resp *alloydbpb.Cluster
1281 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1282 var err error
1283 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GetCluster, req, settings.GRPC, c.logger, "GetCluster")
1284 return err
1285 }, opts...)
1286 if err != nil {
1287 return nil, err
1288 }
1289 return resp, nil
1290 }
1291
1292 func (c *alloyDBAdminGRPCClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
1293 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1294
1295 hds = append(c.xGoogHeaders, hds...)
1296 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1297 opts = append((*c.CallOptions).CreateCluster[0:len((*c.CallOptions).CreateCluster):len((*c.CallOptions).CreateCluster)], opts...)
1298 var resp *longrunningpb.Operation
1299 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1300 var err error
1301 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateCluster, req, settings.GRPC, c.logger, "CreateCluster")
1302 return err
1303 }, opts...)
1304 if err != nil {
1305 return nil, err
1306 }
1307 return &CreateClusterOperation{
1308 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1309 }, nil
1310 }
1311
1312 func (c *alloyDBAdminGRPCClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
1313 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName()))}
1314
1315 hds = append(c.xGoogHeaders, hds...)
1316 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1317 opts = append((*c.CallOptions).UpdateCluster[0:len((*c.CallOptions).UpdateCluster):len((*c.CallOptions).UpdateCluster)], opts...)
1318 var resp *longrunningpb.Operation
1319 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1320 var err error
1321 resp, err = executeRPC(ctx, c.alloyDBAdminClient.UpdateCluster, req, settings.GRPC, c.logger, "UpdateCluster")
1322 return err
1323 }, opts...)
1324 if err != nil {
1325 return nil, err
1326 }
1327 return &UpdateClusterOperation{
1328 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1329 }, nil
1330 }
1331
1332 func (c *alloyDBAdminGRPCClient) ExportCluster(ctx context.Context, req *alloydbpb.ExportClusterRequest, opts ...gax.CallOption) (*ExportClusterOperation, error) {
1333 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1334
1335 hds = append(c.xGoogHeaders, hds...)
1336 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1337 opts = append((*c.CallOptions).ExportCluster[0:len((*c.CallOptions).ExportCluster):len((*c.CallOptions).ExportCluster)], opts...)
1338 var resp *longrunningpb.Operation
1339 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1340 var err error
1341 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ExportCluster, req, settings.GRPC, c.logger, "ExportCluster")
1342 return err
1343 }, opts...)
1344 if err != nil {
1345 return nil, err
1346 }
1347 return &ExportClusterOperation{
1348 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1349 }, nil
1350 }
1351
1352 func (c *alloyDBAdminGRPCClient) ImportCluster(ctx context.Context, req *alloydbpb.ImportClusterRequest, opts ...gax.CallOption) (*ImportClusterOperation, error) {
1353 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1354
1355 hds = append(c.xGoogHeaders, hds...)
1356 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1357 opts = append((*c.CallOptions).ImportCluster[0:len((*c.CallOptions).ImportCluster):len((*c.CallOptions).ImportCluster)], opts...)
1358 var resp *longrunningpb.Operation
1359 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1360 var err error
1361 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ImportCluster, req, settings.GRPC, c.logger, "ImportCluster")
1362 return err
1363 }, opts...)
1364 if err != nil {
1365 return nil, err
1366 }
1367 return &ImportClusterOperation{
1368 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1369 }, nil
1370 }
1371
1372 func (c *alloyDBAdminGRPCClient) UpgradeCluster(ctx context.Context, req *alloydbpb.UpgradeClusterRequest, opts ...gax.CallOption) (*UpgradeClusterOperation, error) {
1373 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1374
1375 hds = append(c.xGoogHeaders, hds...)
1376 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1377 opts = append((*c.CallOptions).UpgradeCluster[0:len((*c.CallOptions).UpgradeCluster):len((*c.CallOptions).UpgradeCluster)], opts...)
1378 var resp *longrunningpb.Operation
1379 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1380 var err error
1381 resp, err = executeRPC(ctx, c.alloyDBAdminClient.UpgradeCluster, req, settings.GRPC, c.logger, "UpgradeCluster")
1382 return err
1383 }, opts...)
1384 if err != nil {
1385 return nil, err
1386 }
1387 return &UpgradeClusterOperation{
1388 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1389 }, nil
1390 }
1391
1392 func (c *alloyDBAdminGRPCClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
1393 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1394
1395 hds = append(c.xGoogHeaders, hds...)
1396 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1397 opts = append((*c.CallOptions).DeleteCluster[0:len((*c.CallOptions).DeleteCluster):len((*c.CallOptions).DeleteCluster)], opts...)
1398 var resp *longrunningpb.Operation
1399 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1400 var err error
1401 resp, err = executeRPC(ctx, c.alloyDBAdminClient.DeleteCluster, req, settings.GRPC, c.logger, "DeleteCluster")
1402 return err
1403 }, opts...)
1404 if err != nil {
1405 return nil, err
1406 }
1407 return &DeleteClusterOperation{
1408 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1409 }, nil
1410 }
1411
1412 func (c *alloyDBAdminGRPCClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
1413 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1414
1415 hds = append(c.xGoogHeaders, hds...)
1416 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1417 opts = append((*c.CallOptions).PromoteCluster[0:len((*c.CallOptions).PromoteCluster):len((*c.CallOptions).PromoteCluster)], opts...)
1418 var resp *longrunningpb.Operation
1419 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1420 var err error
1421 resp, err = executeRPC(ctx, c.alloyDBAdminClient.PromoteCluster, req, settings.GRPC, c.logger, "PromoteCluster")
1422 return err
1423 }, opts...)
1424 if err != nil {
1425 return nil, err
1426 }
1427 return &PromoteClusterOperation{
1428 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1429 }, nil
1430 }
1431
1432 func (c *alloyDBAdminGRPCClient) SwitchoverCluster(ctx context.Context, req *alloydbpb.SwitchoverClusterRequest, opts ...gax.CallOption) (*SwitchoverClusterOperation, error) {
1433 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1434
1435 hds = append(c.xGoogHeaders, hds...)
1436 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1437 opts = append((*c.CallOptions).SwitchoverCluster[0:len((*c.CallOptions).SwitchoverCluster):len((*c.CallOptions).SwitchoverCluster)], opts...)
1438 var resp *longrunningpb.Operation
1439 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1440 var err error
1441 resp, err = executeRPC(ctx, c.alloyDBAdminClient.SwitchoverCluster, req, settings.GRPC, c.logger, "SwitchoverCluster")
1442 return err
1443 }, opts...)
1444 if err != nil {
1445 return nil, err
1446 }
1447 return &SwitchoverClusterOperation{
1448 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1449 }, nil
1450 }
1451
1452 func (c *alloyDBAdminGRPCClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
1453 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1454
1455 hds = append(c.xGoogHeaders, hds...)
1456 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1457 opts = append((*c.CallOptions).RestoreCluster[0:len((*c.CallOptions).RestoreCluster):len((*c.CallOptions).RestoreCluster)], opts...)
1458 var resp *longrunningpb.Operation
1459 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1460 var err error
1461 resp, err = executeRPC(ctx, c.alloyDBAdminClient.RestoreCluster, req, settings.GRPC, c.logger, "RestoreCluster")
1462 return err
1463 }, opts...)
1464 if err != nil {
1465 return nil, err
1466 }
1467 return &RestoreClusterOperation{
1468 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1469 }, nil
1470 }
1471
1472 func (c *alloyDBAdminGRPCClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
1473 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1474
1475 hds = append(c.xGoogHeaders, hds...)
1476 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1477 opts = append((*c.CallOptions).CreateSecondaryCluster[0:len((*c.CallOptions).CreateSecondaryCluster):len((*c.CallOptions).CreateSecondaryCluster)], opts...)
1478 var resp *longrunningpb.Operation
1479 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1480 var err error
1481 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateSecondaryCluster, req, settings.GRPC, c.logger, "CreateSecondaryCluster")
1482 return err
1483 }, opts...)
1484 if err != nil {
1485 return nil, err
1486 }
1487 return &CreateSecondaryClusterOperation{
1488 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1489 }, nil
1490 }
1491
1492 func (c *alloyDBAdminGRPCClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
1493 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1494
1495 hds = append(c.xGoogHeaders, hds...)
1496 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1497 opts = append((*c.CallOptions).ListInstances[0:len((*c.CallOptions).ListInstances):len((*c.CallOptions).ListInstances)], opts...)
1498 it := &InstanceIterator{}
1499 req = proto.Clone(req).(*alloydbpb.ListInstancesRequest)
1500 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Instance, string, error) {
1501 resp := &alloydbpb.ListInstancesResponse{}
1502 if pageToken != "" {
1503 req.PageToken = pageToken
1504 }
1505 if pageSize > math.MaxInt32 {
1506 req.PageSize = math.MaxInt32
1507 } else if pageSize != 0 {
1508 req.PageSize = int32(pageSize)
1509 }
1510 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1511 var err error
1512 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListInstances, req, settings.GRPC, c.logger, "ListInstances")
1513 return err
1514 }, opts...)
1515 if err != nil {
1516 return nil, "", err
1517 }
1518
1519 it.Response = resp
1520 return resp.GetInstances(), resp.GetNextPageToken(), nil
1521 }
1522 fetch := func(pageSize int, pageToken string) (string, error) {
1523 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1524 if err != nil {
1525 return "", err
1526 }
1527 it.items = append(it.items, items...)
1528 return nextPageToken, nil
1529 }
1530
1531 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1532 it.pageInfo.MaxSize = int(req.GetPageSize())
1533 it.pageInfo.Token = req.GetPageToken()
1534
1535 return it
1536 }
1537
1538 func (c *alloyDBAdminGRPCClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
1539 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1540
1541 hds = append(c.xGoogHeaders, hds...)
1542 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1543 opts = append((*c.CallOptions).GetInstance[0:len((*c.CallOptions).GetInstance):len((*c.CallOptions).GetInstance)], opts...)
1544 var resp *alloydbpb.Instance
1545 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1546 var err error
1547 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GetInstance, req, settings.GRPC, c.logger, "GetInstance")
1548 return err
1549 }, opts...)
1550 if err != nil {
1551 return nil, err
1552 }
1553 return resp, nil
1554 }
1555
1556 func (c *alloyDBAdminGRPCClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
1557 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1558
1559 hds = append(c.xGoogHeaders, hds...)
1560 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1561 opts = append((*c.CallOptions).CreateInstance[0:len((*c.CallOptions).CreateInstance):len((*c.CallOptions).CreateInstance)], opts...)
1562 var resp *longrunningpb.Operation
1563 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1564 var err error
1565 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateInstance, req, settings.GRPC, c.logger, "CreateInstance")
1566 return err
1567 }, opts...)
1568 if err != nil {
1569 return nil, err
1570 }
1571 return &CreateInstanceOperation{
1572 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1573 }, nil
1574 }
1575
1576 func (c *alloyDBAdminGRPCClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
1577 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1578
1579 hds = append(c.xGoogHeaders, hds...)
1580 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1581 opts = append((*c.CallOptions).CreateSecondaryInstance[0:len((*c.CallOptions).CreateSecondaryInstance):len((*c.CallOptions).CreateSecondaryInstance)], opts...)
1582 var resp *longrunningpb.Operation
1583 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1584 var err error
1585 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateSecondaryInstance, req, settings.GRPC, c.logger, "CreateSecondaryInstance")
1586 return err
1587 }, opts...)
1588 if err != nil {
1589 return nil, err
1590 }
1591 return &CreateSecondaryInstanceOperation{
1592 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1593 }, nil
1594 }
1595
1596 func (c *alloyDBAdminGRPCClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
1597 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1598
1599 hds = append(c.xGoogHeaders, hds...)
1600 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1601 opts = append((*c.CallOptions).BatchCreateInstances[0:len((*c.CallOptions).BatchCreateInstances):len((*c.CallOptions).BatchCreateInstances)], opts...)
1602 var resp *longrunningpb.Operation
1603 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1604 var err error
1605 resp, err = executeRPC(ctx, c.alloyDBAdminClient.BatchCreateInstances, req, settings.GRPC, c.logger, "BatchCreateInstances")
1606 return err
1607 }, opts...)
1608 if err != nil {
1609 return nil, err
1610 }
1611 return &BatchCreateInstancesOperation{
1612 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1613 }, nil
1614 }
1615
1616 func (c *alloyDBAdminGRPCClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
1617 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "instance.name", url.QueryEscape(req.GetInstance().GetName()))}
1618
1619 hds = append(c.xGoogHeaders, hds...)
1620 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1621 opts = append((*c.CallOptions).UpdateInstance[0:len((*c.CallOptions).UpdateInstance):len((*c.CallOptions).UpdateInstance)], opts...)
1622 var resp *longrunningpb.Operation
1623 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1624 var err error
1625 resp, err = executeRPC(ctx, c.alloyDBAdminClient.UpdateInstance, req, settings.GRPC, c.logger, "UpdateInstance")
1626 return err
1627 }, opts...)
1628 if err != nil {
1629 return nil, err
1630 }
1631 return &UpdateInstanceOperation{
1632 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1633 }, nil
1634 }
1635
1636 func (c *alloyDBAdminGRPCClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
1637 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1638
1639 hds = append(c.xGoogHeaders, hds...)
1640 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1641 opts = append((*c.CallOptions).DeleteInstance[0:len((*c.CallOptions).DeleteInstance):len((*c.CallOptions).DeleteInstance)], opts...)
1642 var resp *longrunningpb.Operation
1643 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1644 var err error
1645 resp, err = executeRPC(ctx, c.alloyDBAdminClient.DeleteInstance, req, settings.GRPC, c.logger, "DeleteInstance")
1646 return err
1647 }, opts...)
1648 if err != nil {
1649 return nil, err
1650 }
1651 return &DeleteInstanceOperation{
1652 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1653 }, nil
1654 }
1655
1656 func (c *alloyDBAdminGRPCClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
1657 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1658
1659 hds = append(c.xGoogHeaders, hds...)
1660 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1661 opts = append((*c.CallOptions).FailoverInstance[0:len((*c.CallOptions).FailoverInstance):len((*c.CallOptions).FailoverInstance)], opts...)
1662 var resp *longrunningpb.Operation
1663 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1664 var err error
1665 resp, err = executeRPC(ctx, c.alloyDBAdminClient.FailoverInstance, req, settings.GRPC, c.logger, "FailoverInstance")
1666 return err
1667 }, opts...)
1668 if err != nil {
1669 return nil, err
1670 }
1671 return &FailoverInstanceOperation{
1672 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1673 }, nil
1674 }
1675
1676 func (c *alloyDBAdminGRPCClient) InjectFault(ctx context.Context, req *alloydbpb.InjectFaultRequest, opts ...gax.CallOption) (*InjectFaultOperation, error) {
1677 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1678
1679 hds = append(c.xGoogHeaders, hds...)
1680 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1681 opts = append((*c.CallOptions).InjectFault[0:len((*c.CallOptions).InjectFault):len((*c.CallOptions).InjectFault)], opts...)
1682 var resp *longrunningpb.Operation
1683 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1684 var err error
1685 resp, err = executeRPC(ctx, c.alloyDBAdminClient.InjectFault, req, settings.GRPC, c.logger, "InjectFault")
1686 return err
1687 }, opts...)
1688 if err != nil {
1689 return nil, err
1690 }
1691 return &InjectFaultOperation{
1692 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1693 }, nil
1694 }
1695
1696 func (c *alloyDBAdminGRPCClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
1697 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1698
1699 hds = append(c.xGoogHeaders, hds...)
1700 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1701 opts = append((*c.CallOptions).RestartInstance[0:len((*c.CallOptions).RestartInstance):len((*c.CallOptions).RestartInstance)], opts...)
1702 var resp *longrunningpb.Operation
1703 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1704 var err error
1705 resp, err = executeRPC(ctx, c.alloyDBAdminClient.RestartInstance, req, settings.GRPC, c.logger, "RestartInstance")
1706 return err
1707 }, opts...)
1708 if err != nil {
1709 return nil, err
1710 }
1711 return &RestartInstanceOperation{
1712 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1713 }, nil
1714 }
1715
1716 func (c *alloyDBAdminGRPCClient) ExecuteSql(ctx context.Context, req *alloydbpb.ExecuteSqlRequest, opts ...gax.CallOption) (*alloydbpb.ExecuteSqlResponse, error) {
1717 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "instance", url.QueryEscape(req.GetInstance()))}
1718
1719 hds = append(c.xGoogHeaders, hds...)
1720 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1721 opts = append((*c.CallOptions).ExecuteSql[0:len((*c.CallOptions).ExecuteSql):len((*c.CallOptions).ExecuteSql)], opts...)
1722 var resp *alloydbpb.ExecuteSqlResponse
1723 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1724 var err error
1725 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ExecuteSql, req, settings.GRPC, c.logger, "ExecuteSql")
1726 return err
1727 }, opts...)
1728 if err != nil {
1729 return nil, err
1730 }
1731 return resp, nil
1732 }
1733
1734 func (c *alloyDBAdminGRPCClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
1735 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1736
1737 hds = append(c.xGoogHeaders, hds...)
1738 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1739 opts = append((*c.CallOptions).ListBackups[0:len((*c.CallOptions).ListBackups):len((*c.CallOptions).ListBackups)], opts...)
1740 it := &BackupIterator{}
1741 req = proto.Clone(req).(*alloydbpb.ListBackupsRequest)
1742 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Backup, string, error) {
1743 resp := &alloydbpb.ListBackupsResponse{}
1744 if pageToken != "" {
1745 req.PageToken = pageToken
1746 }
1747 if pageSize > math.MaxInt32 {
1748 req.PageSize = math.MaxInt32
1749 } else if pageSize != 0 {
1750 req.PageSize = int32(pageSize)
1751 }
1752 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1753 var err error
1754 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListBackups, req, settings.GRPC, c.logger, "ListBackups")
1755 return err
1756 }, opts...)
1757 if err != nil {
1758 return nil, "", err
1759 }
1760
1761 it.Response = resp
1762 return resp.GetBackups(), resp.GetNextPageToken(), nil
1763 }
1764 fetch := func(pageSize int, pageToken string) (string, error) {
1765 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1766 if err != nil {
1767 return "", err
1768 }
1769 it.items = append(it.items, items...)
1770 return nextPageToken, nil
1771 }
1772
1773 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1774 it.pageInfo.MaxSize = int(req.GetPageSize())
1775 it.pageInfo.Token = req.GetPageToken()
1776
1777 return it
1778 }
1779
1780 func (c *alloyDBAdminGRPCClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
1781 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1782
1783 hds = append(c.xGoogHeaders, hds...)
1784 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1785 opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
1786 var resp *alloydbpb.Backup
1787 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1788 var err error
1789 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GetBackup, req, settings.GRPC, c.logger, "GetBackup")
1790 return err
1791 }, opts...)
1792 if err != nil {
1793 return nil, err
1794 }
1795 return resp, nil
1796 }
1797
1798 func (c *alloyDBAdminGRPCClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
1799 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1800
1801 hds = append(c.xGoogHeaders, hds...)
1802 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1803 opts = append((*c.CallOptions).CreateBackup[0:len((*c.CallOptions).CreateBackup):len((*c.CallOptions).CreateBackup)], opts...)
1804 var resp *longrunningpb.Operation
1805 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1806 var err error
1807 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateBackup, req, settings.GRPC, c.logger, "CreateBackup")
1808 return err
1809 }, opts...)
1810 if err != nil {
1811 return nil, err
1812 }
1813 return &CreateBackupOperation{
1814 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1815 }, nil
1816 }
1817
1818 func (c *alloyDBAdminGRPCClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
1819 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "backup.name", url.QueryEscape(req.GetBackup().GetName()))}
1820
1821 hds = append(c.xGoogHeaders, hds...)
1822 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1823 opts = append((*c.CallOptions).UpdateBackup[0:len((*c.CallOptions).UpdateBackup):len((*c.CallOptions).UpdateBackup)], opts...)
1824 var resp *longrunningpb.Operation
1825 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1826 var err error
1827 resp, err = executeRPC(ctx, c.alloyDBAdminClient.UpdateBackup, req, settings.GRPC, c.logger, "UpdateBackup")
1828 return err
1829 }, opts...)
1830 if err != nil {
1831 return nil, err
1832 }
1833 return &UpdateBackupOperation{
1834 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1835 }, nil
1836 }
1837
1838 func (c *alloyDBAdminGRPCClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
1839 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1840
1841 hds = append(c.xGoogHeaders, hds...)
1842 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1843 opts = append((*c.CallOptions).DeleteBackup[0:len((*c.CallOptions).DeleteBackup):len((*c.CallOptions).DeleteBackup)], opts...)
1844 var resp *longrunningpb.Operation
1845 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1846 var err error
1847 resp, err = executeRPC(ctx, c.alloyDBAdminClient.DeleteBackup, req, settings.GRPC, c.logger, "DeleteBackup")
1848 return err
1849 }, opts...)
1850 if err != nil {
1851 return nil, err
1852 }
1853 return &DeleteBackupOperation{
1854 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1855 }, nil
1856 }
1857
1858 func (c *alloyDBAdminGRPCClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
1859 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1860
1861 hds = append(c.xGoogHeaders, hds...)
1862 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1863 opts = append((*c.CallOptions).ListSupportedDatabaseFlags[0:len((*c.CallOptions).ListSupportedDatabaseFlags):len((*c.CallOptions).ListSupportedDatabaseFlags)], opts...)
1864 it := &SupportedDatabaseFlagIterator{}
1865 req = proto.Clone(req).(*alloydbpb.ListSupportedDatabaseFlagsRequest)
1866 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.SupportedDatabaseFlag, string, error) {
1867 resp := &alloydbpb.ListSupportedDatabaseFlagsResponse{}
1868 if pageToken != "" {
1869 req.PageToken = pageToken
1870 }
1871 if pageSize > math.MaxInt32 {
1872 req.PageSize = math.MaxInt32
1873 } else if pageSize != 0 {
1874 req.PageSize = int32(pageSize)
1875 }
1876 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1877 var err error
1878 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListSupportedDatabaseFlags, req, settings.GRPC, c.logger, "ListSupportedDatabaseFlags")
1879 return err
1880 }, opts...)
1881 if err != nil {
1882 return nil, "", err
1883 }
1884
1885 it.Response = resp
1886 return resp.GetSupportedDatabaseFlags(), resp.GetNextPageToken(), nil
1887 }
1888 fetch := func(pageSize int, pageToken string) (string, error) {
1889 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1890 if err != nil {
1891 return "", err
1892 }
1893 it.items = append(it.items, items...)
1894 return nextPageToken, nil
1895 }
1896
1897 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1898 it.pageInfo.MaxSize = int(req.GetPageSize())
1899 it.pageInfo.Token = req.GetPageToken()
1900
1901 return it
1902 }
1903
1904 func (c *alloyDBAdminGRPCClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
1905 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1906
1907 hds = append(c.xGoogHeaders, hds...)
1908 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1909 opts = append((*c.CallOptions).GenerateClientCertificate[0:len((*c.CallOptions).GenerateClientCertificate):len((*c.CallOptions).GenerateClientCertificate)], opts...)
1910 var resp *alloydbpb.GenerateClientCertificateResponse
1911 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1912 var err error
1913 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GenerateClientCertificate, req, settings.GRPC, c.logger, "GenerateClientCertificate")
1914 return err
1915 }, opts...)
1916 if err != nil {
1917 return nil, err
1918 }
1919 return resp, nil
1920 }
1921
1922 func (c *alloyDBAdminGRPCClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
1923 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1924
1925 hds = append(c.xGoogHeaders, hds...)
1926 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1927 opts = append((*c.CallOptions).GetConnectionInfo[0:len((*c.CallOptions).GetConnectionInfo):len((*c.CallOptions).GetConnectionInfo)], opts...)
1928 var resp *alloydbpb.ConnectionInfo
1929 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1930 var err error
1931 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GetConnectionInfo, req, settings.GRPC, c.logger, "GetConnectionInfo")
1932 return err
1933 }, opts...)
1934 if err != nil {
1935 return nil, err
1936 }
1937 return resp, nil
1938 }
1939
1940 func (c *alloyDBAdminGRPCClient) ListUsers(ctx context.Context, req *alloydbpb.ListUsersRequest, opts ...gax.CallOption) *UserIterator {
1941 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1942
1943 hds = append(c.xGoogHeaders, hds...)
1944 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1945 opts = append((*c.CallOptions).ListUsers[0:len((*c.CallOptions).ListUsers):len((*c.CallOptions).ListUsers)], opts...)
1946 it := &UserIterator{}
1947 req = proto.Clone(req).(*alloydbpb.ListUsersRequest)
1948 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.User, string, error) {
1949 resp := &alloydbpb.ListUsersResponse{}
1950 if pageToken != "" {
1951 req.PageToken = pageToken
1952 }
1953 if pageSize > math.MaxInt32 {
1954 req.PageSize = math.MaxInt32
1955 } else if pageSize != 0 {
1956 req.PageSize = int32(pageSize)
1957 }
1958 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1959 var err error
1960 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListUsers, req, settings.GRPC, c.logger, "ListUsers")
1961 return err
1962 }, opts...)
1963 if err != nil {
1964 return nil, "", err
1965 }
1966
1967 it.Response = resp
1968 return resp.GetUsers(), resp.GetNextPageToken(), nil
1969 }
1970 fetch := func(pageSize int, pageToken string) (string, error) {
1971 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1972 if err != nil {
1973 return "", err
1974 }
1975 it.items = append(it.items, items...)
1976 return nextPageToken, nil
1977 }
1978
1979 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1980 it.pageInfo.MaxSize = int(req.GetPageSize())
1981 it.pageInfo.Token = req.GetPageToken()
1982
1983 return it
1984 }
1985
1986 func (c *alloyDBAdminGRPCClient) GetUser(ctx context.Context, req *alloydbpb.GetUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
1987 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1988
1989 hds = append(c.xGoogHeaders, hds...)
1990 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1991 opts = append((*c.CallOptions).GetUser[0:len((*c.CallOptions).GetUser):len((*c.CallOptions).GetUser)], opts...)
1992 var resp *alloydbpb.User
1993 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1994 var err error
1995 resp, err = executeRPC(ctx, c.alloyDBAdminClient.GetUser, req, settings.GRPC, c.logger, "GetUser")
1996 return err
1997 }, opts...)
1998 if err != nil {
1999 return nil, err
2000 }
2001 return resp, nil
2002 }
2003
2004 func (c *alloyDBAdminGRPCClient) CreateUser(ctx context.Context, req *alloydbpb.CreateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
2005 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2006
2007 hds = append(c.xGoogHeaders, hds...)
2008 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2009 opts = append((*c.CallOptions).CreateUser[0:len((*c.CallOptions).CreateUser):len((*c.CallOptions).CreateUser)], opts...)
2010 var resp *alloydbpb.User
2011 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2012 var err error
2013 resp, err = executeRPC(ctx, c.alloyDBAdminClient.CreateUser, req, settings.GRPC, c.logger, "CreateUser")
2014 return err
2015 }, opts...)
2016 if err != nil {
2017 return nil, err
2018 }
2019 return resp, nil
2020 }
2021
2022 func (c *alloyDBAdminGRPCClient) UpdateUser(ctx context.Context, req *alloydbpb.UpdateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
2023 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "user.name", url.QueryEscape(req.GetUser().GetName()))}
2024
2025 hds = append(c.xGoogHeaders, hds...)
2026 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2027 opts = append((*c.CallOptions).UpdateUser[0:len((*c.CallOptions).UpdateUser):len((*c.CallOptions).UpdateUser)], opts...)
2028 var resp *alloydbpb.User
2029 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2030 var err error
2031 resp, err = executeRPC(ctx, c.alloyDBAdminClient.UpdateUser, req, settings.GRPC, c.logger, "UpdateUser")
2032 return err
2033 }, opts...)
2034 if err != nil {
2035 return nil, err
2036 }
2037 return resp, nil
2038 }
2039
2040 func (c *alloyDBAdminGRPCClient) DeleteUser(ctx context.Context, req *alloydbpb.DeleteUserRequest, opts ...gax.CallOption) error {
2041 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2042
2043 hds = append(c.xGoogHeaders, hds...)
2044 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2045 opts = append((*c.CallOptions).DeleteUser[0:len((*c.CallOptions).DeleteUser):len((*c.CallOptions).DeleteUser)], opts...)
2046 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2047 var err error
2048 _, err = executeRPC(ctx, c.alloyDBAdminClient.DeleteUser, req, settings.GRPC, c.logger, "DeleteUser")
2049 return err
2050 }, opts...)
2051 return err
2052 }
2053
2054 func (c *alloyDBAdminGRPCClient) ListDatabases(ctx context.Context, req *alloydbpb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
2055 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2056
2057 hds = append(c.xGoogHeaders, hds...)
2058 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2059 opts = append((*c.CallOptions).ListDatabases[0:len((*c.CallOptions).ListDatabases):len((*c.CallOptions).ListDatabases)], opts...)
2060 it := &DatabaseIterator{}
2061 req = proto.Clone(req).(*alloydbpb.ListDatabasesRequest)
2062 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Database, string, error) {
2063 resp := &alloydbpb.ListDatabasesResponse{}
2064 if pageToken != "" {
2065 req.PageToken = pageToken
2066 }
2067 if pageSize > math.MaxInt32 {
2068 req.PageSize = math.MaxInt32
2069 } else if pageSize != 0 {
2070 req.PageSize = int32(pageSize)
2071 }
2072 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2073 var err error
2074 resp, err = executeRPC(ctx, c.alloyDBAdminClient.ListDatabases, req, settings.GRPC, c.logger, "ListDatabases")
2075 return err
2076 }, opts...)
2077 if err != nil {
2078 return nil, "", err
2079 }
2080
2081 it.Response = resp
2082 return resp.GetDatabases(), resp.GetNextPageToken(), nil
2083 }
2084 fetch := func(pageSize int, pageToken string) (string, error) {
2085 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2086 if err != nil {
2087 return "", err
2088 }
2089 it.items = append(it.items, items...)
2090 return nextPageToken, nil
2091 }
2092
2093 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2094 it.pageInfo.MaxSize = int(req.GetPageSize())
2095 it.pageInfo.Token = req.GetPageToken()
2096
2097 return it
2098 }
2099
2100 func (c *alloyDBAdminGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2101 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2102
2103 hds = append(c.xGoogHeaders, hds...)
2104 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2105 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2106 var resp *locationpb.Location
2107 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2108 var err error
2109 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
2110 return err
2111 }, opts...)
2112 if err != nil {
2113 return nil, err
2114 }
2115 return resp, nil
2116 }
2117
2118 func (c *alloyDBAdminGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2119 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2120
2121 hds = append(c.xGoogHeaders, hds...)
2122 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2123 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
2124 it := &LocationIterator{}
2125 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2126 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2127 resp := &locationpb.ListLocationsResponse{}
2128 if pageToken != "" {
2129 req.PageToken = pageToken
2130 }
2131 if pageSize > math.MaxInt32 {
2132 req.PageSize = math.MaxInt32
2133 } else if pageSize != 0 {
2134 req.PageSize = int32(pageSize)
2135 }
2136 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2137 var err error
2138 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
2139 return err
2140 }, opts...)
2141 if err != nil {
2142 return nil, "", err
2143 }
2144
2145 it.Response = resp
2146 return resp.GetLocations(), resp.GetNextPageToken(), nil
2147 }
2148 fetch := func(pageSize int, pageToken string) (string, error) {
2149 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2150 if err != nil {
2151 return "", err
2152 }
2153 it.items = append(it.items, items...)
2154 return nextPageToken, nil
2155 }
2156
2157 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2158 it.pageInfo.MaxSize = int(req.GetPageSize())
2159 it.pageInfo.Token = req.GetPageToken()
2160
2161 return it
2162 }
2163
2164 func (c *alloyDBAdminGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2165 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2166
2167 hds = append(c.xGoogHeaders, hds...)
2168 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2169 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
2170 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2171 var err error
2172 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
2173 return err
2174 }, opts...)
2175 return err
2176 }
2177
2178 func (c *alloyDBAdminGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
2179 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2180
2181 hds = append(c.xGoogHeaders, hds...)
2182 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2183 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
2184 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2185 var err error
2186 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
2187 return err
2188 }, opts...)
2189 return err
2190 }
2191
2192 func (c *alloyDBAdminGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2193 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2194
2195 hds = append(c.xGoogHeaders, hds...)
2196 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2197 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2198 var resp *longrunningpb.Operation
2199 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2200 var err error
2201 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
2202 return err
2203 }, opts...)
2204 if err != nil {
2205 return nil, err
2206 }
2207 return resp, nil
2208 }
2209
2210 func (c *alloyDBAdminGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
2211 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2212
2213 hds = append(c.xGoogHeaders, hds...)
2214 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2215 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
2216 it := &OperationIterator{}
2217 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
2218 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
2219 resp := &longrunningpb.ListOperationsResponse{}
2220 if pageToken != "" {
2221 req.PageToken = pageToken
2222 }
2223 if pageSize > math.MaxInt32 {
2224 req.PageSize = math.MaxInt32
2225 } else if pageSize != 0 {
2226 req.PageSize = int32(pageSize)
2227 }
2228 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2229 var err error
2230 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
2231 return err
2232 }, opts...)
2233 if err != nil {
2234 return nil, "", err
2235 }
2236
2237 it.Response = resp
2238 return resp.GetOperations(), resp.GetNextPageToken(), nil
2239 }
2240 fetch := func(pageSize int, pageToken string) (string, error) {
2241 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2242 if err != nil {
2243 return "", err
2244 }
2245 it.items = append(it.items, items...)
2246 return nextPageToken, nil
2247 }
2248
2249 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2250 it.pageInfo.MaxSize = int(req.GetPageSize())
2251 it.pageInfo.Token = req.GetPageToken()
2252
2253 return it
2254 }
2255
2256 // ListClusters lists Clusters in a given project and location.
2257 func (c *alloyDBAdminRESTClient) ListClusters(ctx context.Context, req *alloydbpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
2258 it := &ClusterIterator{}
2259 req = proto.Clone(req).(*alloydbpb.ListClustersRequest)
2260 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2261 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Cluster, string, error) {
2262 resp := &alloydbpb.ListClustersResponse{}
2263 if pageToken != "" {
2264 req.PageToken = pageToken
2265 }
2266 if pageSize > math.MaxInt32 {
2267 req.PageSize = math.MaxInt32
2268 } else if pageSize != 0 {
2269 req.PageSize = int32(pageSize)
2270 }
2271 baseUrl, err := url.Parse(c.endpoint)
2272 if err != nil {
2273 return nil, "", err
2274 }
2275 baseUrl.Path += fmt.Sprintf("/v1beta/%v/clusters", req.GetParent())
2276
2277 params := url.Values{}
2278 params.Add("$alt", "json;enum-encoding=int")
2279 if req.GetFilter() != "" {
2280 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2281 }
2282 if req.GetOrderBy() != "" {
2283 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2284 }
2285 if req.GetPageSize() != 0 {
2286 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2287 }
2288 if req.GetPageToken() != "" {
2289 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2290 }
2291
2292 baseUrl.RawQuery = params.Encode()
2293
2294 // Build HTTP headers from client and context metadata.
2295 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2296 headers := gax.BuildHeaders(ctx, hds...)
2297 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2298 if settings.Path != "" {
2299 baseUrl.Path = settings.Path
2300 }
2301 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2302 if err != nil {
2303 return err
2304 }
2305 httpReq.Header = headers
2306
2307 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListClusters")
2308 if err != nil {
2309 return err
2310 }
2311 if err := unm.Unmarshal(buf, resp); err != nil {
2312 return err
2313 }
2314
2315 return nil
2316 }, opts...)
2317 if e != nil {
2318 return nil, "", e
2319 }
2320 it.Response = resp
2321 return resp.GetClusters(), resp.GetNextPageToken(), nil
2322 }
2323
2324 fetch := func(pageSize int, pageToken string) (string, error) {
2325 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2326 if err != nil {
2327 return "", err
2328 }
2329 it.items = append(it.items, items...)
2330 return nextPageToken, nil
2331 }
2332
2333 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2334 it.pageInfo.MaxSize = int(req.GetPageSize())
2335 it.pageInfo.Token = req.GetPageToken()
2336
2337 return it
2338 }
2339
2340 // GetCluster gets details of a single Cluster.
2341 func (c *alloyDBAdminRESTClient) GetCluster(ctx context.Context, req *alloydbpb.GetClusterRequest, opts ...gax.CallOption) (*alloydbpb.Cluster, error) {
2342 baseUrl, err := url.Parse(c.endpoint)
2343 if err != nil {
2344 return nil, err
2345 }
2346 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2347
2348 params := url.Values{}
2349 params.Add("$alt", "json;enum-encoding=int")
2350 if req.GetView() != 0 {
2351 params.Add("view", fmt.Sprintf("%v", req.GetView()))
2352 }
2353
2354 baseUrl.RawQuery = params.Encode()
2355
2356 // Build HTTP headers from client and context metadata.
2357 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2358
2359 hds = append(c.xGoogHeaders, hds...)
2360 hds = append(hds, "Content-Type", "application/json")
2361 headers := gax.BuildHeaders(ctx, hds...)
2362 opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
2363 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2364 resp := &alloydbpb.Cluster{}
2365 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2366 if settings.Path != "" {
2367 baseUrl.Path = settings.Path
2368 }
2369 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2370 if err != nil {
2371 return err
2372 }
2373 httpReq = httpReq.WithContext(ctx)
2374 httpReq.Header = headers
2375
2376 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCluster")
2377 if err != nil {
2378 return err
2379 }
2380
2381 if err := unm.Unmarshal(buf, resp); err != nil {
2382 return err
2383 }
2384
2385 return nil
2386 }, opts...)
2387 if e != nil {
2388 return nil, e
2389 }
2390 return resp, nil
2391 }
2392
2393 // CreateCluster creates a new Cluster in a given project and location.
2394 func (c *alloyDBAdminRESTClient) CreateCluster(ctx context.Context, req *alloydbpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
2395 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2396 body := req.GetCluster()
2397 jsonReq, err := m.Marshal(body)
2398 if err != nil {
2399 return nil, err
2400 }
2401
2402 baseUrl, err := url.Parse(c.endpoint)
2403 if err != nil {
2404 return nil, err
2405 }
2406 baseUrl.Path += fmt.Sprintf("/v1beta/%v/clusters", req.GetParent())
2407
2408 params := url.Values{}
2409 params.Add("$alt", "json;enum-encoding=int")
2410 params.Add("clusterId", fmt.Sprintf("%v", req.GetClusterId()))
2411 if req.GetRequestId() != "" {
2412 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2413 }
2414 if req.GetValidateOnly() {
2415 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
2416 }
2417
2418 baseUrl.RawQuery = params.Encode()
2419
2420 // Build HTTP headers from client and context metadata.
2421 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2422
2423 hds = append(c.xGoogHeaders, hds...)
2424 hds = append(hds, "Content-Type", "application/json")
2425 headers := gax.BuildHeaders(ctx, hds...)
2426 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2427 resp := &longrunningpb.Operation{}
2428 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2429 if settings.Path != "" {
2430 baseUrl.Path = settings.Path
2431 }
2432 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2433 if err != nil {
2434 return err
2435 }
2436 httpReq = httpReq.WithContext(ctx)
2437 httpReq.Header = headers
2438
2439 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCluster")
2440 if err != nil {
2441 return err
2442 }
2443 if err := unm.Unmarshal(buf, resp); err != nil {
2444 return err
2445 }
2446
2447 return nil
2448 }, opts...)
2449 if e != nil {
2450 return nil, e
2451 }
2452
2453 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2454 return &CreateClusterOperation{
2455 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2456 pollPath: override,
2457 }, nil
2458 }
2459
2460 // UpdateCluster updates the parameters of a single Cluster.
2461 func (c *alloyDBAdminRESTClient) UpdateCluster(ctx context.Context, req *alloydbpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
2462 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2463 body := req.GetCluster()
2464 jsonReq, err := m.Marshal(body)
2465 if err != nil {
2466 return nil, err
2467 }
2468
2469 baseUrl, err := url.Parse(c.endpoint)
2470 if err != nil {
2471 return nil, err
2472 }
2473 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetCluster().GetName())
2474
2475 params := url.Values{}
2476 params.Add("$alt", "json;enum-encoding=int")
2477 if req.GetAllowMissing() {
2478 params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
2479 }
2480 if req.GetRequestId() != "" {
2481 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2482 }
2483 if req.GetUpdateMask() != nil {
2484 field, err := protojson.Marshal(req.GetUpdateMask())
2485 if err != nil {
2486 return nil, err
2487 }
2488 params.Add("updateMask", string(field[1:len(field)-1]))
2489 }
2490 if req.GetValidateOnly() {
2491 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
2492 }
2493
2494 baseUrl.RawQuery = params.Encode()
2495
2496 // Build HTTP headers from client and context metadata.
2497 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName()))}
2498
2499 hds = append(c.xGoogHeaders, hds...)
2500 hds = append(hds, "Content-Type", "application/json")
2501 headers := gax.BuildHeaders(ctx, hds...)
2502 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2503 resp := &longrunningpb.Operation{}
2504 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2505 if settings.Path != "" {
2506 baseUrl.Path = settings.Path
2507 }
2508 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2509 if err != nil {
2510 return err
2511 }
2512 httpReq = httpReq.WithContext(ctx)
2513 httpReq.Header = headers
2514
2515 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateCluster")
2516 if err != nil {
2517 return err
2518 }
2519 if err := unm.Unmarshal(buf, resp); err != nil {
2520 return err
2521 }
2522
2523 return nil
2524 }, opts...)
2525 if e != nil {
2526 return nil, e
2527 }
2528
2529 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2530 return &UpdateClusterOperation{
2531 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2532 pollPath: override,
2533 }, nil
2534 }
2535
2536 // ExportCluster exports data from the cluster.
2537 // Imperative only.
2538 func (c *alloyDBAdminRESTClient) ExportCluster(ctx context.Context, req *alloydbpb.ExportClusterRequest, opts ...gax.CallOption) (*ExportClusterOperation, error) {
2539 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2540 jsonReq, err := m.Marshal(req)
2541 if err != nil {
2542 return nil, err
2543 }
2544
2545 baseUrl, err := url.Parse(c.endpoint)
2546 if err != nil {
2547 return nil, err
2548 }
2549 baseUrl.Path += fmt.Sprintf("/v1beta/%v:export", req.GetName())
2550
2551 params := url.Values{}
2552 params.Add("$alt", "json;enum-encoding=int")
2553
2554 baseUrl.RawQuery = params.Encode()
2555
2556 // Build HTTP headers from client and context metadata.
2557 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2558
2559 hds = append(c.xGoogHeaders, hds...)
2560 hds = append(hds, "Content-Type", "application/json")
2561 headers := gax.BuildHeaders(ctx, hds...)
2562 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2563 resp := &longrunningpb.Operation{}
2564 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2565 if settings.Path != "" {
2566 baseUrl.Path = settings.Path
2567 }
2568 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2569 if err != nil {
2570 return err
2571 }
2572 httpReq = httpReq.WithContext(ctx)
2573 httpReq.Header = headers
2574
2575 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportCluster")
2576 if err != nil {
2577 return err
2578 }
2579 if err := unm.Unmarshal(buf, resp); err != nil {
2580 return err
2581 }
2582
2583 return nil
2584 }, opts...)
2585 if e != nil {
2586 return nil, e
2587 }
2588
2589 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2590 return &ExportClusterOperation{
2591 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2592 pollPath: override,
2593 }, nil
2594 }
2595
2596 // ImportCluster imports data to the cluster.
2597 // Imperative only.
2598 func (c *alloyDBAdminRESTClient) ImportCluster(ctx context.Context, req *alloydbpb.ImportClusterRequest, opts ...gax.CallOption) (*ImportClusterOperation, error) {
2599 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2600 jsonReq, err := m.Marshal(req)
2601 if err != nil {
2602 return nil, err
2603 }
2604
2605 baseUrl, err := url.Parse(c.endpoint)
2606 if err != nil {
2607 return nil, err
2608 }
2609 baseUrl.Path += fmt.Sprintf("/v1beta/%v:import", req.GetName())
2610
2611 params := url.Values{}
2612 params.Add("$alt", "json;enum-encoding=int")
2613
2614 baseUrl.RawQuery = params.Encode()
2615
2616 // Build HTTP headers from client and context metadata.
2617 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2618
2619 hds = append(c.xGoogHeaders, hds...)
2620 hds = append(hds, "Content-Type", "application/json")
2621 headers := gax.BuildHeaders(ctx, hds...)
2622 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2623 resp := &longrunningpb.Operation{}
2624 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2625 if settings.Path != "" {
2626 baseUrl.Path = settings.Path
2627 }
2628 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2629 if err != nil {
2630 return err
2631 }
2632 httpReq = httpReq.WithContext(ctx)
2633 httpReq.Header = headers
2634
2635 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportCluster")
2636 if err != nil {
2637 return err
2638 }
2639 if err := unm.Unmarshal(buf, resp); err != nil {
2640 return err
2641 }
2642
2643 return nil
2644 }, opts...)
2645 if e != nil {
2646 return nil, e
2647 }
2648
2649 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2650 return &ImportClusterOperation{
2651 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2652 pollPath: override,
2653 }, nil
2654 }
2655
2656 // UpgradeCluster upgrades a single Cluster.
2657 // Imperative only.
2658 func (c *alloyDBAdminRESTClient) UpgradeCluster(ctx context.Context, req *alloydbpb.UpgradeClusterRequest, opts ...gax.CallOption) (*UpgradeClusterOperation, error) {
2659 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2660 jsonReq, err := m.Marshal(req)
2661 if err != nil {
2662 return nil, err
2663 }
2664
2665 baseUrl, err := url.Parse(c.endpoint)
2666 if err != nil {
2667 return nil, err
2668 }
2669 baseUrl.Path += fmt.Sprintf("/v1beta/%v:upgrade", req.GetName())
2670
2671 params := url.Values{}
2672 params.Add("$alt", "json;enum-encoding=int")
2673
2674 baseUrl.RawQuery = params.Encode()
2675
2676 // Build HTTP headers from client and context metadata.
2677 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2678
2679 hds = append(c.xGoogHeaders, hds...)
2680 hds = append(hds, "Content-Type", "application/json")
2681 headers := gax.BuildHeaders(ctx, hds...)
2682 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2683 resp := &longrunningpb.Operation{}
2684 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2685 if settings.Path != "" {
2686 baseUrl.Path = settings.Path
2687 }
2688 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2689 if err != nil {
2690 return err
2691 }
2692 httpReq = httpReq.WithContext(ctx)
2693 httpReq.Header = headers
2694
2695 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpgradeCluster")
2696 if err != nil {
2697 return err
2698 }
2699 if err := unm.Unmarshal(buf, resp); err != nil {
2700 return err
2701 }
2702
2703 return nil
2704 }, opts...)
2705 if e != nil {
2706 return nil, e
2707 }
2708
2709 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2710 return &UpgradeClusterOperation{
2711 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2712 pollPath: override,
2713 }, nil
2714 }
2715
2716 // DeleteCluster deletes a single Cluster.
2717 func (c *alloyDBAdminRESTClient) DeleteCluster(ctx context.Context, req *alloydbpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
2718 baseUrl, err := url.Parse(c.endpoint)
2719 if err != nil {
2720 return nil, err
2721 }
2722 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2723
2724 params := url.Values{}
2725 params.Add("$alt", "json;enum-encoding=int")
2726 if req.GetEtag() != "" {
2727 params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
2728 }
2729 if req.GetForce() {
2730 params.Add("force", fmt.Sprintf("%v", req.GetForce()))
2731 }
2732 if req.GetRequestId() != "" {
2733 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2734 }
2735 if req.GetValidateOnly() {
2736 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
2737 }
2738
2739 baseUrl.RawQuery = params.Encode()
2740
2741 // Build HTTP headers from client and context metadata.
2742 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2743
2744 hds = append(c.xGoogHeaders, hds...)
2745 hds = append(hds, "Content-Type", "application/json")
2746 headers := gax.BuildHeaders(ctx, hds...)
2747 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2748 resp := &longrunningpb.Operation{}
2749 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2750 if settings.Path != "" {
2751 baseUrl.Path = settings.Path
2752 }
2753 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2754 if err != nil {
2755 return err
2756 }
2757 httpReq = httpReq.WithContext(ctx)
2758 httpReq.Header = headers
2759
2760 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCluster")
2761 if err != nil {
2762 return err
2763 }
2764 if err := unm.Unmarshal(buf, resp); err != nil {
2765 return err
2766 }
2767
2768 return nil
2769 }, opts...)
2770 if e != nil {
2771 return nil, e
2772 }
2773
2774 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2775 return &DeleteClusterOperation{
2776 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2777 pollPath: override,
2778 }, nil
2779 }
2780
2781 // PromoteCluster promotes a SECONDARY cluster. This turns down replication
2782 // from the PRIMARY cluster and promotes a secondary cluster
2783 // into its own standalone cluster.
2784 // Imperative only.
2785 func (c *alloyDBAdminRESTClient) PromoteCluster(ctx context.Context, req *alloydbpb.PromoteClusterRequest, opts ...gax.CallOption) (*PromoteClusterOperation, error) {
2786 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2787 jsonReq, err := m.Marshal(req)
2788 if err != nil {
2789 return nil, err
2790 }
2791
2792 baseUrl, err := url.Parse(c.endpoint)
2793 if err != nil {
2794 return nil, err
2795 }
2796 baseUrl.Path += fmt.Sprintf("/v1beta/%v:promote", req.GetName())
2797
2798 params := url.Values{}
2799 params.Add("$alt", "json;enum-encoding=int")
2800
2801 baseUrl.RawQuery = params.Encode()
2802
2803 // Build HTTP headers from client and context metadata.
2804 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2805
2806 hds = append(c.xGoogHeaders, hds...)
2807 hds = append(hds, "Content-Type", "application/json")
2808 headers := gax.BuildHeaders(ctx, hds...)
2809 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2810 resp := &longrunningpb.Operation{}
2811 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2812 if settings.Path != "" {
2813 baseUrl.Path = settings.Path
2814 }
2815 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2816 if err != nil {
2817 return err
2818 }
2819 httpReq = httpReq.WithContext(ctx)
2820 httpReq.Header = headers
2821
2822 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PromoteCluster")
2823 if err != nil {
2824 return err
2825 }
2826 if err := unm.Unmarshal(buf, resp); err != nil {
2827 return err
2828 }
2829
2830 return nil
2831 }, opts...)
2832 if e != nil {
2833 return nil, e
2834 }
2835
2836 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2837 return &PromoteClusterOperation{
2838 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2839 pollPath: override,
2840 }, nil
2841 }
2842
2843 // SwitchoverCluster switches the roles of PRIMARY and SECONDARY clusters without any data loss.
2844 // This promotes the SECONDARY cluster to PRIMARY and sets up the original
2845 // PRIMARY cluster to replicate from this newly promoted cluster.
2846 func (c *alloyDBAdminRESTClient) SwitchoverCluster(ctx context.Context, req *alloydbpb.SwitchoverClusterRequest, opts ...gax.CallOption) (*SwitchoverClusterOperation, error) {
2847 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2848 jsonReq, err := m.Marshal(req)
2849 if err != nil {
2850 return nil, err
2851 }
2852
2853 baseUrl, err := url.Parse(c.endpoint)
2854 if err != nil {
2855 return nil, err
2856 }
2857 baseUrl.Path += fmt.Sprintf("/v1beta/%v:switchover", req.GetName())
2858
2859 params := url.Values{}
2860 params.Add("$alt", "json;enum-encoding=int")
2861
2862 baseUrl.RawQuery = params.Encode()
2863
2864 // Build HTTP headers from client and context metadata.
2865 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2866
2867 hds = append(c.xGoogHeaders, hds...)
2868 hds = append(hds, "Content-Type", "application/json")
2869 headers := gax.BuildHeaders(ctx, hds...)
2870 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2871 resp := &longrunningpb.Operation{}
2872 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2873 if settings.Path != "" {
2874 baseUrl.Path = settings.Path
2875 }
2876 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2877 if err != nil {
2878 return err
2879 }
2880 httpReq = httpReq.WithContext(ctx)
2881 httpReq.Header = headers
2882
2883 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SwitchoverCluster")
2884 if err != nil {
2885 return err
2886 }
2887 if err := unm.Unmarshal(buf, resp); err != nil {
2888 return err
2889 }
2890
2891 return nil
2892 }, opts...)
2893 if e != nil {
2894 return nil, e
2895 }
2896
2897 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2898 return &SwitchoverClusterOperation{
2899 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2900 pollPath: override,
2901 }, nil
2902 }
2903
2904 // RestoreCluster creates a new Cluster in a given project and location, with a volume
2905 // restored from the provided source, either a backup ID or a point-in-time
2906 // and a source cluster.
2907 func (c *alloyDBAdminRESTClient) RestoreCluster(ctx context.Context, req *alloydbpb.RestoreClusterRequest, opts ...gax.CallOption) (*RestoreClusterOperation, error) {
2908 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2909 jsonReq, err := m.Marshal(req)
2910 if err != nil {
2911 return nil, err
2912 }
2913
2914 baseUrl, err := url.Parse(c.endpoint)
2915 if err != nil {
2916 return nil, err
2917 }
2918 baseUrl.Path += fmt.Sprintf("/v1beta/%v/clusters:restore", req.GetParent())
2919
2920 params := url.Values{}
2921 params.Add("$alt", "json;enum-encoding=int")
2922
2923 baseUrl.RawQuery = params.Encode()
2924
2925 // Build HTTP headers from client and context metadata.
2926 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2927
2928 hds = append(c.xGoogHeaders, hds...)
2929 hds = append(hds, "Content-Type", "application/json")
2930 headers := gax.BuildHeaders(ctx, hds...)
2931 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2932 resp := &longrunningpb.Operation{}
2933 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2934 if settings.Path != "" {
2935 baseUrl.Path = settings.Path
2936 }
2937 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2938 if err != nil {
2939 return err
2940 }
2941 httpReq = httpReq.WithContext(ctx)
2942 httpReq.Header = headers
2943
2944 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RestoreCluster")
2945 if err != nil {
2946 return err
2947 }
2948 if err := unm.Unmarshal(buf, resp); err != nil {
2949 return err
2950 }
2951
2952 return nil
2953 }, opts...)
2954 if e != nil {
2955 return nil, e
2956 }
2957
2958 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2959 return &RestoreClusterOperation{
2960 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2961 pollPath: override,
2962 }, nil
2963 }
2964
2965 // CreateSecondaryCluster creates a cluster of type SECONDARY in the given location using
2966 // the primary cluster as the source.
2967 func (c *alloyDBAdminRESTClient) CreateSecondaryCluster(ctx context.Context, req *alloydbpb.CreateSecondaryClusterRequest, opts ...gax.CallOption) (*CreateSecondaryClusterOperation, error) {
2968 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2969 body := req.GetCluster()
2970 jsonReq, err := m.Marshal(body)
2971 if err != nil {
2972 return nil, err
2973 }
2974
2975 baseUrl, err := url.Parse(c.endpoint)
2976 if err != nil {
2977 return nil, err
2978 }
2979 baseUrl.Path += fmt.Sprintf("/v1beta/%v/clusters:createsecondary", req.GetParent())
2980
2981 params := url.Values{}
2982 params.Add("$alt", "json;enum-encoding=int")
2983 params.Add("clusterId", fmt.Sprintf("%v", req.GetClusterId()))
2984 if req.GetRequestId() != "" {
2985 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2986 }
2987 if req.GetValidateOnly() {
2988 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
2989 }
2990
2991 baseUrl.RawQuery = params.Encode()
2992
2993 // Build HTTP headers from client and context metadata.
2994 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2995
2996 hds = append(c.xGoogHeaders, hds...)
2997 hds = append(hds, "Content-Type", "application/json")
2998 headers := gax.BuildHeaders(ctx, hds...)
2999 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3000 resp := &longrunningpb.Operation{}
3001 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3002 if settings.Path != "" {
3003 baseUrl.Path = settings.Path
3004 }
3005 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3006 if err != nil {
3007 return err
3008 }
3009 httpReq = httpReq.WithContext(ctx)
3010 httpReq.Header = headers
3011
3012 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSecondaryCluster")
3013 if err != nil {
3014 return err
3015 }
3016 if err := unm.Unmarshal(buf, resp); err != nil {
3017 return err
3018 }
3019
3020 return nil
3021 }, opts...)
3022 if e != nil {
3023 return nil, e
3024 }
3025
3026 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3027 return &CreateSecondaryClusterOperation{
3028 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3029 pollPath: override,
3030 }, nil
3031 }
3032
3033 // ListInstances lists Instances in a given project and location.
3034 func (c *alloyDBAdminRESTClient) ListInstances(ctx context.Context, req *alloydbpb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator {
3035 it := &InstanceIterator{}
3036 req = proto.Clone(req).(*alloydbpb.ListInstancesRequest)
3037 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3038 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Instance, string, error) {
3039 resp := &alloydbpb.ListInstancesResponse{}
3040 if pageToken != "" {
3041 req.PageToken = pageToken
3042 }
3043 if pageSize > math.MaxInt32 {
3044 req.PageSize = math.MaxInt32
3045 } else if pageSize != 0 {
3046 req.PageSize = int32(pageSize)
3047 }
3048 baseUrl, err := url.Parse(c.endpoint)
3049 if err != nil {
3050 return nil, "", err
3051 }
3052 baseUrl.Path += fmt.Sprintf("/v1beta/%v/instances", req.GetParent())
3053
3054 params := url.Values{}
3055 params.Add("$alt", "json;enum-encoding=int")
3056 if req.GetFilter() != "" {
3057 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3058 }
3059 if req.GetOrderBy() != "" {
3060 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3061 }
3062 if req.GetPageSize() != 0 {
3063 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3064 }
3065 if req.GetPageToken() != "" {
3066 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3067 }
3068
3069 baseUrl.RawQuery = params.Encode()
3070
3071 // Build HTTP headers from client and context metadata.
3072 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3073 headers := gax.BuildHeaders(ctx, hds...)
3074 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3075 if settings.Path != "" {
3076 baseUrl.Path = settings.Path
3077 }
3078 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3079 if err != nil {
3080 return err
3081 }
3082 httpReq.Header = headers
3083
3084 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListInstances")
3085 if err != nil {
3086 return err
3087 }
3088 if err := unm.Unmarshal(buf, resp); err != nil {
3089 return err
3090 }
3091
3092 return nil
3093 }, opts...)
3094 if e != nil {
3095 return nil, "", e
3096 }
3097 it.Response = resp
3098 return resp.GetInstances(), resp.GetNextPageToken(), nil
3099 }
3100
3101 fetch := func(pageSize int, pageToken string) (string, error) {
3102 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3103 if err != nil {
3104 return "", err
3105 }
3106 it.items = append(it.items, items...)
3107 return nextPageToken, nil
3108 }
3109
3110 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3111 it.pageInfo.MaxSize = int(req.GetPageSize())
3112 it.pageInfo.Token = req.GetPageToken()
3113
3114 return it
3115 }
3116
3117 // GetInstance gets details of a single Instance.
3118 func (c *alloyDBAdminRESTClient) GetInstance(ctx context.Context, req *alloydbpb.GetInstanceRequest, opts ...gax.CallOption) (*alloydbpb.Instance, error) {
3119 baseUrl, err := url.Parse(c.endpoint)
3120 if err != nil {
3121 return nil, err
3122 }
3123 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
3124
3125 params := url.Values{}
3126 params.Add("$alt", "json;enum-encoding=int")
3127 if req.GetView() != 0 {
3128 params.Add("view", fmt.Sprintf("%v", req.GetView()))
3129 }
3130
3131 baseUrl.RawQuery = params.Encode()
3132
3133 // Build HTTP headers from client and context metadata.
3134 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3135
3136 hds = append(c.xGoogHeaders, hds...)
3137 hds = append(hds, "Content-Type", "application/json")
3138 headers := gax.BuildHeaders(ctx, hds...)
3139 opts = append((*c.CallOptions).GetInstance[0:len((*c.CallOptions).GetInstance):len((*c.CallOptions).GetInstance)], opts...)
3140 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3141 resp := &alloydbpb.Instance{}
3142 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3143 if settings.Path != "" {
3144 baseUrl.Path = settings.Path
3145 }
3146 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3147 if err != nil {
3148 return err
3149 }
3150 httpReq = httpReq.WithContext(ctx)
3151 httpReq.Header = headers
3152
3153 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetInstance")
3154 if err != nil {
3155 return err
3156 }
3157
3158 if err := unm.Unmarshal(buf, resp); err != nil {
3159 return err
3160 }
3161
3162 return nil
3163 }, opts...)
3164 if e != nil {
3165 return nil, e
3166 }
3167 return resp, nil
3168 }
3169
3170 // CreateInstance creates a new Instance in a given project and location.
3171 func (c *alloyDBAdminRESTClient) CreateInstance(ctx context.Context, req *alloydbpb.CreateInstanceRequest, opts ...gax.CallOption) (*CreateInstanceOperation, error) {
3172 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3173 body := req.GetInstance()
3174 jsonReq, err := m.Marshal(body)
3175 if err != nil {
3176 return nil, err
3177 }
3178
3179 baseUrl, err := url.Parse(c.endpoint)
3180 if err != nil {
3181 return nil, err
3182 }
3183 baseUrl.Path += fmt.Sprintf("/v1beta/%v/instances", req.GetParent())
3184
3185 params := url.Values{}
3186 params.Add("$alt", "json;enum-encoding=int")
3187 params.Add("instanceId", fmt.Sprintf("%v", req.GetInstanceId()))
3188 if req.GetRequestId() != "" {
3189 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3190 }
3191 if req.GetValidateOnly() {
3192 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3193 }
3194
3195 baseUrl.RawQuery = params.Encode()
3196
3197 // Build HTTP headers from client and context metadata.
3198 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3199
3200 hds = append(c.xGoogHeaders, hds...)
3201 hds = append(hds, "Content-Type", "application/json")
3202 headers := gax.BuildHeaders(ctx, hds...)
3203 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3204 resp := &longrunningpb.Operation{}
3205 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3206 if settings.Path != "" {
3207 baseUrl.Path = settings.Path
3208 }
3209 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3210 if err != nil {
3211 return err
3212 }
3213 httpReq = httpReq.WithContext(ctx)
3214 httpReq.Header = headers
3215
3216 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateInstance")
3217 if err != nil {
3218 return err
3219 }
3220 if err := unm.Unmarshal(buf, resp); err != nil {
3221 return err
3222 }
3223
3224 return nil
3225 }, opts...)
3226 if e != nil {
3227 return nil, e
3228 }
3229
3230 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3231 return &CreateInstanceOperation{
3232 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3233 pollPath: override,
3234 }, nil
3235 }
3236
3237 // CreateSecondaryInstance creates a new SECONDARY Instance in a given project and location.
3238 func (c *alloyDBAdminRESTClient) CreateSecondaryInstance(ctx context.Context, req *alloydbpb.CreateSecondaryInstanceRequest, opts ...gax.CallOption) (*CreateSecondaryInstanceOperation, error) {
3239 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3240 body := req.GetInstance()
3241 jsonReq, err := m.Marshal(body)
3242 if err != nil {
3243 return nil, err
3244 }
3245
3246 baseUrl, err := url.Parse(c.endpoint)
3247 if err != nil {
3248 return nil, err
3249 }
3250 baseUrl.Path += fmt.Sprintf("/v1beta/%v/instances:createsecondary", req.GetParent())
3251
3252 params := url.Values{}
3253 params.Add("$alt", "json;enum-encoding=int")
3254 params.Add("instanceId", fmt.Sprintf("%v", req.GetInstanceId()))
3255 if req.GetRequestId() != "" {
3256 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3257 }
3258 if req.GetValidateOnly() {
3259 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3260 }
3261
3262 baseUrl.RawQuery = params.Encode()
3263
3264 // Build HTTP headers from client and context metadata.
3265 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3266
3267 hds = append(c.xGoogHeaders, hds...)
3268 hds = append(hds, "Content-Type", "application/json")
3269 headers := gax.BuildHeaders(ctx, hds...)
3270 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3271 resp := &longrunningpb.Operation{}
3272 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3273 if settings.Path != "" {
3274 baseUrl.Path = settings.Path
3275 }
3276 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3277 if err != nil {
3278 return err
3279 }
3280 httpReq = httpReq.WithContext(ctx)
3281 httpReq.Header = headers
3282
3283 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSecondaryInstance")
3284 if err != nil {
3285 return err
3286 }
3287 if err := unm.Unmarshal(buf, resp); err != nil {
3288 return err
3289 }
3290
3291 return nil
3292 }, opts...)
3293 if e != nil {
3294 return nil, e
3295 }
3296
3297 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3298 return &CreateSecondaryInstanceOperation{
3299 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3300 pollPath: override,
3301 }, nil
3302 }
3303
3304 // BatchCreateInstances creates new instances under the given project, location and cluster.
3305 // There can be only one primary instance in a cluster. If the primary
3306 // instance exists in the cluster as well as this request, then API will
3307 // throw an error.
3308 // The primary instance should exist before any read pool instance is
3309 // created. If the primary instance is a part of the request payload, then
3310 // the API will take care of creating instances in the correct order.
3311 // This method is here to support Google-internal use cases, and is not meant
3312 // for external customers to consume. Please do not start relying on it; its
3313 // behavior is subject to change without notice.
3314 func (c *alloyDBAdminRESTClient) BatchCreateInstances(ctx context.Context, req *alloydbpb.BatchCreateInstancesRequest, opts ...gax.CallOption) (*BatchCreateInstancesOperation, error) {
3315 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3316 body := req.GetRequests()
3317 jsonReq, err := m.Marshal(body)
3318 if err != nil {
3319 return nil, err
3320 }
3321
3322 baseUrl, err := url.Parse(c.endpoint)
3323 if err != nil {
3324 return nil, err
3325 }
3326 baseUrl.Path += fmt.Sprintf("/v1beta/%v/instances:batchCreate", req.GetParent())
3327
3328 params := url.Values{}
3329 params.Add("$alt", "json;enum-encoding=int")
3330 if req.GetRequestId() != "" {
3331 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3332 }
3333
3334 baseUrl.RawQuery = params.Encode()
3335
3336 // Build HTTP headers from client and context metadata.
3337 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3338
3339 hds = append(c.xGoogHeaders, hds...)
3340 hds = append(hds, "Content-Type", "application/json")
3341 headers := gax.BuildHeaders(ctx, hds...)
3342 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3343 resp := &longrunningpb.Operation{}
3344 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3345 if settings.Path != "" {
3346 baseUrl.Path = settings.Path
3347 }
3348 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3349 if err != nil {
3350 return err
3351 }
3352 httpReq = httpReq.WithContext(ctx)
3353 httpReq.Header = headers
3354
3355 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchCreateInstances")
3356 if err != nil {
3357 return err
3358 }
3359 if err := unm.Unmarshal(buf, resp); err != nil {
3360 return err
3361 }
3362
3363 return nil
3364 }, opts...)
3365 if e != nil {
3366 return nil, e
3367 }
3368
3369 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3370 return &BatchCreateInstancesOperation{
3371 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3372 pollPath: override,
3373 }, nil
3374 }
3375
3376 // UpdateInstance updates the parameters of a single Instance.
3377 func (c *alloyDBAdminRESTClient) UpdateInstance(ctx context.Context, req *alloydbpb.UpdateInstanceRequest, opts ...gax.CallOption) (*UpdateInstanceOperation, error) {
3378 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3379 body := req.GetInstance()
3380 jsonReq, err := m.Marshal(body)
3381 if err != nil {
3382 return nil, err
3383 }
3384
3385 baseUrl, err := url.Parse(c.endpoint)
3386 if err != nil {
3387 return nil, err
3388 }
3389 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetInstance().GetName())
3390
3391 params := url.Values{}
3392 params.Add("$alt", "json;enum-encoding=int")
3393 if req.GetAllowMissing() {
3394 params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
3395 }
3396 if req.GetRequestId() != "" {
3397 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3398 }
3399 if req.GetUpdateMask() != nil {
3400 field, err := protojson.Marshal(req.GetUpdateMask())
3401 if err != nil {
3402 return nil, err
3403 }
3404 params.Add("updateMask", string(field[1:len(field)-1]))
3405 }
3406 if req.GetValidateOnly() {
3407 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3408 }
3409
3410 baseUrl.RawQuery = params.Encode()
3411
3412 // Build HTTP headers from client and context metadata.
3413 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "instance.name", url.QueryEscape(req.GetInstance().GetName()))}
3414
3415 hds = append(c.xGoogHeaders, hds...)
3416 hds = append(hds, "Content-Type", "application/json")
3417 headers := gax.BuildHeaders(ctx, hds...)
3418 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3419 resp := &longrunningpb.Operation{}
3420 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3421 if settings.Path != "" {
3422 baseUrl.Path = settings.Path
3423 }
3424 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
3425 if err != nil {
3426 return err
3427 }
3428 httpReq = httpReq.WithContext(ctx)
3429 httpReq.Header = headers
3430
3431 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateInstance")
3432 if err != nil {
3433 return err
3434 }
3435 if err := unm.Unmarshal(buf, resp); err != nil {
3436 return err
3437 }
3438
3439 return nil
3440 }, opts...)
3441 if e != nil {
3442 return nil, e
3443 }
3444
3445 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3446 return &UpdateInstanceOperation{
3447 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3448 pollPath: override,
3449 }, nil
3450 }
3451
3452 // DeleteInstance deletes a single Instance.
3453 func (c *alloyDBAdminRESTClient) DeleteInstance(ctx context.Context, req *alloydbpb.DeleteInstanceRequest, opts ...gax.CallOption) (*DeleteInstanceOperation, error) {
3454 baseUrl, err := url.Parse(c.endpoint)
3455 if err != nil {
3456 return nil, err
3457 }
3458 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
3459
3460 params := url.Values{}
3461 params.Add("$alt", "json;enum-encoding=int")
3462 if req.GetEtag() != "" {
3463 params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
3464 }
3465 if req.GetRequestId() != "" {
3466 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3467 }
3468 if req.GetValidateOnly() {
3469 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3470 }
3471
3472 baseUrl.RawQuery = params.Encode()
3473
3474 // Build HTTP headers from client and context metadata.
3475 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3476
3477 hds = append(c.xGoogHeaders, hds...)
3478 hds = append(hds, "Content-Type", "application/json")
3479 headers := gax.BuildHeaders(ctx, hds...)
3480 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3481 resp := &longrunningpb.Operation{}
3482 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3483 if settings.Path != "" {
3484 baseUrl.Path = settings.Path
3485 }
3486 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3487 if err != nil {
3488 return err
3489 }
3490 httpReq = httpReq.WithContext(ctx)
3491 httpReq.Header = headers
3492
3493 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteInstance")
3494 if err != nil {
3495 return err
3496 }
3497 if err := unm.Unmarshal(buf, resp); err != nil {
3498 return err
3499 }
3500
3501 return nil
3502 }, opts...)
3503 if e != nil {
3504 return nil, e
3505 }
3506
3507 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3508 return &DeleteInstanceOperation{
3509 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3510 pollPath: override,
3511 }, nil
3512 }
3513
3514 // FailoverInstance forces a Failover for a highly available instance.
3515 // Failover promotes the HA standby instance as the new primary.
3516 // Imperative only.
3517 func (c *alloyDBAdminRESTClient) FailoverInstance(ctx context.Context, req *alloydbpb.FailoverInstanceRequest, opts ...gax.CallOption) (*FailoverInstanceOperation, error) {
3518 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3519 jsonReq, err := m.Marshal(req)
3520 if err != nil {
3521 return nil, err
3522 }
3523
3524 baseUrl, err := url.Parse(c.endpoint)
3525 if err != nil {
3526 return nil, err
3527 }
3528 baseUrl.Path += fmt.Sprintf("/v1beta/%v:failover", req.GetName())
3529
3530 params := url.Values{}
3531 params.Add("$alt", "json;enum-encoding=int")
3532
3533 baseUrl.RawQuery = params.Encode()
3534
3535 // Build HTTP headers from client and context metadata.
3536 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3537
3538 hds = append(c.xGoogHeaders, hds...)
3539 hds = append(hds, "Content-Type", "application/json")
3540 headers := gax.BuildHeaders(ctx, hds...)
3541 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3542 resp := &longrunningpb.Operation{}
3543 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3544 if settings.Path != "" {
3545 baseUrl.Path = settings.Path
3546 }
3547 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3548 if err != nil {
3549 return err
3550 }
3551 httpReq = httpReq.WithContext(ctx)
3552 httpReq.Header = headers
3553
3554 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "FailoverInstance")
3555 if err != nil {
3556 return err
3557 }
3558 if err := unm.Unmarshal(buf, resp); err != nil {
3559 return err
3560 }
3561
3562 return nil
3563 }, opts...)
3564 if e != nil {
3565 return nil, e
3566 }
3567
3568 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3569 return &FailoverInstanceOperation{
3570 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3571 pollPath: override,
3572 }, nil
3573 }
3574
3575 // InjectFault injects fault in an instance.
3576 // Imperative only.
3577 func (c *alloyDBAdminRESTClient) InjectFault(ctx context.Context, req *alloydbpb.InjectFaultRequest, opts ...gax.CallOption) (*InjectFaultOperation, error) {
3578 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3579 jsonReq, err := m.Marshal(req)
3580 if err != nil {
3581 return nil, err
3582 }
3583
3584 baseUrl, err := url.Parse(c.endpoint)
3585 if err != nil {
3586 return nil, err
3587 }
3588 baseUrl.Path += fmt.Sprintf("/v1beta/%v:injectFault", req.GetName())
3589
3590 params := url.Values{}
3591 params.Add("$alt", "json;enum-encoding=int")
3592
3593 baseUrl.RawQuery = params.Encode()
3594
3595 // Build HTTP headers from client and context metadata.
3596 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3597
3598 hds = append(c.xGoogHeaders, hds...)
3599 hds = append(hds, "Content-Type", "application/json")
3600 headers := gax.BuildHeaders(ctx, hds...)
3601 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3602 resp := &longrunningpb.Operation{}
3603 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3604 if settings.Path != "" {
3605 baseUrl.Path = settings.Path
3606 }
3607 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3608 if err != nil {
3609 return err
3610 }
3611 httpReq = httpReq.WithContext(ctx)
3612 httpReq.Header = headers
3613
3614 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "InjectFault")
3615 if err != nil {
3616 return err
3617 }
3618 if err := unm.Unmarshal(buf, resp); err != nil {
3619 return err
3620 }
3621
3622 return nil
3623 }, opts...)
3624 if e != nil {
3625 return nil, e
3626 }
3627
3628 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3629 return &InjectFaultOperation{
3630 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3631 pollPath: override,
3632 }, nil
3633 }
3634
3635 // RestartInstance restart an Instance in a cluster.
3636 // Imperative only.
3637 func (c *alloyDBAdminRESTClient) RestartInstance(ctx context.Context, req *alloydbpb.RestartInstanceRequest, opts ...gax.CallOption) (*RestartInstanceOperation, error) {
3638 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3639 jsonReq, err := m.Marshal(req)
3640 if err != nil {
3641 return nil, err
3642 }
3643
3644 baseUrl, err := url.Parse(c.endpoint)
3645 if err != nil {
3646 return nil, err
3647 }
3648 baseUrl.Path += fmt.Sprintf("/v1beta/%v:restart", req.GetName())
3649
3650 params := url.Values{}
3651 params.Add("$alt", "json;enum-encoding=int")
3652
3653 baseUrl.RawQuery = params.Encode()
3654
3655 // Build HTTP headers from client and context metadata.
3656 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3657
3658 hds = append(c.xGoogHeaders, hds...)
3659 hds = append(hds, "Content-Type", "application/json")
3660 headers := gax.BuildHeaders(ctx, hds...)
3661 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3662 resp := &longrunningpb.Operation{}
3663 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3664 if settings.Path != "" {
3665 baseUrl.Path = settings.Path
3666 }
3667 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3668 if err != nil {
3669 return err
3670 }
3671 httpReq = httpReq.WithContext(ctx)
3672 httpReq.Header = headers
3673
3674 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RestartInstance")
3675 if err != nil {
3676 return err
3677 }
3678 if err := unm.Unmarshal(buf, resp); err != nil {
3679 return err
3680 }
3681
3682 return nil
3683 }, opts...)
3684 if e != nil {
3685 return nil, e
3686 }
3687
3688 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3689 return &RestartInstanceOperation{
3690 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3691 pollPath: override,
3692 }, nil
3693 }
3694
3695 // ExecuteSql executes a SQL statement in a database inside an AlloyDB instance.
3696 func (c *alloyDBAdminRESTClient) ExecuteSql(ctx context.Context, req *alloydbpb.ExecuteSqlRequest, opts ...gax.CallOption) (*alloydbpb.ExecuteSqlResponse, error) {
3697 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3698 jsonReq, err := m.Marshal(req)
3699 if err != nil {
3700 return nil, err
3701 }
3702
3703 baseUrl, err := url.Parse(c.endpoint)
3704 if err != nil {
3705 return nil, err
3706 }
3707 baseUrl.Path += fmt.Sprintf("/v1beta/%v:executeSql", req.GetInstance())
3708
3709 params := url.Values{}
3710 params.Add("$alt", "json;enum-encoding=int")
3711
3712 baseUrl.RawQuery = params.Encode()
3713
3714 // Build HTTP headers from client and context metadata.
3715 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "instance", url.QueryEscape(req.GetInstance()))}
3716
3717 hds = append(c.xGoogHeaders, hds...)
3718 hds = append(hds, "Content-Type", "application/json")
3719 headers := gax.BuildHeaders(ctx, hds...)
3720 opts = append((*c.CallOptions).ExecuteSql[0:len((*c.CallOptions).ExecuteSql):len((*c.CallOptions).ExecuteSql)], opts...)
3721 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3722 resp := &alloydbpb.ExecuteSqlResponse{}
3723 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3724 if settings.Path != "" {
3725 baseUrl.Path = settings.Path
3726 }
3727 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3728 if err != nil {
3729 return err
3730 }
3731 httpReq = httpReq.WithContext(ctx)
3732 httpReq.Header = headers
3733
3734 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExecuteSql")
3735 if err != nil {
3736 return err
3737 }
3738
3739 if err := unm.Unmarshal(buf, resp); err != nil {
3740 return err
3741 }
3742
3743 return nil
3744 }, opts...)
3745 if e != nil {
3746 return nil, e
3747 }
3748 return resp, nil
3749 }
3750
3751 // ListBackups lists Backups in a given project and location.
3752 func (c *alloyDBAdminRESTClient) ListBackups(ctx context.Context, req *alloydbpb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
3753 it := &BackupIterator{}
3754 req = proto.Clone(req).(*alloydbpb.ListBackupsRequest)
3755 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3756 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Backup, string, error) {
3757 resp := &alloydbpb.ListBackupsResponse{}
3758 if pageToken != "" {
3759 req.PageToken = pageToken
3760 }
3761 if pageSize > math.MaxInt32 {
3762 req.PageSize = math.MaxInt32
3763 } else if pageSize != 0 {
3764 req.PageSize = int32(pageSize)
3765 }
3766 baseUrl, err := url.Parse(c.endpoint)
3767 if err != nil {
3768 return nil, "", err
3769 }
3770 baseUrl.Path += fmt.Sprintf("/v1beta/%v/backups", req.GetParent())
3771
3772 params := url.Values{}
3773 params.Add("$alt", "json;enum-encoding=int")
3774 if req.GetFilter() != "" {
3775 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3776 }
3777 if req.GetOrderBy() != "" {
3778 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3779 }
3780 if req.GetPageSize() != 0 {
3781 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3782 }
3783 if req.GetPageToken() != "" {
3784 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3785 }
3786
3787 baseUrl.RawQuery = params.Encode()
3788
3789 // Build HTTP headers from client and context metadata.
3790 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3791 headers := gax.BuildHeaders(ctx, hds...)
3792 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3793 if settings.Path != "" {
3794 baseUrl.Path = settings.Path
3795 }
3796 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3797 if err != nil {
3798 return err
3799 }
3800 httpReq.Header = headers
3801
3802 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListBackups")
3803 if err != nil {
3804 return err
3805 }
3806 if err := unm.Unmarshal(buf, resp); err != nil {
3807 return err
3808 }
3809
3810 return nil
3811 }, opts...)
3812 if e != nil {
3813 return nil, "", e
3814 }
3815 it.Response = resp
3816 return resp.GetBackups(), resp.GetNextPageToken(), nil
3817 }
3818
3819 fetch := func(pageSize int, pageToken string) (string, error) {
3820 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3821 if err != nil {
3822 return "", err
3823 }
3824 it.items = append(it.items, items...)
3825 return nextPageToken, nil
3826 }
3827
3828 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3829 it.pageInfo.MaxSize = int(req.GetPageSize())
3830 it.pageInfo.Token = req.GetPageToken()
3831
3832 return it
3833 }
3834
3835 // GetBackup gets details of a single Backup.
3836 func (c *alloyDBAdminRESTClient) GetBackup(ctx context.Context, req *alloydbpb.GetBackupRequest, opts ...gax.CallOption) (*alloydbpb.Backup, error) {
3837 baseUrl, err := url.Parse(c.endpoint)
3838 if err != nil {
3839 return nil, err
3840 }
3841 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
3842
3843 params := url.Values{}
3844 params.Add("$alt", "json;enum-encoding=int")
3845
3846 baseUrl.RawQuery = params.Encode()
3847
3848 // Build HTTP headers from client and context metadata.
3849 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3850
3851 hds = append(c.xGoogHeaders, hds...)
3852 hds = append(hds, "Content-Type", "application/json")
3853 headers := gax.BuildHeaders(ctx, hds...)
3854 opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
3855 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3856 resp := &alloydbpb.Backup{}
3857 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3858 if settings.Path != "" {
3859 baseUrl.Path = settings.Path
3860 }
3861 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3862 if err != nil {
3863 return err
3864 }
3865 httpReq = httpReq.WithContext(ctx)
3866 httpReq.Header = headers
3867
3868 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetBackup")
3869 if err != nil {
3870 return err
3871 }
3872
3873 if err := unm.Unmarshal(buf, resp); err != nil {
3874 return err
3875 }
3876
3877 return nil
3878 }, opts...)
3879 if e != nil {
3880 return nil, e
3881 }
3882 return resp, nil
3883 }
3884
3885 // CreateBackup creates a new Backup in a given project and location.
3886 func (c *alloyDBAdminRESTClient) CreateBackup(ctx context.Context, req *alloydbpb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
3887 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3888 body := req.GetBackup()
3889 jsonReq, err := m.Marshal(body)
3890 if err != nil {
3891 return nil, err
3892 }
3893
3894 baseUrl, err := url.Parse(c.endpoint)
3895 if err != nil {
3896 return nil, err
3897 }
3898 baseUrl.Path += fmt.Sprintf("/v1beta/%v/backups", req.GetParent())
3899
3900 params := url.Values{}
3901 params.Add("$alt", "json;enum-encoding=int")
3902 params.Add("backupId", fmt.Sprintf("%v", req.GetBackupId()))
3903 if req.GetRequestId() != "" {
3904 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3905 }
3906 if req.GetValidateOnly() {
3907 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3908 }
3909
3910 baseUrl.RawQuery = params.Encode()
3911
3912 // Build HTTP headers from client and context metadata.
3913 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3914
3915 hds = append(c.xGoogHeaders, hds...)
3916 hds = append(hds, "Content-Type", "application/json")
3917 headers := gax.BuildHeaders(ctx, hds...)
3918 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3919 resp := &longrunningpb.Operation{}
3920 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3921 if settings.Path != "" {
3922 baseUrl.Path = settings.Path
3923 }
3924 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3925 if err != nil {
3926 return err
3927 }
3928 httpReq = httpReq.WithContext(ctx)
3929 httpReq.Header = headers
3930
3931 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateBackup")
3932 if err != nil {
3933 return err
3934 }
3935 if err := unm.Unmarshal(buf, resp); err != nil {
3936 return err
3937 }
3938
3939 return nil
3940 }, opts...)
3941 if e != nil {
3942 return nil, e
3943 }
3944
3945 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
3946 return &CreateBackupOperation{
3947 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3948 pollPath: override,
3949 }, nil
3950 }
3951
3952 // UpdateBackup updates the parameters of a single Backup.
3953 func (c *alloyDBAdminRESTClient) UpdateBackup(ctx context.Context, req *alloydbpb.UpdateBackupRequest, opts ...gax.CallOption) (*UpdateBackupOperation, error) {
3954 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3955 body := req.GetBackup()
3956 jsonReq, err := m.Marshal(body)
3957 if err != nil {
3958 return nil, err
3959 }
3960
3961 baseUrl, err := url.Parse(c.endpoint)
3962 if err != nil {
3963 return nil, err
3964 }
3965 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetBackup().GetName())
3966
3967 params := url.Values{}
3968 params.Add("$alt", "json;enum-encoding=int")
3969 if req.GetAllowMissing() {
3970 params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
3971 }
3972 if req.GetRequestId() != "" {
3973 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
3974 }
3975 if req.GetUpdateMask() != nil {
3976 field, err := protojson.Marshal(req.GetUpdateMask())
3977 if err != nil {
3978 return nil, err
3979 }
3980 params.Add("updateMask", string(field[1:len(field)-1]))
3981 }
3982 if req.GetValidateOnly() {
3983 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
3984 }
3985
3986 baseUrl.RawQuery = params.Encode()
3987
3988 // Build HTTP headers from client and context metadata.
3989 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "backup.name", url.QueryEscape(req.GetBackup().GetName()))}
3990
3991 hds = append(c.xGoogHeaders, hds...)
3992 hds = append(hds, "Content-Type", "application/json")
3993 headers := gax.BuildHeaders(ctx, hds...)
3994 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3995 resp := &longrunningpb.Operation{}
3996 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3997 if settings.Path != "" {
3998 baseUrl.Path = settings.Path
3999 }
4000 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4001 if err != nil {
4002 return err
4003 }
4004 httpReq = httpReq.WithContext(ctx)
4005 httpReq.Header = headers
4006
4007 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateBackup")
4008 if err != nil {
4009 return err
4010 }
4011 if err := unm.Unmarshal(buf, resp); err != nil {
4012 return err
4013 }
4014
4015 return nil
4016 }, opts...)
4017 if e != nil {
4018 return nil, e
4019 }
4020
4021 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
4022 return &UpdateBackupOperation{
4023 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4024 pollPath: override,
4025 }, nil
4026 }
4027
4028 // DeleteBackup deletes a single Backup.
4029 func (c *alloyDBAdminRESTClient) DeleteBackup(ctx context.Context, req *alloydbpb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
4030 baseUrl, err := url.Parse(c.endpoint)
4031 if err != nil {
4032 return nil, err
4033 }
4034 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4035
4036 params := url.Values{}
4037 params.Add("$alt", "json;enum-encoding=int")
4038 if req.GetEtag() != "" {
4039 params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
4040 }
4041 if req.GetRequestId() != "" {
4042 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
4043 }
4044 if req.GetValidateOnly() {
4045 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
4046 }
4047
4048 baseUrl.RawQuery = params.Encode()
4049
4050 // Build HTTP headers from client and context metadata.
4051 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4052
4053 hds = append(c.xGoogHeaders, hds...)
4054 hds = append(hds, "Content-Type", "application/json")
4055 headers := gax.BuildHeaders(ctx, hds...)
4056 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4057 resp := &longrunningpb.Operation{}
4058 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4059 if settings.Path != "" {
4060 baseUrl.Path = settings.Path
4061 }
4062 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4063 if err != nil {
4064 return err
4065 }
4066 httpReq = httpReq.WithContext(ctx)
4067 httpReq.Header = headers
4068
4069 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteBackup")
4070 if err != nil {
4071 return err
4072 }
4073 if err := unm.Unmarshal(buf, resp); err != nil {
4074 return err
4075 }
4076
4077 return nil
4078 }, opts...)
4079 if e != nil {
4080 return nil, e
4081 }
4082
4083 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
4084 return &DeleteBackupOperation{
4085 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4086 pollPath: override,
4087 }, nil
4088 }
4089
4090 // ListSupportedDatabaseFlags lists SupportedDatabaseFlags for a given project and location.
4091 func (c *alloyDBAdminRESTClient) ListSupportedDatabaseFlags(ctx context.Context, req *alloydbpb.ListSupportedDatabaseFlagsRequest, opts ...gax.CallOption) *SupportedDatabaseFlagIterator {
4092 it := &SupportedDatabaseFlagIterator{}
4093 req = proto.Clone(req).(*alloydbpb.ListSupportedDatabaseFlagsRequest)
4094 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4095 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.SupportedDatabaseFlag, string, error) {
4096 resp := &alloydbpb.ListSupportedDatabaseFlagsResponse{}
4097 if pageToken != "" {
4098 req.PageToken = pageToken
4099 }
4100 if pageSize > math.MaxInt32 {
4101 req.PageSize = math.MaxInt32
4102 } else if pageSize != 0 {
4103 req.PageSize = int32(pageSize)
4104 }
4105 baseUrl, err := url.Parse(c.endpoint)
4106 if err != nil {
4107 return nil, "", err
4108 }
4109 baseUrl.Path += fmt.Sprintf("/v1beta/%v/supportedDatabaseFlags", req.GetParent())
4110
4111 params := url.Values{}
4112 params.Add("$alt", "json;enum-encoding=int")
4113 if req.GetPageSize() != 0 {
4114 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4115 }
4116 if req.GetPageToken() != "" {
4117 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4118 }
4119 if req.GetScope() != 0 {
4120 params.Add("scope", fmt.Sprintf("%v", req.GetScope()))
4121 }
4122
4123 baseUrl.RawQuery = params.Encode()
4124
4125 // Build HTTP headers from client and context metadata.
4126 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4127 headers := gax.BuildHeaders(ctx, hds...)
4128 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4129 if settings.Path != "" {
4130 baseUrl.Path = settings.Path
4131 }
4132 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4133 if err != nil {
4134 return err
4135 }
4136 httpReq.Header = headers
4137
4138 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSupportedDatabaseFlags")
4139 if err != nil {
4140 return err
4141 }
4142 if err := unm.Unmarshal(buf, resp); err != nil {
4143 return err
4144 }
4145
4146 return nil
4147 }, opts...)
4148 if e != nil {
4149 return nil, "", e
4150 }
4151 it.Response = resp
4152 return resp.GetSupportedDatabaseFlags(), resp.GetNextPageToken(), nil
4153 }
4154
4155 fetch := func(pageSize int, pageToken string) (string, error) {
4156 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4157 if err != nil {
4158 return "", err
4159 }
4160 it.items = append(it.items, items...)
4161 return nextPageToken, nil
4162 }
4163
4164 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4165 it.pageInfo.MaxSize = int(req.GetPageSize())
4166 it.pageInfo.Token = req.GetPageToken()
4167
4168 return it
4169 }
4170
4171 // GenerateClientCertificate generate a client certificate signed by a Cluster CA.
4172 // The sole purpose of this endpoint is to support AlloyDB connectors and the
4173 // Auth Proxy client. The endpoint’s behavior is subject to change without
4174 // notice, so do not rely on its behavior remaining constant. Future changes
4175 // will not break AlloyDB connectors or the Auth Proxy client.
4176 func (c *alloyDBAdminRESTClient) GenerateClientCertificate(ctx context.Context, req *alloydbpb.GenerateClientCertificateRequest, opts ...gax.CallOption) (*alloydbpb.GenerateClientCertificateResponse, error) {
4177 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4178 jsonReq, err := m.Marshal(req)
4179 if err != nil {
4180 return nil, err
4181 }
4182
4183 baseUrl, err := url.Parse(c.endpoint)
4184 if err != nil {
4185 return nil, err
4186 }
4187 baseUrl.Path += fmt.Sprintf("/v1beta/%v:generateClientCertificate", req.GetParent())
4188
4189 params := url.Values{}
4190 params.Add("$alt", "json;enum-encoding=int")
4191
4192 baseUrl.RawQuery = params.Encode()
4193
4194 // Build HTTP headers from client and context metadata.
4195 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4196
4197 hds = append(c.xGoogHeaders, hds...)
4198 hds = append(hds, "Content-Type", "application/json")
4199 headers := gax.BuildHeaders(ctx, hds...)
4200 opts = append((*c.CallOptions).GenerateClientCertificate[0:len((*c.CallOptions).GenerateClientCertificate):len((*c.CallOptions).GenerateClientCertificate)], opts...)
4201 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4202 resp := &alloydbpb.GenerateClientCertificateResponse{}
4203 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4204 if settings.Path != "" {
4205 baseUrl.Path = settings.Path
4206 }
4207 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4208 if err != nil {
4209 return err
4210 }
4211 httpReq = httpReq.WithContext(ctx)
4212 httpReq.Header = headers
4213
4214 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateClientCertificate")
4215 if err != nil {
4216 return err
4217 }
4218
4219 if err := unm.Unmarshal(buf, resp); err != nil {
4220 return err
4221 }
4222
4223 return nil
4224 }, opts...)
4225 if e != nil {
4226 return nil, e
4227 }
4228 return resp, nil
4229 }
4230
4231 // GetConnectionInfo get instance metadata used for a connection.
4232 func (c *alloyDBAdminRESTClient) GetConnectionInfo(ctx context.Context, req *alloydbpb.GetConnectionInfoRequest, opts ...gax.CallOption) (*alloydbpb.ConnectionInfo, error) {
4233 baseUrl, err := url.Parse(c.endpoint)
4234 if err != nil {
4235 return nil, err
4236 }
4237 baseUrl.Path += fmt.Sprintf("/v1beta/%v/connectionInfo", req.GetParent())
4238
4239 params := url.Values{}
4240 params.Add("$alt", "json;enum-encoding=int")
4241 if req.GetRequestId() != "" {
4242 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
4243 }
4244
4245 baseUrl.RawQuery = params.Encode()
4246
4247 // Build HTTP headers from client and context metadata.
4248 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4249
4250 hds = append(c.xGoogHeaders, hds...)
4251 hds = append(hds, "Content-Type", "application/json")
4252 headers := gax.BuildHeaders(ctx, hds...)
4253 opts = append((*c.CallOptions).GetConnectionInfo[0:len((*c.CallOptions).GetConnectionInfo):len((*c.CallOptions).GetConnectionInfo)], opts...)
4254 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4255 resp := &alloydbpb.ConnectionInfo{}
4256 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4257 if settings.Path != "" {
4258 baseUrl.Path = settings.Path
4259 }
4260 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4261 if err != nil {
4262 return err
4263 }
4264 httpReq = httpReq.WithContext(ctx)
4265 httpReq.Header = headers
4266
4267 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetConnectionInfo")
4268 if err != nil {
4269 return err
4270 }
4271
4272 if err := unm.Unmarshal(buf, resp); err != nil {
4273 return err
4274 }
4275
4276 return nil
4277 }, opts...)
4278 if e != nil {
4279 return nil, e
4280 }
4281 return resp, nil
4282 }
4283
4284 // ListUsers lists Users in a given project and location.
4285 func (c *alloyDBAdminRESTClient) ListUsers(ctx context.Context, req *alloydbpb.ListUsersRequest, opts ...gax.CallOption) *UserIterator {
4286 it := &UserIterator{}
4287 req = proto.Clone(req).(*alloydbpb.ListUsersRequest)
4288 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4289 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.User, string, error) {
4290 resp := &alloydbpb.ListUsersResponse{}
4291 if pageToken != "" {
4292 req.PageToken = pageToken
4293 }
4294 if pageSize > math.MaxInt32 {
4295 req.PageSize = math.MaxInt32
4296 } else if pageSize != 0 {
4297 req.PageSize = int32(pageSize)
4298 }
4299 baseUrl, err := url.Parse(c.endpoint)
4300 if err != nil {
4301 return nil, "", err
4302 }
4303 baseUrl.Path += fmt.Sprintf("/v1beta/%v/users", req.GetParent())
4304
4305 params := url.Values{}
4306 params.Add("$alt", "json;enum-encoding=int")
4307 if req.GetFilter() != "" {
4308 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4309 }
4310 if req.GetOrderBy() != "" {
4311 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
4312 }
4313 if req.GetPageSize() != 0 {
4314 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4315 }
4316 if req.GetPageToken() != "" {
4317 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4318 }
4319
4320 baseUrl.RawQuery = params.Encode()
4321
4322 // Build HTTP headers from client and context metadata.
4323 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4324 headers := gax.BuildHeaders(ctx, hds...)
4325 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4326 if settings.Path != "" {
4327 baseUrl.Path = settings.Path
4328 }
4329 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4330 if err != nil {
4331 return err
4332 }
4333 httpReq.Header = headers
4334
4335 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListUsers")
4336 if err != nil {
4337 return err
4338 }
4339 if err := unm.Unmarshal(buf, resp); err != nil {
4340 return err
4341 }
4342
4343 return nil
4344 }, opts...)
4345 if e != nil {
4346 return nil, "", e
4347 }
4348 it.Response = resp
4349 return resp.GetUsers(), resp.GetNextPageToken(), nil
4350 }
4351
4352 fetch := func(pageSize int, pageToken string) (string, error) {
4353 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4354 if err != nil {
4355 return "", err
4356 }
4357 it.items = append(it.items, items...)
4358 return nextPageToken, nil
4359 }
4360
4361 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4362 it.pageInfo.MaxSize = int(req.GetPageSize())
4363 it.pageInfo.Token = req.GetPageToken()
4364
4365 return it
4366 }
4367
4368 // GetUser gets details of a single User.
4369 func (c *alloyDBAdminRESTClient) GetUser(ctx context.Context, req *alloydbpb.GetUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
4370 baseUrl, err := url.Parse(c.endpoint)
4371 if err != nil {
4372 return nil, err
4373 }
4374 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4375
4376 params := url.Values{}
4377 params.Add("$alt", "json;enum-encoding=int")
4378
4379 baseUrl.RawQuery = params.Encode()
4380
4381 // Build HTTP headers from client and context metadata.
4382 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4383
4384 hds = append(c.xGoogHeaders, hds...)
4385 hds = append(hds, "Content-Type", "application/json")
4386 headers := gax.BuildHeaders(ctx, hds...)
4387 opts = append((*c.CallOptions).GetUser[0:len((*c.CallOptions).GetUser):len((*c.CallOptions).GetUser)], opts...)
4388 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4389 resp := &alloydbpb.User{}
4390 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4391 if settings.Path != "" {
4392 baseUrl.Path = settings.Path
4393 }
4394 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4395 if err != nil {
4396 return err
4397 }
4398 httpReq = httpReq.WithContext(ctx)
4399 httpReq.Header = headers
4400
4401 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetUser")
4402 if err != nil {
4403 return err
4404 }
4405
4406 if err := unm.Unmarshal(buf, resp); err != nil {
4407 return err
4408 }
4409
4410 return nil
4411 }, opts...)
4412 if e != nil {
4413 return nil, e
4414 }
4415 return resp, nil
4416 }
4417
4418 // CreateUser creates a new User in a given project, location, and cluster.
4419 func (c *alloyDBAdminRESTClient) CreateUser(ctx context.Context, req *alloydbpb.CreateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
4420 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4421 body := req.GetUser()
4422 jsonReq, err := m.Marshal(body)
4423 if err != nil {
4424 return nil, err
4425 }
4426
4427 baseUrl, err := url.Parse(c.endpoint)
4428 if err != nil {
4429 return nil, err
4430 }
4431 baseUrl.Path += fmt.Sprintf("/v1beta/%v/users", req.GetParent())
4432
4433 params := url.Values{}
4434 params.Add("$alt", "json;enum-encoding=int")
4435 if req.GetRequestId() != "" {
4436 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
4437 }
4438 params.Add("userId", fmt.Sprintf("%v", req.GetUserId()))
4439 if req.GetValidateOnly() {
4440 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
4441 }
4442
4443 baseUrl.RawQuery = params.Encode()
4444
4445 // Build HTTP headers from client and context metadata.
4446 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4447
4448 hds = append(c.xGoogHeaders, hds...)
4449 hds = append(hds, "Content-Type", "application/json")
4450 headers := gax.BuildHeaders(ctx, hds...)
4451 opts = append((*c.CallOptions).CreateUser[0:len((*c.CallOptions).CreateUser):len((*c.CallOptions).CreateUser)], opts...)
4452 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4453 resp := &alloydbpb.User{}
4454 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4455 if settings.Path != "" {
4456 baseUrl.Path = settings.Path
4457 }
4458 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4459 if err != nil {
4460 return err
4461 }
4462 httpReq = httpReq.WithContext(ctx)
4463 httpReq.Header = headers
4464
4465 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateUser")
4466 if err != nil {
4467 return err
4468 }
4469
4470 if err := unm.Unmarshal(buf, resp); err != nil {
4471 return err
4472 }
4473
4474 return nil
4475 }, opts...)
4476 if e != nil {
4477 return nil, e
4478 }
4479 return resp, nil
4480 }
4481
4482 // UpdateUser updates the parameters of a single User.
4483 func (c *alloyDBAdminRESTClient) UpdateUser(ctx context.Context, req *alloydbpb.UpdateUserRequest, opts ...gax.CallOption) (*alloydbpb.User, error) {
4484 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4485 body := req.GetUser()
4486 jsonReq, err := m.Marshal(body)
4487 if err != nil {
4488 return nil, err
4489 }
4490
4491 baseUrl, err := url.Parse(c.endpoint)
4492 if err != nil {
4493 return nil, err
4494 }
4495 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetUser().GetName())
4496
4497 params := url.Values{}
4498 params.Add("$alt", "json;enum-encoding=int")
4499 if req.GetAllowMissing() {
4500 params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
4501 }
4502 if req.GetRequestId() != "" {
4503 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
4504 }
4505 if req.GetUpdateMask() != nil {
4506 field, err := protojson.Marshal(req.GetUpdateMask())
4507 if err != nil {
4508 return nil, err
4509 }
4510 params.Add("updateMask", string(field[1:len(field)-1]))
4511 }
4512 if req.GetValidateOnly() {
4513 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
4514 }
4515
4516 baseUrl.RawQuery = params.Encode()
4517
4518 // Build HTTP headers from client and context metadata.
4519 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "user.name", url.QueryEscape(req.GetUser().GetName()))}
4520
4521 hds = append(c.xGoogHeaders, hds...)
4522 hds = append(hds, "Content-Type", "application/json")
4523 headers := gax.BuildHeaders(ctx, hds...)
4524 opts = append((*c.CallOptions).UpdateUser[0:len((*c.CallOptions).UpdateUser):len((*c.CallOptions).UpdateUser)], opts...)
4525 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4526 resp := &alloydbpb.User{}
4527 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4528 if settings.Path != "" {
4529 baseUrl.Path = settings.Path
4530 }
4531 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4532 if err != nil {
4533 return err
4534 }
4535 httpReq = httpReq.WithContext(ctx)
4536 httpReq.Header = headers
4537
4538 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateUser")
4539 if err != nil {
4540 return err
4541 }
4542
4543 if err := unm.Unmarshal(buf, resp); err != nil {
4544 return err
4545 }
4546
4547 return nil
4548 }, opts...)
4549 if e != nil {
4550 return nil, e
4551 }
4552 return resp, nil
4553 }
4554
4555 // DeleteUser deletes a single User.
4556 func (c *alloyDBAdminRESTClient) DeleteUser(ctx context.Context, req *alloydbpb.DeleteUserRequest, opts ...gax.CallOption) error {
4557 baseUrl, err := url.Parse(c.endpoint)
4558 if err != nil {
4559 return err
4560 }
4561 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4562
4563 params := url.Values{}
4564 params.Add("$alt", "json;enum-encoding=int")
4565 if req.GetRequestId() != "" {
4566 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
4567 }
4568 if req.GetValidateOnly() {
4569 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
4570 }
4571
4572 baseUrl.RawQuery = params.Encode()
4573
4574 // Build HTTP headers from client and context metadata.
4575 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4576
4577 hds = append(c.xGoogHeaders, hds...)
4578 hds = append(hds, "Content-Type", "application/json")
4579 headers := gax.BuildHeaders(ctx, hds...)
4580 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4581 if settings.Path != "" {
4582 baseUrl.Path = settings.Path
4583 }
4584 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4585 if err != nil {
4586 return err
4587 }
4588 httpReq = httpReq.WithContext(ctx)
4589 httpReq.Header = headers
4590
4591 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteUser")
4592 return err
4593 }, opts...)
4594 }
4595
4596 // ListDatabases lists Databases in a given project and location.
4597 func (c *alloyDBAdminRESTClient) ListDatabases(ctx context.Context, req *alloydbpb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
4598 it := &DatabaseIterator{}
4599 req = proto.Clone(req).(*alloydbpb.ListDatabasesRequest)
4600 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4601 it.InternalFetch = func(pageSize int, pageToken string) ([]*alloydbpb.Database, string, error) {
4602 resp := &alloydbpb.ListDatabasesResponse{}
4603 if pageToken != "" {
4604 req.PageToken = pageToken
4605 }
4606 if pageSize > math.MaxInt32 {
4607 req.PageSize = math.MaxInt32
4608 } else if pageSize != 0 {
4609 req.PageSize = int32(pageSize)
4610 }
4611 baseUrl, err := url.Parse(c.endpoint)
4612 if err != nil {
4613 return nil, "", err
4614 }
4615 baseUrl.Path += fmt.Sprintf("/v1beta/%v/databases", req.GetParent())
4616
4617 params := url.Values{}
4618 params.Add("$alt", "json;enum-encoding=int")
4619 if req.GetFilter() != "" {
4620 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4621 }
4622 if req.GetPageSize() != 0 {
4623 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4624 }
4625 if req.GetPageToken() != "" {
4626 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4627 }
4628
4629 baseUrl.RawQuery = params.Encode()
4630
4631 // Build HTTP headers from client and context metadata.
4632 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4633 headers := gax.BuildHeaders(ctx, hds...)
4634 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4635 if settings.Path != "" {
4636 baseUrl.Path = settings.Path
4637 }
4638 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4639 if err != nil {
4640 return err
4641 }
4642 httpReq.Header = headers
4643
4644 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDatabases")
4645 if err != nil {
4646 return err
4647 }
4648 if err := unm.Unmarshal(buf, resp); err != nil {
4649 return err
4650 }
4651
4652 return nil
4653 }, opts...)
4654 if e != nil {
4655 return nil, "", e
4656 }
4657 it.Response = resp
4658 return resp.GetDatabases(), resp.GetNextPageToken(), nil
4659 }
4660
4661 fetch := func(pageSize int, pageToken string) (string, error) {
4662 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4663 if err != nil {
4664 return "", err
4665 }
4666 it.items = append(it.items, items...)
4667 return nextPageToken, nil
4668 }
4669
4670 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4671 it.pageInfo.MaxSize = int(req.GetPageSize())
4672 it.pageInfo.Token = req.GetPageToken()
4673
4674 return it
4675 }
4676
4677 // GetLocation gets information about a location.
4678 func (c *alloyDBAdminRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
4679 baseUrl, err := url.Parse(c.endpoint)
4680 if err != nil {
4681 return nil, err
4682 }
4683 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4684
4685 params := url.Values{}
4686 params.Add("$alt", "json;enum-encoding=int")
4687
4688 baseUrl.RawQuery = params.Encode()
4689
4690 // Build HTTP headers from client and context metadata.
4691 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4692
4693 hds = append(c.xGoogHeaders, hds...)
4694 hds = append(hds, "Content-Type", "application/json")
4695 headers := gax.BuildHeaders(ctx, hds...)
4696 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
4697 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4698 resp := &locationpb.Location{}
4699 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4700 if settings.Path != "" {
4701 baseUrl.Path = settings.Path
4702 }
4703 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4704 if err != nil {
4705 return err
4706 }
4707 httpReq = httpReq.WithContext(ctx)
4708 httpReq.Header = headers
4709
4710 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
4711 if err != nil {
4712 return err
4713 }
4714
4715 if err := unm.Unmarshal(buf, resp); err != nil {
4716 return err
4717 }
4718
4719 return nil
4720 }, opts...)
4721 if e != nil {
4722 return nil, e
4723 }
4724 return resp, nil
4725 }
4726
4727 // ListLocations lists information about the supported locations for this service.
4728 func (c *alloyDBAdminRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
4729 it := &LocationIterator{}
4730 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
4731 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4732 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
4733 resp := &locationpb.ListLocationsResponse{}
4734 if pageToken != "" {
4735 req.PageToken = pageToken
4736 }
4737 if pageSize > math.MaxInt32 {
4738 req.PageSize = math.MaxInt32
4739 } else if pageSize != 0 {
4740 req.PageSize = int32(pageSize)
4741 }
4742 baseUrl, err := url.Parse(c.endpoint)
4743 if err != nil {
4744 return nil, "", err
4745 }
4746 baseUrl.Path += fmt.Sprintf("/v1beta/%v/locations", req.GetName())
4747
4748 params := url.Values{}
4749 params.Add("$alt", "json;enum-encoding=int")
4750 if req.GetFilter() != "" {
4751 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4752 }
4753 if req.GetPageSize() != 0 {
4754 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4755 }
4756 if req.GetPageToken() != "" {
4757 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4758 }
4759
4760 baseUrl.RawQuery = params.Encode()
4761
4762 // Build HTTP headers from client and context metadata.
4763 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4764 headers := gax.BuildHeaders(ctx, hds...)
4765 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4766 if settings.Path != "" {
4767 baseUrl.Path = settings.Path
4768 }
4769 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4770 if err != nil {
4771 return err
4772 }
4773 httpReq.Header = headers
4774
4775 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
4776 if err != nil {
4777 return err
4778 }
4779 if err := unm.Unmarshal(buf, resp); err != nil {
4780 return err
4781 }
4782
4783 return nil
4784 }, opts...)
4785 if e != nil {
4786 return nil, "", e
4787 }
4788 it.Response = resp
4789 return resp.GetLocations(), resp.GetNextPageToken(), nil
4790 }
4791
4792 fetch := func(pageSize int, pageToken string) (string, error) {
4793 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4794 if err != nil {
4795 return "", err
4796 }
4797 it.items = append(it.items, items...)
4798 return nextPageToken, nil
4799 }
4800
4801 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4802 it.pageInfo.MaxSize = int(req.GetPageSize())
4803 it.pageInfo.Token = req.GetPageToken()
4804
4805 return it
4806 }
4807
4808 // CancelOperation is a utility method from google.longrunning.Operations.
4809 func (c *alloyDBAdminRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
4810 baseUrl, err := url.Parse(c.endpoint)
4811 if err != nil {
4812 return err
4813 }
4814 baseUrl.Path += fmt.Sprintf("/v1beta/%v:cancel", req.GetName())
4815
4816 params := url.Values{}
4817 params.Add("$alt", "json;enum-encoding=int")
4818
4819 baseUrl.RawQuery = params.Encode()
4820
4821 // Build HTTP headers from client and context metadata.
4822 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4823
4824 hds = append(c.xGoogHeaders, hds...)
4825 hds = append(hds, "Content-Type", "application/json")
4826 headers := gax.BuildHeaders(ctx, hds...)
4827 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4828 if settings.Path != "" {
4829 baseUrl.Path = settings.Path
4830 }
4831 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
4832 if err != nil {
4833 return err
4834 }
4835 httpReq = httpReq.WithContext(ctx)
4836 httpReq.Header = headers
4837
4838 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
4839 return err
4840 }, opts...)
4841 }
4842
4843 // DeleteOperation is a utility method from google.longrunning.Operations.
4844 func (c *alloyDBAdminRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
4845 baseUrl, err := url.Parse(c.endpoint)
4846 if err != nil {
4847 return err
4848 }
4849 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4850
4851 params := url.Values{}
4852 params.Add("$alt", "json;enum-encoding=int")
4853
4854 baseUrl.RawQuery = params.Encode()
4855
4856 // Build HTTP headers from client and context metadata.
4857 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4858
4859 hds = append(c.xGoogHeaders, hds...)
4860 hds = append(hds, "Content-Type", "application/json")
4861 headers := gax.BuildHeaders(ctx, hds...)
4862 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4863 if settings.Path != "" {
4864 baseUrl.Path = settings.Path
4865 }
4866 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4867 if err != nil {
4868 return err
4869 }
4870 httpReq = httpReq.WithContext(ctx)
4871 httpReq.Header = headers
4872
4873 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
4874 return err
4875 }, opts...)
4876 }
4877
4878 // GetOperation is a utility method from google.longrunning.Operations.
4879 func (c *alloyDBAdminRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
4880 baseUrl, err := url.Parse(c.endpoint)
4881 if err != nil {
4882 return nil, err
4883 }
4884 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
4885
4886 params := url.Values{}
4887 params.Add("$alt", "json;enum-encoding=int")
4888
4889 baseUrl.RawQuery = params.Encode()
4890
4891 // Build HTTP headers from client and context metadata.
4892 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4893
4894 hds = append(c.xGoogHeaders, hds...)
4895 hds = append(hds, "Content-Type", "application/json")
4896 headers := gax.BuildHeaders(ctx, hds...)
4897 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
4898 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4899 resp := &longrunningpb.Operation{}
4900 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4901 if settings.Path != "" {
4902 baseUrl.Path = settings.Path
4903 }
4904 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4905 if err != nil {
4906 return err
4907 }
4908 httpReq = httpReq.WithContext(ctx)
4909 httpReq.Header = headers
4910
4911 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
4912 if err != nil {
4913 return err
4914 }
4915
4916 if err := unm.Unmarshal(buf, resp); err != nil {
4917 return err
4918 }
4919
4920 return nil
4921 }, opts...)
4922 if e != nil {
4923 return nil, e
4924 }
4925 return resp, nil
4926 }
4927
4928 // ListOperations is a utility method from google.longrunning.Operations.
4929 func (c *alloyDBAdminRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
4930 it := &OperationIterator{}
4931 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
4932 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4933 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
4934 resp := &longrunningpb.ListOperationsResponse{}
4935 if pageToken != "" {
4936 req.PageToken = pageToken
4937 }
4938 if pageSize > math.MaxInt32 {
4939 req.PageSize = math.MaxInt32
4940 } else if pageSize != 0 {
4941 req.PageSize = int32(pageSize)
4942 }
4943 baseUrl, err := url.Parse(c.endpoint)
4944 if err != nil {
4945 return nil, "", err
4946 }
4947 baseUrl.Path += fmt.Sprintf("/v1beta/%v/operations", req.GetName())
4948
4949 params := url.Values{}
4950 params.Add("$alt", "json;enum-encoding=int")
4951 if req.GetFilter() != "" {
4952 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4953 }
4954 if req.GetPageSize() != 0 {
4955 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4956 }
4957 if req.GetPageToken() != "" {
4958 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4959 }
4960
4961 baseUrl.RawQuery = params.Encode()
4962
4963 // Build HTTP headers from client and context metadata.
4964 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4965 headers := gax.BuildHeaders(ctx, hds...)
4966 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4967 if settings.Path != "" {
4968 baseUrl.Path = settings.Path
4969 }
4970 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4971 if err != nil {
4972 return err
4973 }
4974 httpReq.Header = headers
4975
4976 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
4977 if err != nil {
4978 return err
4979 }
4980 if err := unm.Unmarshal(buf, resp); err != nil {
4981 return err
4982 }
4983
4984 return nil
4985 }, opts...)
4986 if e != nil {
4987 return nil, "", e
4988 }
4989 it.Response = resp
4990 return resp.GetOperations(), resp.GetNextPageToken(), nil
4991 }
4992
4993 fetch := func(pageSize int, pageToken string) (string, error) {
4994 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4995 if err != nil {
4996 return "", err
4997 }
4998 it.items = append(it.items, items...)
4999 return nextPageToken, nil
5000 }
5001
5002 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5003 it.pageInfo.MaxSize = int(req.GetPageSize())
5004 it.pageInfo.Token = req.GetPageToken()
5005
5006 return it
5007 }
5008
5009 // BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
5010 // The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
5011 func (c *alloyDBAdminGRPCClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
5012 return &BatchCreateInstancesOperation{
5013 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5014 }
5015 }
5016
5017 // BatchCreateInstancesOperation returns a new BatchCreateInstancesOperation from a given name.
5018 // The name must be that of a previously created BatchCreateInstancesOperation, possibly from a different process.
5019 func (c *alloyDBAdminRESTClient) BatchCreateInstancesOperation(name string) *BatchCreateInstancesOperation {
5020 override := fmt.Sprintf("/v1beta/%s", name)
5021 return &BatchCreateInstancesOperation{
5022 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5023 pollPath: override,
5024 }
5025 }
5026
5027 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
5028 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
5029 func (c *alloyDBAdminGRPCClient) CreateBackupOperation(name string) *CreateBackupOperation {
5030 return &CreateBackupOperation{
5031 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5032 }
5033 }
5034
5035 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
5036 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
5037 func (c *alloyDBAdminRESTClient) CreateBackupOperation(name string) *CreateBackupOperation {
5038 override := fmt.Sprintf("/v1beta/%s", name)
5039 return &CreateBackupOperation{
5040 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5041 pollPath: override,
5042 }
5043 }
5044
5045 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
5046 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
5047 func (c *alloyDBAdminGRPCClient) CreateClusterOperation(name string) *CreateClusterOperation {
5048 return &CreateClusterOperation{
5049 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5050 }
5051 }
5052
5053 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
5054 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
5055 func (c *alloyDBAdminRESTClient) CreateClusterOperation(name string) *CreateClusterOperation {
5056 override := fmt.Sprintf("/v1beta/%s", name)
5057 return &CreateClusterOperation{
5058 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5059 pollPath: override,
5060 }
5061 }
5062
5063 // CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
5064 // The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
5065 func (c *alloyDBAdminGRPCClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
5066 return &CreateInstanceOperation{
5067 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5068 }
5069 }
5070
5071 // CreateInstanceOperation returns a new CreateInstanceOperation from a given name.
5072 // The name must be that of a previously created CreateInstanceOperation, possibly from a different process.
5073 func (c *alloyDBAdminRESTClient) CreateInstanceOperation(name string) *CreateInstanceOperation {
5074 override := fmt.Sprintf("/v1beta/%s", name)
5075 return &CreateInstanceOperation{
5076 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5077 pollPath: override,
5078 }
5079 }
5080
5081 // CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
5082 // The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
5083 func (c *alloyDBAdminGRPCClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
5084 return &CreateSecondaryClusterOperation{
5085 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5086 }
5087 }
5088
5089 // CreateSecondaryClusterOperation returns a new CreateSecondaryClusterOperation from a given name.
5090 // The name must be that of a previously created CreateSecondaryClusterOperation, possibly from a different process.
5091 func (c *alloyDBAdminRESTClient) CreateSecondaryClusterOperation(name string) *CreateSecondaryClusterOperation {
5092 override := fmt.Sprintf("/v1beta/%s", name)
5093 return &CreateSecondaryClusterOperation{
5094 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5095 pollPath: override,
5096 }
5097 }
5098
5099 // CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
5100 // The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
5101 func (c *alloyDBAdminGRPCClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
5102 return &CreateSecondaryInstanceOperation{
5103 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5104 }
5105 }
5106
5107 // CreateSecondaryInstanceOperation returns a new CreateSecondaryInstanceOperation from a given name.
5108 // The name must be that of a previously created CreateSecondaryInstanceOperation, possibly from a different process.
5109 func (c *alloyDBAdminRESTClient) CreateSecondaryInstanceOperation(name string) *CreateSecondaryInstanceOperation {
5110 override := fmt.Sprintf("/v1beta/%s", name)
5111 return &CreateSecondaryInstanceOperation{
5112 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5113 pollPath: override,
5114 }
5115 }
5116
5117 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
5118 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
5119 func (c *alloyDBAdminGRPCClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
5120 return &DeleteBackupOperation{
5121 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5122 }
5123 }
5124
5125 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
5126 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
5127 func (c *alloyDBAdminRESTClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
5128 override := fmt.Sprintf("/v1beta/%s", name)
5129 return &DeleteBackupOperation{
5130 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5131 pollPath: override,
5132 }
5133 }
5134
5135 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
5136 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
5137 func (c *alloyDBAdminGRPCClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
5138 return &DeleteClusterOperation{
5139 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5140 }
5141 }
5142
5143 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
5144 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
5145 func (c *alloyDBAdminRESTClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
5146 override := fmt.Sprintf("/v1beta/%s", name)
5147 return &DeleteClusterOperation{
5148 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5149 pollPath: override,
5150 }
5151 }
5152
5153 // DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
5154 // The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
5155 func (c *alloyDBAdminGRPCClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
5156 return &DeleteInstanceOperation{
5157 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5158 }
5159 }
5160
5161 // DeleteInstanceOperation returns a new DeleteInstanceOperation from a given name.
5162 // The name must be that of a previously created DeleteInstanceOperation, possibly from a different process.
5163 func (c *alloyDBAdminRESTClient) DeleteInstanceOperation(name string) *DeleteInstanceOperation {
5164 override := fmt.Sprintf("/v1beta/%s", name)
5165 return &DeleteInstanceOperation{
5166 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5167 pollPath: override,
5168 }
5169 }
5170
5171 // ExportClusterOperation returns a new ExportClusterOperation from a given name.
5172 // The name must be that of a previously created ExportClusterOperation, possibly from a different process.
5173 func (c *alloyDBAdminGRPCClient) ExportClusterOperation(name string) *ExportClusterOperation {
5174 return &ExportClusterOperation{
5175 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5176 }
5177 }
5178
5179 // ExportClusterOperation returns a new ExportClusterOperation from a given name.
5180 // The name must be that of a previously created ExportClusterOperation, possibly from a different process.
5181 func (c *alloyDBAdminRESTClient) ExportClusterOperation(name string) *ExportClusterOperation {
5182 override := fmt.Sprintf("/v1beta/%s", name)
5183 return &ExportClusterOperation{
5184 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5185 pollPath: override,
5186 }
5187 }
5188
5189 // FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
5190 // The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
5191 func (c *alloyDBAdminGRPCClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
5192 return &FailoverInstanceOperation{
5193 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5194 }
5195 }
5196
5197 // FailoverInstanceOperation returns a new FailoverInstanceOperation from a given name.
5198 // The name must be that of a previously created FailoverInstanceOperation, possibly from a different process.
5199 func (c *alloyDBAdminRESTClient) FailoverInstanceOperation(name string) *FailoverInstanceOperation {
5200 override := fmt.Sprintf("/v1beta/%s", name)
5201 return &FailoverInstanceOperation{
5202 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5203 pollPath: override,
5204 }
5205 }
5206
5207 // ImportClusterOperation returns a new ImportClusterOperation from a given name.
5208 // The name must be that of a previously created ImportClusterOperation, possibly from a different process.
5209 func (c *alloyDBAdminGRPCClient) ImportClusterOperation(name string) *ImportClusterOperation {
5210 return &ImportClusterOperation{
5211 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5212 }
5213 }
5214
5215 // ImportClusterOperation returns a new ImportClusterOperation from a given name.
5216 // The name must be that of a previously created ImportClusterOperation, possibly from a different process.
5217 func (c *alloyDBAdminRESTClient) ImportClusterOperation(name string) *ImportClusterOperation {
5218 override := fmt.Sprintf("/v1beta/%s", name)
5219 return &ImportClusterOperation{
5220 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5221 pollPath: override,
5222 }
5223 }
5224
5225 // InjectFaultOperation returns a new InjectFaultOperation from a given name.
5226 // The name must be that of a previously created InjectFaultOperation, possibly from a different process.
5227 func (c *alloyDBAdminGRPCClient) InjectFaultOperation(name string) *InjectFaultOperation {
5228 return &InjectFaultOperation{
5229 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5230 }
5231 }
5232
5233 // InjectFaultOperation returns a new InjectFaultOperation from a given name.
5234 // The name must be that of a previously created InjectFaultOperation, possibly from a different process.
5235 func (c *alloyDBAdminRESTClient) InjectFaultOperation(name string) *InjectFaultOperation {
5236 override := fmt.Sprintf("/v1beta/%s", name)
5237 return &InjectFaultOperation{
5238 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5239 pollPath: override,
5240 }
5241 }
5242
5243 // PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
5244 // The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
5245 func (c *alloyDBAdminGRPCClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
5246 return &PromoteClusterOperation{
5247 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5248 }
5249 }
5250
5251 // PromoteClusterOperation returns a new PromoteClusterOperation from a given name.
5252 // The name must be that of a previously created PromoteClusterOperation, possibly from a different process.
5253 func (c *alloyDBAdminRESTClient) PromoteClusterOperation(name string) *PromoteClusterOperation {
5254 override := fmt.Sprintf("/v1beta/%s", name)
5255 return &PromoteClusterOperation{
5256 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5257 pollPath: override,
5258 }
5259 }
5260
5261 // RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
5262 // The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
5263 func (c *alloyDBAdminGRPCClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
5264 return &RestartInstanceOperation{
5265 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5266 }
5267 }
5268
5269 // RestartInstanceOperation returns a new RestartInstanceOperation from a given name.
5270 // The name must be that of a previously created RestartInstanceOperation, possibly from a different process.
5271 func (c *alloyDBAdminRESTClient) RestartInstanceOperation(name string) *RestartInstanceOperation {
5272 override := fmt.Sprintf("/v1beta/%s", name)
5273 return &RestartInstanceOperation{
5274 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5275 pollPath: override,
5276 }
5277 }
5278
5279 // RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
5280 // The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
5281 func (c *alloyDBAdminGRPCClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
5282 return &RestoreClusterOperation{
5283 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5284 }
5285 }
5286
5287 // RestoreClusterOperation returns a new RestoreClusterOperation from a given name.
5288 // The name must be that of a previously created RestoreClusterOperation, possibly from a different process.
5289 func (c *alloyDBAdminRESTClient) RestoreClusterOperation(name string) *RestoreClusterOperation {
5290 override := fmt.Sprintf("/v1beta/%s", name)
5291 return &RestoreClusterOperation{
5292 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5293 pollPath: override,
5294 }
5295 }
5296
5297 // SwitchoverClusterOperation returns a new SwitchoverClusterOperation from a given name.
5298 // The name must be that of a previously created SwitchoverClusterOperation, possibly from a different process.
5299 func (c *alloyDBAdminGRPCClient) SwitchoverClusterOperation(name string) *SwitchoverClusterOperation {
5300 return &SwitchoverClusterOperation{
5301 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5302 }
5303 }
5304
5305 // SwitchoverClusterOperation returns a new SwitchoverClusterOperation from a given name.
5306 // The name must be that of a previously created SwitchoverClusterOperation, possibly from a different process.
5307 func (c *alloyDBAdminRESTClient) SwitchoverClusterOperation(name string) *SwitchoverClusterOperation {
5308 override := fmt.Sprintf("/v1beta/%s", name)
5309 return &SwitchoverClusterOperation{
5310 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5311 pollPath: override,
5312 }
5313 }
5314
5315 // UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
5316 // The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
5317 func (c *alloyDBAdminGRPCClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
5318 return &UpdateBackupOperation{
5319 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5320 }
5321 }
5322
5323 // UpdateBackupOperation returns a new UpdateBackupOperation from a given name.
5324 // The name must be that of a previously created UpdateBackupOperation, possibly from a different process.
5325 func (c *alloyDBAdminRESTClient) UpdateBackupOperation(name string) *UpdateBackupOperation {
5326 override := fmt.Sprintf("/v1beta/%s", name)
5327 return &UpdateBackupOperation{
5328 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5329 pollPath: override,
5330 }
5331 }
5332
5333 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
5334 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
5335 func (c *alloyDBAdminGRPCClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
5336 return &UpdateClusterOperation{
5337 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5338 }
5339 }
5340
5341 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
5342 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
5343 func (c *alloyDBAdminRESTClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
5344 override := fmt.Sprintf("/v1beta/%s", name)
5345 return &UpdateClusterOperation{
5346 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5347 pollPath: override,
5348 }
5349 }
5350
5351 // UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
5352 // The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
5353 func (c *alloyDBAdminGRPCClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
5354 return &UpdateInstanceOperation{
5355 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5356 }
5357 }
5358
5359 // UpdateInstanceOperation returns a new UpdateInstanceOperation from a given name.
5360 // The name must be that of a previously created UpdateInstanceOperation, possibly from a different process.
5361 func (c *alloyDBAdminRESTClient) UpdateInstanceOperation(name string) *UpdateInstanceOperation {
5362 override := fmt.Sprintf("/v1beta/%s", name)
5363 return &UpdateInstanceOperation{
5364 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5365 pollPath: override,
5366 }
5367 }
5368
5369 // UpgradeClusterOperation returns a new UpgradeClusterOperation from a given name.
5370 // The name must be that of a previously created UpgradeClusterOperation, possibly from a different process.
5371 func (c *alloyDBAdminGRPCClient) UpgradeClusterOperation(name string) *UpgradeClusterOperation {
5372 return &UpgradeClusterOperation{
5373 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5374 }
5375 }
5376
5377 // UpgradeClusterOperation returns a new UpgradeClusterOperation from a given name.
5378 // The name must be that of a previously created UpgradeClusterOperation, possibly from a different process.
5379 func (c *alloyDBAdminRESTClient) UpgradeClusterOperation(name string) *UpgradeClusterOperation {
5380 override := fmt.Sprintf("/v1beta/%s", name)
5381 return &UpgradeClusterOperation{
5382 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5383 pollPath: override,
5384 }
5385 }