Debian Codegraph @

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