Debian Codegraph @

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