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