Debian Codegraph @

gkemulticloud/apiv1/attached_clusters_client.go

raw symbols SCIP
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 gkemulticloud
18
19 import (
20 "context"
21 "fmt"
22 "log/slog"
23 "math"
24 "net/url"
25 "time"
26
27 gkemulticloudpb "cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb"
28 "cloud.google.com/go/longrunning"
29 lroauto "cloud.google.com/go/longrunning/autogen"
30 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
31 gax "github.com/googleapis/gax-go/v2"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 "google.golang.org/grpc"
37 "google.golang.org/grpc/codes"
38 "google.golang.org/protobuf/proto"
39 )
40
41 var newAttachedClustersClientHook clientHook
42
43 // AttachedClustersCallOptions contains the retry settings for each method of AttachedClustersClient.
44 type AttachedClustersCallOptions struct {
45 CreateAttachedCluster []gax.CallOption
46 UpdateAttachedCluster []gax.CallOption
47 ImportAttachedCluster []gax.CallOption
48 GetAttachedCluster []gax.CallOption
49 ListAttachedClusters []gax.CallOption
50 DeleteAttachedCluster []gax.CallOption
51 GetAttachedServerConfig []gax.CallOption
52 GenerateAttachedClusterInstallManifest []gax.CallOption
53 GenerateAttachedClusterAgentToken []gax.CallOption
54 CancelOperation []gax.CallOption
55 DeleteOperation []gax.CallOption
56 GetOperation []gax.CallOption
57 ListOperations []gax.CallOption
58 }
59
60 func defaultAttachedClustersGRPCClientOptions() []option.ClientOption {
61 return []option.ClientOption{
62 internaloption.WithDefaultEndpoint("gkemulticloud.googleapis.com:443"),
63 internaloption.WithDefaultEndpointTemplate("gkemulticloud.UNIVERSE_DOMAIN:443"),
64 internaloption.WithDefaultMTLSEndpoint("gkemulticloud.mtls.googleapis.com:443"),
65 internaloption.WithDefaultUniverseDomain("googleapis.com"),
66 internaloption.WithDefaultAudience("https://gkemulticloud.googleapis.com/"),
67 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
68 internaloption.EnableJwtWithScope(),
69 internaloption.EnableNewAuthLibrary(),
70 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
71 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
72 }
73 }
74
75 func defaultAttachedClustersCallOptions() *AttachedClustersCallOptions {
76 return &AttachedClustersCallOptions{
77 CreateAttachedCluster: []gax.CallOption{
78 gax.WithTimeout(60000 * time.Millisecond),
79 },
80 UpdateAttachedCluster: []gax.CallOption{
81 gax.WithTimeout(60000 * time.Millisecond),
82 },
83 ImportAttachedCluster: []gax.CallOption{
84 gax.WithTimeout(60000 * time.Millisecond),
85 },
86 GetAttachedCluster: []gax.CallOption{
87 gax.WithTimeout(60000 * time.Millisecond),
88 gax.WithRetry(func() gax.Retryer {
89 return gax.OnCodes([]codes.Code{
90 codes.Unavailable,
91 }, gax.Backoff{
92 Initial: 1000 * time.Millisecond,
93 Max: 10000 * time.Millisecond,
94 Multiplier: 1.30,
95 })
96 }),
97 },
98 ListAttachedClusters: []gax.CallOption{
99 gax.WithTimeout(60000 * time.Millisecond),
100 gax.WithRetry(func() gax.Retryer {
101 return gax.OnCodes([]codes.Code{
102 codes.Unavailable,
103 }, gax.Backoff{
104 Initial: 1000 * time.Millisecond,
105 Max: 10000 * time.Millisecond,
106 Multiplier: 1.30,
107 })
108 }),
109 },
110 DeleteAttachedCluster: []gax.CallOption{
111 gax.WithTimeout(60000 * time.Millisecond),
112 },
113 GetAttachedServerConfig: []gax.CallOption{
114 gax.WithTimeout(60000 * time.Millisecond),
115 gax.WithRetry(func() gax.Retryer {
116 return gax.OnCodes([]codes.Code{
117 codes.Unavailable,
118 }, gax.Backoff{
119 Initial: 1000 * time.Millisecond,
120 Max: 10000 * time.Millisecond,
121 Multiplier: 1.30,
122 })
123 }),
124 },
125 GenerateAttachedClusterInstallManifest: []gax.CallOption{
126 gax.WithTimeout(60000 * time.Millisecond),
127 gax.WithRetry(func() gax.Retryer {
128 return gax.OnCodes([]codes.Code{
129 codes.Unavailable,
130 }, gax.Backoff{
131 Initial: 1000 * time.Millisecond,
132 Max: 10000 * time.Millisecond,
133 Multiplier: 1.30,
134 })
135 }),
136 },
137 GenerateAttachedClusterAgentToken: []gax.CallOption{
138 gax.WithTimeout(60000 * time.Millisecond),
139 gax.WithRetry(func() gax.Retryer {
140 return gax.OnCodes([]codes.Code{
141 codes.Unavailable,
142 }, gax.Backoff{
143 Initial: 1000 * time.Millisecond,
144 Max: 10000 * time.Millisecond,
145 Multiplier: 1.30,
146 })
147 }),
148 },
149 CancelOperation: []gax.CallOption{},
150 DeleteOperation: []gax.CallOption{},
151 GetOperation: []gax.CallOption{},
152 ListOperations: []gax.CallOption{},
153 }
154 }
155
156 // internalAttachedClustersClient is an interface that defines the methods available from GKE Multi-Cloud API.
157 type internalAttachedClustersClient interface {
158 Close() error
159 setGoogleClientInfo(...string)
160 Connection() *grpc.ClientConn
161 CreateAttachedCluster(context.Context, *gkemulticloudpb.CreateAttachedClusterRequest, ...gax.CallOption) (*CreateAttachedClusterOperation, error)
162 CreateAttachedClusterOperation(name string) *CreateAttachedClusterOperation
163 UpdateAttachedCluster(context.Context, *gkemulticloudpb.UpdateAttachedClusterRequest, ...gax.CallOption) (*UpdateAttachedClusterOperation, error)
164 UpdateAttachedClusterOperation(name string) *UpdateAttachedClusterOperation
165 ImportAttachedCluster(context.Context, *gkemulticloudpb.ImportAttachedClusterRequest, ...gax.CallOption) (*ImportAttachedClusterOperation, error)
166 ImportAttachedClusterOperation(name string) *ImportAttachedClusterOperation
167 GetAttachedCluster(context.Context, *gkemulticloudpb.GetAttachedClusterRequest, ...gax.CallOption) (*gkemulticloudpb.AttachedCluster, error)
168 ListAttachedClusters(context.Context, *gkemulticloudpb.ListAttachedClustersRequest, ...gax.CallOption) *AttachedClusterIterator
169 DeleteAttachedCluster(context.Context, *gkemulticloudpb.DeleteAttachedClusterRequest, ...gax.CallOption) (*DeleteAttachedClusterOperation, error)
170 DeleteAttachedClusterOperation(name string) *DeleteAttachedClusterOperation
171 GetAttachedServerConfig(context.Context, *gkemulticloudpb.GetAttachedServerConfigRequest, ...gax.CallOption) (*gkemulticloudpb.AttachedServerConfig, error)
172 GenerateAttachedClusterInstallManifest(context.Context, *gkemulticloudpb.GenerateAttachedClusterInstallManifestRequest, ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterInstallManifestResponse, error)
173 GenerateAttachedClusterAgentToken(context.Context, *gkemulticloudpb.GenerateAttachedClusterAgentTokenRequest, ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterAgentTokenResponse, error)
174 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
175 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
176 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
177 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
178 }
179
180 // AttachedClustersClient is a client for interacting with GKE Multi-Cloud API.
181 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
182 //
183 // The AttachedClusters API provides a single centrally managed service
184 // to register and manage Anthos attached clusters that run on customer’s owned
185 // infrastructure.
186 type AttachedClustersClient struct {
187 // The internal transport-dependent client.
188 internalClient internalAttachedClustersClient
189
190 // The call options for this service.
191 CallOptions *AttachedClustersCallOptions
192
193 // LROClient is used internally to handle long-running operations.
194 // It is exposed so that its CallOptions can be modified if required.
195 // Users should not Close this client.
196 LROClient *lroauto.OperationsClient
197 }
198
199 // Wrapper methods routed to the internal client.
200
201 // Close closes the connection to the API service. The user should invoke this when
202 // the client is no longer required.
203 func (c *AttachedClustersClient) Close() error {
204 return c.internalClient.Close()
205 }
206
207 // setGoogleClientInfo sets the name and version of the application in
208 // the `x-goog-api-client` header passed on each request. Intended for
209 // use by Google-written clients.
210 func (c *AttachedClustersClient) setGoogleClientInfo(keyval ...string) {
211 c.internalClient.setGoogleClientInfo(keyval...)
212 }
213
214 // Connection returns a connection to the API service.
215 //
216 // Deprecated: Connections are now pooled so this method does not always
217 // return the same resource.
218 func (c *AttachedClustersClient) Connection() *grpc.ClientConn {
219 return c.internalClient.Connection()
220 }
221
222 // CreateAttachedCluster creates a new
223 // AttachedCluster resource
224 // on a given Google Cloud Platform project and region.
225 //
226 // If successful, the response contains a newly created
227 // Operation resource that can be
228 // described to track the status of the operation.
229 func (c *AttachedClustersClient) CreateAttachedCluster(ctx context.Context, req *gkemulticloudpb.CreateAttachedClusterRequest, opts ...gax.CallOption) (*CreateAttachedClusterOperation, error) {
230 return c.internalClient.CreateAttachedCluster(ctx, req, opts...)
231 }
232
233 // CreateAttachedClusterOperation returns a new CreateAttachedClusterOperation from a given name.
234 // The name must be that of a previously created CreateAttachedClusterOperation, possibly from a different process.
235 func (c *AttachedClustersClient) CreateAttachedClusterOperation(name string) *CreateAttachedClusterOperation {
236 return c.internalClient.CreateAttachedClusterOperation(name)
237 }
238
239 // UpdateAttachedCluster updates an
240 // AttachedCluster.
241 func (c *AttachedClustersClient) UpdateAttachedCluster(ctx context.Context, req *gkemulticloudpb.UpdateAttachedClusterRequest, opts ...gax.CallOption) (*UpdateAttachedClusterOperation, error) {
242 return c.internalClient.UpdateAttachedCluster(ctx, req, opts...)
243 }
244
245 // UpdateAttachedClusterOperation returns a new UpdateAttachedClusterOperation from a given name.
246 // The name must be that of a previously created UpdateAttachedClusterOperation, possibly from a different process.
247 func (c *AttachedClustersClient) UpdateAttachedClusterOperation(name string) *UpdateAttachedClusterOperation {
248 return c.internalClient.UpdateAttachedClusterOperation(name)
249 }
250
251 // ImportAttachedCluster imports creates a new
252 // AttachedCluster resource
253 // by importing an existing Fleet Membership resource.
254 //
255 // Attached Clusters created before the introduction of the Anthos Multi-Cloud
256 // API can be imported through this method.
257 //
258 // If successful, the response contains a newly created
259 // Operation resource that can be
260 // described to track the status of the operation.
261 func (c *AttachedClustersClient) ImportAttachedCluster(ctx context.Context, req *gkemulticloudpb.ImportAttachedClusterRequest, opts ...gax.CallOption) (*ImportAttachedClusterOperation, error) {
262 return c.internalClient.ImportAttachedCluster(ctx, req, opts...)
263 }
264
265 // ImportAttachedClusterOperation returns a new ImportAttachedClusterOperation from a given name.
266 // The name must be that of a previously created ImportAttachedClusterOperation, possibly from a different process.
267 func (c *AttachedClustersClient) ImportAttachedClusterOperation(name string) *ImportAttachedClusterOperation {
268 return c.internalClient.ImportAttachedClusterOperation(name)
269 }
270
271 // GetAttachedCluster describes a specific
272 // AttachedCluster resource.
273 func (c *AttachedClustersClient) GetAttachedCluster(ctx context.Context, req *gkemulticloudpb.GetAttachedClusterRequest, opts ...gax.CallOption) (*gkemulticloudpb.AttachedCluster, error) {
274 return c.internalClient.GetAttachedCluster(ctx, req, opts...)
275 }
276
277 // ListAttachedClusters lists all AttachedCluster
278 // resources on a given Google Cloud project and region.
279 func (c *AttachedClustersClient) ListAttachedClusters(ctx context.Context, req *gkemulticloudpb.ListAttachedClustersRequest, opts ...gax.CallOption) *AttachedClusterIterator {
280 return c.internalClient.ListAttachedClusters(ctx, req, opts...)
281 }
282
283 // DeleteAttachedCluster deletes a specific
284 // AttachedCluster resource.
285 //
286 // If successful, the response contains a newly created
287 // Operation resource that can be
288 // described to track the status of the operation.
289 func (c *AttachedClustersClient) DeleteAttachedCluster(ctx context.Context, req *gkemulticloudpb.DeleteAttachedClusterRequest, opts ...gax.CallOption) (*DeleteAttachedClusterOperation, error) {
290 return c.internalClient.DeleteAttachedCluster(ctx, req, opts...)
291 }
292
293 // DeleteAttachedClusterOperation returns a new DeleteAttachedClusterOperation from a given name.
294 // The name must be that of a previously created DeleteAttachedClusterOperation, possibly from a different process.
295 func (c *AttachedClustersClient) DeleteAttachedClusterOperation(name string) *DeleteAttachedClusterOperation {
296 return c.internalClient.DeleteAttachedClusterOperation(name)
297 }
298
299 // GetAttachedServerConfig returns information, such as supported Kubernetes versions, on a given
300 // Google Cloud location.
301 func (c *AttachedClustersClient) GetAttachedServerConfig(ctx context.Context, req *gkemulticloudpb.GetAttachedServerConfigRequest, opts ...gax.CallOption) (*gkemulticloudpb.AttachedServerConfig, error) {
302 return c.internalClient.GetAttachedServerConfig(ctx, req, opts...)
303 }
304
305 // GenerateAttachedClusterInstallManifest generates the install manifest to be installed on the target cluster.
306 func (c *AttachedClustersClient) GenerateAttachedClusterInstallManifest(ctx context.Context, req *gkemulticloudpb.GenerateAttachedClusterInstallManifestRequest, opts ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterInstallManifestResponse, error) {
307 return c.internalClient.GenerateAttachedClusterInstallManifest(ctx, req, opts...)
308 }
309
310 // GenerateAttachedClusterAgentToken generates an access token for a cluster agent.
311 func (c *AttachedClustersClient) GenerateAttachedClusterAgentToken(ctx context.Context, req *gkemulticloudpb.GenerateAttachedClusterAgentTokenRequest, opts ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterAgentTokenResponse, error) {
312 return c.internalClient.GenerateAttachedClusterAgentToken(ctx, req, opts...)
313 }
314
315 // CancelOperation is a utility method from google.longrunning.Operations.
316 func (c *AttachedClustersClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
317 return c.internalClient.CancelOperation(ctx, req, opts...)
318 }
319
320 // DeleteOperation is a utility method from google.longrunning.Operations.
321 func (c *AttachedClustersClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
322 return c.internalClient.DeleteOperation(ctx, req, opts...)
323 }
324
325 // GetOperation is a utility method from google.longrunning.Operations.
326 func (c *AttachedClustersClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
327 return c.internalClient.GetOperation(ctx, req, opts...)
328 }
329
330 // ListOperations is a utility method from google.longrunning.Operations.
331 func (c *AttachedClustersClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
332 return c.internalClient.ListOperations(ctx, req, opts...)
333 }
334
335 // attachedClustersGRPCClient is a client for interacting with GKE Multi-Cloud API over gRPC transport.
336 //
337 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
338 type attachedClustersGRPCClient struct {
339 // Connection pool of gRPC connections to the service.
340 connPool gtransport.ConnPool
341
342 // Points back to the CallOptions field of the containing AttachedClustersClient
343 CallOptions **AttachedClustersCallOptions
344
345 // The gRPC API client.
346 attachedClustersClient gkemulticloudpb.AttachedClustersClient
347
348 // LROClient is used internally to handle long-running operations.
349 // It is exposed so that its CallOptions can be modified if required.
350 // Users should not Close this client.
351 LROClient **lroauto.OperationsClient
352
353 operationsClient longrunningpb.OperationsClient
354
355 // The x-goog-* metadata to be sent with each request.
356 xGoogHeaders []string
357
358 logger *slog.Logger
359 }
360
361 // NewAttachedClustersClient creates a new attached clusters client based on gRPC.
362 // The returned client must be Closed when it is done being used to clean up its underlying connections.
363 //
364 // The AttachedClusters API provides a single centrally managed service
365 // to register and manage Anthos attached clusters that run on customer’s owned
366 // infrastructure.
367 func NewAttachedClustersClient(ctx context.Context, opts ...option.ClientOption) (*AttachedClustersClient, error) {
368 clientOpts := defaultAttachedClustersGRPCClientOptions()
369 if newAttachedClustersClientHook != nil {
370 hookOpts, err := newAttachedClustersClientHook(ctx, clientHookParams{})
371 if err != nil {
372 return nil, err
373 }
374 clientOpts = append(clientOpts, hookOpts...)
375 }
376
377 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
378 if err != nil {
379 return nil, err
380 }
381 client := AttachedClustersClient{CallOptions: defaultAttachedClustersCallOptions()}
382
383 c := &attachedClustersGRPCClient{
384 connPool: connPool,
385 attachedClustersClient: gkemulticloudpb.NewAttachedClustersClient(connPool),
386 CallOptions: &client.CallOptions,
387 logger: internaloption.GetLogger(opts),
388 operationsClient: longrunningpb.NewOperationsClient(connPool),
389 }
390 c.setGoogleClientInfo()
391
392 client.internalClient = c
393
394 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
395 if err != nil {
396 // This error "should not happen", since we are just reusing old connection pool
397 // and never actually need to dial.
398 // If this does happen, we could leak connp. However, we cannot close conn:
399 // If the user invoked the constructor with option.WithGRPCConn,
400 // we would close a connection that's still in use.
401 // TODO: investigate error conditions.
402 return nil, err
403 }
404 c.LROClient = &client.LROClient
405 return &client, nil
406 }
407
408 // Connection returns a connection to the API service.
409 //
410 // Deprecated: Connections are now pooled so this method does not always
411 // return the same resource.
412 func (c *attachedClustersGRPCClient) Connection() *grpc.ClientConn {
413 return c.connPool.Conn()
414 }
415
416 // setGoogleClientInfo sets the name and version of the application in
417 // the `x-goog-api-client` header passed on each request. Intended for
418 // use by Google-written clients.
419 func (c *attachedClustersGRPCClient) setGoogleClientInfo(keyval ...string) {
420 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
421 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
422 c.xGoogHeaders = []string{
423 "x-goog-api-client", gax.XGoogHeader(kv...),
424 }
425 }
426
427 // Close closes the connection to the API service. The user should invoke this when
428 // the client is no longer required.
429 func (c *attachedClustersGRPCClient) Close() error {
430 return c.connPool.Close()
431 }
432
433 func (c *attachedClustersGRPCClient) CreateAttachedCluster(ctx context.Context, req *gkemulticloudpb.CreateAttachedClusterRequest, opts ...gax.CallOption) (*CreateAttachedClusterOperation, error) {
434 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
435
436 hds = append(c.xGoogHeaders, hds...)
437 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
438 opts = append((*c.CallOptions).CreateAttachedCluster[0:len((*c.CallOptions).CreateAttachedCluster):len((*c.CallOptions).CreateAttachedCluster)], opts...)
439 var resp *longrunningpb.Operation
440 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
441 var err error
442 resp, err = executeRPC(ctx, c.attachedClustersClient.CreateAttachedCluster, req, settings.GRPC, c.logger, "CreateAttachedCluster")
443 return err
444 }, opts...)
445 if err != nil {
446 return nil, err
447 }
448 return &CreateAttachedClusterOperation{
449 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
450 }, nil
451 }
452
453 func (c *attachedClustersGRPCClient) UpdateAttachedCluster(ctx context.Context, req *gkemulticloudpb.UpdateAttachedClusterRequest, opts ...gax.CallOption) (*UpdateAttachedClusterOperation, error) {
454 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "attached_cluster.name", url.QueryEscape(req.GetAttachedCluster().GetName()))}
455
456 hds = append(c.xGoogHeaders, hds...)
457 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
458 opts = append((*c.CallOptions).UpdateAttachedCluster[0:len((*c.CallOptions).UpdateAttachedCluster):len((*c.CallOptions).UpdateAttachedCluster)], opts...)
459 var resp *longrunningpb.Operation
460 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
461 var err error
462 resp, err = executeRPC(ctx, c.attachedClustersClient.UpdateAttachedCluster, req, settings.GRPC, c.logger, "UpdateAttachedCluster")
463 return err
464 }, opts...)
465 if err != nil {
466 return nil, err
467 }
468 return &UpdateAttachedClusterOperation{
469 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
470 }, nil
471 }
472
473 func (c *attachedClustersGRPCClient) ImportAttachedCluster(ctx context.Context, req *gkemulticloudpb.ImportAttachedClusterRequest, opts ...gax.CallOption) (*ImportAttachedClusterOperation, error) {
474 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
475
476 hds = append(c.xGoogHeaders, hds...)
477 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
478 opts = append((*c.CallOptions).ImportAttachedCluster[0:len((*c.CallOptions).ImportAttachedCluster):len((*c.CallOptions).ImportAttachedCluster)], opts...)
479 var resp *longrunningpb.Operation
480 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
481 var err error
482 resp, err = executeRPC(ctx, c.attachedClustersClient.ImportAttachedCluster, req, settings.GRPC, c.logger, "ImportAttachedCluster")
483 return err
484 }, opts...)
485 if err != nil {
486 return nil, err
487 }
488 return &ImportAttachedClusterOperation{
489 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
490 }, nil
491 }
492
493 func (c *attachedClustersGRPCClient) GetAttachedCluster(ctx context.Context, req *gkemulticloudpb.GetAttachedClusterRequest, opts ...gax.CallOption) (*gkemulticloudpb.AttachedCluster, error) {
494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
495
496 hds = append(c.xGoogHeaders, hds...)
497 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
498 opts = append((*c.CallOptions).GetAttachedCluster[0:len((*c.CallOptions).GetAttachedCluster):len((*c.CallOptions).GetAttachedCluster)], opts...)
499 var resp *gkemulticloudpb.AttachedCluster
500 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
501 var err error
502 resp, err = executeRPC(ctx, c.attachedClustersClient.GetAttachedCluster, req, settings.GRPC, c.logger, "GetAttachedCluster")
503 return err
504 }, opts...)
505 if err != nil {
506 return nil, err
507 }
508 return resp, nil
509 }
510
511 func (c *attachedClustersGRPCClient) ListAttachedClusters(ctx context.Context, req *gkemulticloudpb.ListAttachedClustersRequest, opts ...gax.CallOption) *AttachedClusterIterator {
512 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
513
514 hds = append(c.xGoogHeaders, hds...)
515 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
516 opts = append((*c.CallOptions).ListAttachedClusters[0:len((*c.CallOptions).ListAttachedClusters):len((*c.CallOptions).ListAttachedClusters)], opts...)
517 it := &AttachedClusterIterator{}
518 req = proto.Clone(req).(*gkemulticloudpb.ListAttachedClustersRequest)
519 it.InternalFetch = func(pageSize int, pageToken string) ([]*gkemulticloudpb.AttachedCluster, string, error) {
520 resp := &gkemulticloudpb.ListAttachedClustersResponse{}
521 if pageToken != "" {
522 req.PageToken = pageToken
523 }
524 if pageSize > math.MaxInt32 {
525 req.PageSize = math.MaxInt32
526 } else if pageSize != 0 {
527 req.PageSize = int32(pageSize)
528 }
529 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
530 var err error
531 resp, err = executeRPC(ctx, c.attachedClustersClient.ListAttachedClusters, req, settings.GRPC, c.logger, "ListAttachedClusters")
532 return err
533 }, opts...)
534 if err != nil {
535 return nil, "", err
536 }
537
538 it.Response = resp
539 return resp.GetAttachedClusters(), resp.GetNextPageToken(), nil
540 }
541 fetch := func(pageSize int, pageToken string) (string, error) {
542 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
543 if err != nil {
544 return "", err
545 }
546 it.items = append(it.items, items...)
547 return nextPageToken, nil
548 }
549
550 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
551 it.pageInfo.MaxSize = int(req.GetPageSize())
552 it.pageInfo.Token = req.GetPageToken()
553
554 return it
555 }
556
557 func (c *attachedClustersGRPCClient) DeleteAttachedCluster(ctx context.Context, req *gkemulticloudpb.DeleteAttachedClusterRequest, opts ...gax.CallOption) (*DeleteAttachedClusterOperation, error) {
558 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
559
560 hds = append(c.xGoogHeaders, hds...)
561 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
562 opts = append((*c.CallOptions).DeleteAttachedCluster[0:len((*c.CallOptions).DeleteAttachedCluster):len((*c.CallOptions).DeleteAttachedCluster)], opts...)
563 var resp *longrunningpb.Operation
564 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
565 var err error
566 resp, err = executeRPC(ctx, c.attachedClustersClient.DeleteAttachedCluster, req, settings.GRPC, c.logger, "DeleteAttachedCluster")
567 return err
568 }, opts...)
569 if err != nil {
570 return nil, err
571 }
572 return &DeleteAttachedClusterOperation{
573 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
574 }, nil
575 }
576
577 func (c *attachedClustersGRPCClient) GetAttachedServerConfig(ctx context.Context, req *gkemulticloudpb.GetAttachedServerConfigRequest, opts ...gax.CallOption) (*gkemulticloudpb.AttachedServerConfig, error) {
578 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
579
580 hds = append(c.xGoogHeaders, hds...)
581 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
582 opts = append((*c.CallOptions).GetAttachedServerConfig[0:len((*c.CallOptions).GetAttachedServerConfig):len((*c.CallOptions).GetAttachedServerConfig)], opts...)
583 var resp *gkemulticloudpb.AttachedServerConfig
584 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
585 var err error
586 resp, err = executeRPC(ctx, c.attachedClustersClient.GetAttachedServerConfig, req, settings.GRPC, c.logger, "GetAttachedServerConfig")
587 return err
588 }, opts...)
589 if err != nil {
590 return nil, err
591 }
592 return resp, nil
593 }
594
595 func (c *attachedClustersGRPCClient) GenerateAttachedClusterInstallManifest(ctx context.Context, req *gkemulticloudpb.GenerateAttachedClusterInstallManifestRequest, opts ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterInstallManifestResponse, error) {
596 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
597
598 hds = append(c.xGoogHeaders, hds...)
599 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
600 opts = append((*c.CallOptions).GenerateAttachedClusterInstallManifest[0:len((*c.CallOptions).GenerateAttachedClusterInstallManifest):len((*c.CallOptions).GenerateAttachedClusterInstallManifest)], opts...)
601 var resp *gkemulticloudpb.GenerateAttachedClusterInstallManifestResponse
602 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
603 var err error
604 resp, err = executeRPC(ctx, c.attachedClustersClient.GenerateAttachedClusterInstallManifest, req, settings.GRPC, c.logger, "GenerateAttachedClusterInstallManifest")
605 return err
606 }, opts...)
607 if err != nil {
608 return nil, err
609 }
610 return resp, nil
611 }
612
613 func (c *attachedClustersGRPCClient) GenerateAttachedClusterAgentToken(ctx context.Context, req *gkemulticloudpb.GenerateAttachedClusterAgentTokenRequest, opts ...gax.CallOption) (*gkemulticloudpb.GenerateAttachedClusterAgentTokenResponse, error) {
614 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "attached_cluster", url.QueryEscape(req.GetAttachedCluster()))}
615
616 hds = append(c.xGoogHeaders, hds...)
617 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
618 opts = append((*c.CallOptions).GenerateAttachedClusterAgentToken[0:len((*c.CallOptions).GenerateAttachedClusterAgentToken):len((*c.CallOptions).GenerateAttachedClusterAgentToken)], opts...)
619 var resp *gkemulticloudpb.GenerateAttachedClusterAgentTokenResponse
620 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
621 var err error
622 resp, err = executeRPC(ctx, c.attachedClustersClient.GenerateAttachedClusterAgentToken, req, settings.GRPC, c.logger, "GenerateAttachedClusterAgentToken")
623 return err
624 }, opts...)
625 if err != nil {
626 return nil, err
627 }
628 return resp, nil
629 }
630
631 func (c *attachedClustersGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
632 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
633
634 hds = append(c.xGoogHeaders, hds...)
635 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
636 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
637 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
638 var err error
639 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
640 return err
641 }, opts...)
642 return err
643 }
644
645 func (c *attachedClustersGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
646 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
647
648 hds = append(c.xGoogHeaders, hds...)
649 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
650 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
651 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
652 var err error
653 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
654 return err
655 }, opts...)
656 return err
657 }
658
659 func (c *attachedClustersGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
660 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
661
662 hds = append(c.xGoogHeaders, hds...)
663 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
664 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
665 var resp *longrunningpb.Operation
666 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
667 var err error
668 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
669 return err
670 }, opts...)
671 if err != nil {
672 return nil, err
673 }
674 return resp, nil
675 }
676
677 func (c *attachedClustersGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
678 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
679
680 hds = append(c.xGoogHeaders, hds...)
681 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
682 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
683 it := &OperationIterator{}
684 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
685 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
686 resp := &longrunningpb.ListOperationsResponse{}
687 if pageToken != "" {
688 req.PageToken = pageToken
689 }
690 if pageSize > math.MaxInt32 {
691 req.PageSize = math.MaxInt32
692 } else if pageSize != 0 {
693 req.PageSize = int32(pageSize)
694 }
695 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
696 var err error
697 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
698 return err
699 }, opts...)
700 if err != nil {
701 return nil, "", err
702 }
703
704 it.Response = resp
705 return resp.GetOperations(), resp.GetNextPageToken(), nil
706 }
707 fetch := func(pageSize int, pageToken string) (string, error) {
708 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
709 if err != nil {
710 return "", err
711 }
712 it.items = append(it.items, items...)
713 return nextPageToken, nil
714 }
715
716 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
717 it.pageInfo.MaxSize = int(req.GetPageSize())
718 it.pageInfo.Token = req.GetPageToken()
719
720 return it
721 }
722
723 // CreateAttachedClusterOperation returns a new CreateAttachedClusterOperation from a given name.
724 // The name must be that of a previously created CreateAttachedClusterOperation, possibly from a different process.
725 func (c *attachedClustersGRPCClient) CreateAttachedClusterOperation(name string) *CreateAttachedClusterOperation {
726 return &CreateAttachedClusterOperation{
727 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
728 }
729 }
730
731 // DeleteAttachedClusterOperation returns a new DeleteAttachedClusterOperation from a given name.
732 // The name must be that of a previously created DeleteAttachedClusterOperation, possibly from a different process.
733 func (c *attachedClustersGRPCClient) DeleteAttachedClusterOperation(name string) *DeleteAttachedClusterOperation {
734 return &DeleteAttachedClusterOperation{
735 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
736 }
737 }
738
739 // ImportAttachedClusterOperation returns a new ImportAttachedClusterOperation from a given name.
740 // The name must be that of a previously created ImportAttachedClusterOperation, possibly from a different process.
741 func (c *attachedClustersGRPCClient) ImportAttachedClusterOperation(name string) *ImportAttachedClusterOperation {
742 return &ImportAttachedClusterOperation{
743 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
744 }
745 }
746
747 // UpdateAttachedClusterOperation returns a new UpdateAttachedClusterOperation from a given name.
748 // The name must be that of a previously created UpdateAttachedClusterOperation, possibly from a different process.
749 func (c *attachedClustersGRPCClient) UpdateAttachedClusterOperation(name string) *UpdateAttachedClusterOperation {
750 return &UpdateAttachedClusterOperation{
751 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
752 }
753 }