cloud.google.com/go/aiplatform@v1.106.0/apiv1/match_client.go (about) 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 aiplatform 18 19 import ( 20 "context" 21 "fmt" 22 "log/slog" 23 "math" 24 "net/url" 25 26 aiplatformpb "cloud.google.com/go/aiplatform/apiv1/aiplatformpb" 27 iampb "cloud.google.com/go/iam/apiv1/iampb" 28 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 29 gax "github.com/googleapis/gax-go/v2" 30 "google.golang.org/api/iterator" 31 "google.golang.org/api/option" 32 "google.golang.org/api/option/internaloption" 33 gtransport "google.golang.org/api/transport/grpc" 34 locationpb "google.golang.org/genproto/googleapis/cloud/location" 35 "google.golang.org/grpc" 36 "google.golang.org/protobuf/proto" 37 ) 38 39 var newMatchClientHook clientHook 40 41 // MatchCallOptions contains the retry settings for each method of MatchClient. 42 type MatchCallOptions struct { 43 FindNeighbors []gax.CallOption 44 ReadIndexDatapoints []gax.CallOption 45 GetLocation []gax.CallOption 46 ListLocations []gax.CallOption 47 GetIamPolicy []gax.CallOption 48 SetIamPolicy []gax.CallOption 49 TestIamPermissions []gax.CallOption 50 CancelOperation []gax.CallOption 51 DeleteOperation []gax.CallOption 52 GetOperation []gax.CallOption 53 ListOperations []gax.CallOption 54 WaitOperation []gax.CallOption 55 } 56 57 func defaultMatchGRPCClientOptions() []option.ClientOption { 58 return []option.ClientOption{ 59 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 60 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 61 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 62 internaloption.WithDefaultUniverseDomain("googleapis.com"), 63 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 64 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 65 internaloption.EnableJwtWithScope(), 66 internaloption.EnableNewAuthLibrary(), 67 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 68 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 69 } 70 } 71 72 func defaultMatchCallOptions() *MatchCallOptions { 73 return &MatchCallOptions{ 74 FindNeighbors: []gax.CallOption{}, 75 ReadIndexDatapoints: []gax.CallOption{}, 76 GetLocation: []gax.CallOption{}, 77 ListLocations: []gax.CallOption{}, 78 GetIamPolicy: []gax.CallOption{}, 79 SetIamPolicy: []gax.CallOption{}, 80 TestIamPermissions: []gax.CallOption{}, 81 CancelOperation: []gax.CallOption{}, 82 DeleteOperation: []gax.CallOption{}, 83 GetOperation: []gax.CallOption{}, 84 ListOperations: []gax.CallOption{}, 85 WaitOperation: []gax.CallOption{}, 86 } 87 } 88 89 // internalMatchClient is an interface that defines the methods available from Vertex AI API. 90 type internalMatchClient interface { 91 Close() error 92 setGoogleClientInfo(...string) 93 Connection() *grpc.ClientConn 94 FindNeighbors(context.Context, *aiplatformpb.FindNeighborsRequest, ...gax.CallOption) (*aiplatformpb.FindNeighborsResponse, error) 95 ReadIndexDatapoints(context.Context, *aiplatformpb.ReadIndexDatapointsRequest, ...gax.CallOption) (*aiplatformpb.ReadIndexDatapointsResponse, error) 96 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 97 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 98 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 99 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 100 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 101 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 102 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 103 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 104 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 105 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 106 } 107 108 // MatchClient is a client for interacting with Vertex AI API. 109 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 110 // 111 // MatchService is a Google managed service for efficient vector similarity 112 // search at scale. 113 type MatchClient struct { 114 // The internal transport-dependent client. 115 internalClient internalMatchClient 116 117 // The call options for this service. 118 CallOptions *MatchCallOptions 119 } 120 121 // Wrapper methods routed to the internal client. 122 123 // Close closes the connection to the API service. The user should invoke this when 124 // the client is no longer required. 125 func (c *MatchClient) Close() error { 126 return c.internalClient.Close() 127 } 128 129 // setGoogleClientInfo sets the name and version of the application in 130 // the `x-goog-api-client` header passed on each request. Intended for 131 // use by Google-written clients. 132 func (c *MatchClient) setGoogleClientInfo(keyval ...string) { 133 c.internalClient.setGoogleClientInfo(keyval...) 134 } 135 136 // Connection returns a connection to the API service. 137 // 138 // Deprecated: Connections are now pooled so this method does not always 139 // return the same resource. 140 func (c *MatchClient) Connection() *grpc.ClientConn { 141 return c.internalClient.Connection() 142 } 143 144 // FindNeighbors finds the nearest neighbors of each vector within the request. 145 func (c *MatchClient) FindNeighbors(ctx context.Context, req *aiplatformpb.FindNeighborsRequest, opts ...gax.CallOption) (*aiplatformpb.FindNeighborsResponse, error) { 146 return c.internalClient.FindNeighbors(ctx, req, opts...) 147 } 148 149 // ReadIndexDatapoints reads the datapoints/vectors of the given IDs. 150 // A maximum of 1000 datapoints can be retrieved in a batch. 151 func (c *MatchClient) ReadIndexDatapoints(ctx context.Context, req *aiplatformpb.ReadIndexDatapointsRequest, opts ...gax.CallOption) (*aiplatformpb.ReadIndexDatapointsResponse, error) { 152 return c.internalClient.ReadIndexDatapoints(ctx, req, opts...) 153 } 154 155 // GetLocation gets information about a location. 156 func (c *MatchClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 157 return c.internalClient.GetLocation(ctx, req, opts...) 158 } 159 160 // ListLocations lists information about the supported locations for this service. 161 func (c *MatchClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 162 return c.internalClient.ListLocations(ctx, req, opts...) 163 } 164 165 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 166 // if the resource exists and does not have a policy set. 167 func (c *MatchClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 168 return c.internalClient.GetIamPolicy(ctx, req, opts...) 169 } 170 171 // SetIamPolicy sets the access control policy on the specified resource. Replaces 172 // any existing policy. 173 // 174 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 175 // errors. 176 func (c *MatchClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 177 return c.internalClient.SetIamPolicy(ctx, req, opts...) 178 } 179 180 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 181 // resource does not exist, this will return an empty set of 182 // permissions, not a NOT_FOUND error. 183 // 184 // Note: This operation is designed to be used for building 185 // permission-aware UIs and command-line tools, not for authorization 186 // checking. This operation may “fail open” without warning. 187 func (c *MatchClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 188 return c.internalClient.TestIamPermissions(ctx, req, opts...) 189 } 190 191 // CancelOperation is a utility method from google.longrunning.Operations. 192 func (c *MatchClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 193 return c.internalClient.CancelOperation(ctx, req, opts...) 194 } 195 196 // DeleteOperation is a utility method from google.longrunning.Operations. 197 func (c *MatchClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 198 return c.internalClient.DeleteOperation(ctx, req, opts...) 199 } 200 201 // GetOperation is a utility method from google.longrunning.Operations. 202 func (c *MatchClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 203 return c.internalClient.GetOperation(ctx, req, opts...) 204 } 205 206 // ListOperations is a utility method from google.longrunning.Operations. 207 func (c *MatchClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 208 return c.internalClient.ListOperations(ctx, req, opts...) 209 } 210 211 // WaitOperation is a utility method from google.longrunning.Operations. 212 func (c *MatchClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 213 return c.internalClient.WaitOperation(ctx, req, opts...) 214 } 215 216 // matchGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 217 // 218 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 219 type matchGRPCClient struct { 220 // Connection pool of gRPC connections to the service. 221 connPool gtransport.ConnPool 222 223 // Points back to the CallOptions field of the containing MatchClient 224 CallOptions **MatchCallOptions 225 226 // The gRPC API client. 227 matchClient aiplatformpb.MatchServiceClient 228 229 operationsClient longrunningpb.OperationsClient 230 231 iamPolicyClient iampb.IAMPolicyClient 232 233 locationsClient locationpb.LocationsClient 234 235 // The x-goog-* metadata to be sent with each request. 236 xGoogHeaders []string 237 238 logger *slog.Logger 239 } 240 241 // NewMatchClient creates a new match service client based on gRPC. 242 // The returned client must be Closed when it is done being used to clean up its underlying connections. 243 // 244 // MatchService is a Google managed service for efficient vector similarity 245 // search at scale. 246 func NewMatchClient(ctx context.Context, opts ...option.ClientOption) (*MatchClient, error) { 247 clientOpts := defaultMatchGRPCClientOptions() 248 if newMatchClientHook != nil { 249 hookOpts, err := newMatchClientHook(ctx, clientHookParams{}) 250 if err != nil { 251 return nil, err 252 } 253 clientOpts = append(clientOpts, hookOpts...) 254 } 255 256 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 257 if err != nil { 258 return nil, err 259 } 260 client := MatchClient{CallOptions: defaultMatchCallOptions()} 261 262 c := &matchGRPCClient{ 263 connPool: connPool, 264 matchClient: aiplatformpb.NewMatchServiceClient(connPool), 265 CallOptions: &client.CallOptions, 266 logger: internaloption.GetLogger(opts), 267 operationsClient: longrunningpb.NewOperationsClient(connPool), 268 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 269 locationsClient: locationpb.NewLocationsClient(connPool), 270 } 271 c.setGoogleClientInfo() 272 273 client.internalClient = c 274 275 return &client, nil 276 } 277 278 // Connection returns a connection to the API service. 279 // 280 // Deprecated: Connections are now pooled so this method does not always 281 // return the same resource. 282 func (c *matchGRPCClient) Connection() *grpc.ClientConn { 283 return c.connPool.Conn() 284 } 285 286 // setGoogleClientInfo sets the name and version of the application in 287 // the `x-goog-api-client` header passed on each request. Intended for 288 // use by Google-written clients. 289 func (c *matchGRPCClient) setGoogleClientInfo(keyval ...string) { 290 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 291 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 292 c.xGoogHeaders = []string{ 293 "x-goog-api-client", gax.XGoogHeader(kv...), 294 } 295 } 296 297 // Close closes the connection to the API service. The user should invoke this when 298 // the client is no longer required. 299 func (c *matchGRPCClient) Close() error { 300 return c.connPool.Close() 301 } 302 303 func (c *matchGRPCClient) FindNeighbors(ctx context.Context, req *aiplatformpb.FindNeighborsRequest, opts ...gax.CallOption) (*aiplatformpb.FindNeighborsResponse, error) { 304 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 305 306 hds = append(c.xGoogHeaders, hds...) 307 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 308 opts = append((*c.CallOptions).FindNeighbors[0:len((*c.CallOptions).FindNeighbors):len((*c.CallOptions).FindNeighbors)], opts...) 309 var resp *aiplatformpb.FindNeighborsResponse 310 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 311 var err error 312 resp, err = executeRPC(ctx, c.matchClient.FindNeighbors, req, settings.GRPC, c.logger, "FindNeighbors") 313 return err 314 }, opts...) 315 if err != nil { 316 return nil, err 317 } 318 return resp, nil 319 } 320 321 func (c *matchGRPCClient) ReadIndexDatapoints(ctx context.Context, req *aiplatformpb.ReadIndexDatapointsRequest, opts ...gax.CallOption) (*aiplatformpb.ReadIndexDatapointsResponse, error) { 322 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 323 324 hds = append(c.xGoogHeaders, hds...) 325 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 326 opts = append((*c.CallOptions).ReadIndexDatapoints[0:len((*c.CallOptions).ReadIndexDatapoints):len((*c.CallOptions).ReadIndexDatapoints)], opts...) 327 var resp *aiplatformpb.ReadIndexDatapointsResponse 328 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 329 var err error 330 resp, err = executeRPC(ctx, c.matchClient.ReadIndexDatapoints, req, settings.GRPC, c.logger, "ReadIndexDatapoints") 331 return err 332 }, opts...) 333 if err != nil { 334 return nil, err 335 } 336 return resp, nil 337 } 338 339 func (c *matchGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 340 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 341 342 hds = append(c.xGoogHeaders, hds...) 343 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 344 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 345 var resp *locationpb.Location 346 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 347 var err error 348 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 349 return err 350 }, opts...) 351 if err != nil { 352 return nil, err 353 } 354 return resp, nil 355 } 356 357 func (c *matchGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 358 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 359 360 hds = append(c.xGoogHeaders, hds...) 361 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 362 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 363 it := &LocationIterator{} 364 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 365 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 366 resp := &locationpb.ListLocationsResponse{} 367 if pageToken != "" { 368 req.PageToken = pageToken 369 } 370 if pageSize > math.MaxInt32 { 371 req.PageSize = math.MaxInt32 372 } else if pageSize != 0 { 373 req.PageSize = int32(pageSize) 374 } 375 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 376 var err error 377 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 378 return err 379 }, opts...) 380 if err != nil { 381 return nil, "", err 382 } 383 384 it.Response = resp 385 return resp.GetLocations(), resp.GetNextPageToken(), nil 386 } 387 fetch := func(pageSize int, pageToken string) (string, error) { 388 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 389 if err != nil { 390 return "", err 391 } 392 it.items = append(it.items, items...) 393 return nextPageToken, nil 394 } 395 396 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 397 it.pageInfo.MaxSize = int(req.GetPageSize()) 398 it.pageInfo.Token = req.GetPageToken() 399 400 return it 401 } 402 403 func (c *matchGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 404 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 405 406 hds = append(c.xGoogHeaders, hds...) 407 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 408 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 409 var resp *iampb.Policy 410 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 411 var err error 412 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 413 return err 414 }, opts...) 415 if err != nil { 416 return nil, err 417 } 418 return resp, nil 419 } 420 421 func (c *matchGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 422 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 423 424 hds = append(c.xGoogHeaders, hds...) 425 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 426 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 427 var resp *iampb.Policy 428 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 429 var err error 430 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 431 return err 432 }, opts...) 433 if err != nil { 434 return nil, err 435 } 436 return resp, nil 437 } 438 439 func (c *matchGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 440 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 441 442 hds = append(c.xGoogHeaders, hds...) 443 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 444 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 445 var resp *iampb.TestIamPermissionsResponse 446 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 447 var err error 448 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 449 return err 450 }, opts...) 451 if err != nil { 452 return nil, err 453 } 454 return resp, nil 455 } 456 457 func (c *matchGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 458 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 459 460 hds = append(c.xGoogHeaders, hds...) 461 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 462 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 463 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 464 var err error 465 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 466 return err 467 }, opts...) 468 return err 469 } 470 471 func (c *matchGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 472 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 473 474 hds = append(c.xGoogHeaders, hds...) 475 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 476 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 477 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 478 var err error 479 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 480 return err 481 }, opts...) 482 return err 483 } 484 485 func (c *matchGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 486 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 487 488 hds = append(c.xGoogHeaders, hds...) 489 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 490 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 491 var resp *longrunningpb.Operation 492 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 493 var err error 494 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 495 return err 496 }, opts...) 497 if err != nil { 498 return nil, err 499 } 500 return resp, nil 501 } 502 503 func (c *matchGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 504 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 505 506 hds = append(c.xGoogHeaders, hds...) 507 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 508 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 509 it := &OperationIterator{} 510 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 511 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 512 resp := &longrunningpb.ListOperationsResponse{} 513 if pageToken != "" { 514 req.PageToken = pageToken 515 } 516 if pageSize > math.MaxInt32 { 517 req.PageSize = math.MaxInt32 518 } else if pageSize != 0 { 519 req.PageSize = int32(pageSize) 520 } 521 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 522 var err error 523 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 524 return err 525 }, opts...) 526 if err != nil { 527 return nil, "", err 528 } 529 530 it.Response = resp 531 return resp.GetOperations(), resp.GetNextPageToken(), nil 532 } 533 fetch := func(pageSize int, pageToken string) (string, error) { 534 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 535 if err != nil { 536 return "", err 537 } 538 it.items = append(it.items, items...) 539 return nextPageToken, nil 540 } 541 542 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 543 it.pageInfo.MaxSize = int(req.GetPageSize()) 544 it.pageInfo.Token = req.GetPageToken() 545 546 return it 547 } 548 549 func (c *matchGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 550 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 551 552 hds = append(c.xGoogHeaders, hds...) 553 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 554 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 555 var resp *longrunningpb.Operation 556 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 557 var err error 558 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 559 return err 560 }, opts...) 561 if err != nil { 562 return nil, err 563 } 564 return resp, nil 565 }