cloud.google.com/go/aiplatform@v1.106.0/apiv1/index_endpoint_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 "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 locationpb "google.golang.org/genproto/googleapis/cloud/location" 37 "google.golang.org/grpc" 38 "google.golang.org/protobuf/proto" 39 ) 40 41 var newIndexEndpointClientHook clientHook 42 43 // IndexEndpointCallOptions contains the retry settings for each method of IndexEndpointClient. 44 type IndexEndpointCallOptions struct { 45 CreateIndexEndpoint []gax.CallOption 46 GetIndexEndpoint []gax.CallOption 47 ListIndexEndpoints []gax.CallOption 48 UpdateIndexEndpoint []gax.CallOption 49 DeleteIndexEndpoint []gax.CallOption 50 DeployIndex []gax.CallOption 51 UndeployIndex []gax.CallOption 52 MutateDeployedIndex []gax.CallOption 53 GetLocation []gax.CallOption 54 ListLocations []gax.CallOption 55 GetIamPolicy []gax.CallOption 56 SetIamPolicy []gax.CallOption 57 TestIamPermissions []gax.CallOption 58 CancelOperation []gax.CallOption 59 DeleteOperation []gax.CallOption 60 GetOperation []gax.CallOption 61 ListOperations []gax.CallOption 62 WaitOperation []gax.CallOption 63 } 64 65 func defaultIndexEndpointGRPCClientOptions() []option.ClientOption { 66 return []option.ClientOption{ 67 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 68 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 69 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 70 internaloption.WithDefaultUniverseDomain("googleapis.com"), 71 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 72 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 73 internaloption.EnableJwtWithScope(), 74 internaloption.EnableNewAuthLibrary(), 75 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 76 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 77 } 78 } 79 80 func defaultIndexEndpointCallOptions() *IndexEndpointCallOptions { 81 return &IndexEndpointCallOptions{ 82 CreateIndexEndpoint: []gax.CallOption{}, 83 GetIndexEndpoint: []gax.CallOption{}, 84 ListIndexEndpoints: []gax.CallOption{}, 85 UpdateIndexEndpoint: []gax.CallOption{}, 86 DeleteIndexEndpoint: []gax.CallOption{}, 87 DeployIndex: []gax.CallOption{}, 88 UndeployIndex: []gax.CallOption{}, 89 MutateDeployedIndex: []gax.CallOption{}, 90 GetLocation: []gax.CallOption{}, 91 ListLocations: []gax.CallOption{}, 92 GetIamPolicy: []gax.CallOption{}, 93 SetIamPolicy: []gax.CallOption{}, 94 TestIamPermissions: []gax.CallOption{}, 95 CancelOperation: []gax.CallOption{}, 96 DeleteOperation: []gax.CallOption{}, 97 GetOperation: []gax.CallOption{}, 98 ListOperations: []gax.CallOption{}, 99 WaitOperation: []gax.CallOption{}, 100 } 101 } 102 103 // internalIndexEndpointClient is an interface that defines the methods available from Vertex AI API. 104 type internalIndexEndpointClient interface { 105 Close() error 106 setGoogleClientInfo(...string) 107 Connection() *grpc.ClientConn 108 CreateIndexEndpoint(context.Context, *aiplatformpb.CreateIndexEndpointRequest, ...gax.CallOption) (*CreateIndexEndpointOperation, error) 109 CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation 110 GetIndexEndpoint(context.Context, *aiplatformpb.GetIndexEndpointRequest, ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) 111 ListIndexEndpoints(context.Context, *aiplatformpb.ListIndexEndpointsRequest, ...gax.CallOption) *IndexEndpointIterator 112 UpdateIndexEndpoint(context.Context, *aiplatformpb.UpdateIndexEndpointRequest, ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) 113 DeleteIndexEndpoint(context.Context, *aiplatformpb.DeleteIndexEndpointRequest, ...gax.CallOption) (*DeleteIndexEndpointOperation, error) 114 DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation 115 DeployIndex(context.Context, *aiplatformpb.DeployIndexRequest, ...gax.CallOption) (*DeployIndexOperation, error) 116 DeployIndexOperation(name string) *DeployIndexOperation 117 UndeployIndex(context.Context, *aiplatformpb.UndeployIndexRequest, ...gax.CallOption) (*UndeployIndexOperation, error) 118 UndeployIndexOperation(name string) *UndeployIndexOperation 119 MutateDeployedIndex(context.Context, *aiplatformpb.MutateDeployedIndexRequest, ...gax.CallOption) (*MutateDeployedIndexOperation, error) 120 MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation 121 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 122 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 123 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 124 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 125 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 126 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 127 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 128 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 129 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 130 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 131 } 132 133 // IndexEndpointClient is a client for interacting with Vertex AI API. 134 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 135 // 136 // A service for managing Vertex AI’s IndexEndpoints. 137 type IndexEndpointClient struct { 138 // The internal transport-dependent client. 139 internalClient internalIndexEndpointClient 140 141 // The call options for this service. 142 CallOptions *IndexEndpointCallOptions 143 144 // LROClient is used internally to handle long-running operations. 145 // It is exposed so that its CallOptions can be modified if required. 146 // Users should not Close this client. 147 LROClient *lroauto.OperationsClient 148 } 149 150 // Wrapper methods routed to the internal client. 151 152 // Close closes the connection to the API service. The user should invoke this when 153 // the client is no longer required. 154 func (c *IndexEndpointClient) Close() error { 155 return c.internalClient.Close() 156 } 157 158 // setGoogleClientInfo sets the name and version of the application in 159 // the `x-goog-api-client` header passed on each request. Intended for 160 // use by Google-written clients. 161 func (c *IndexEndpointClient) setGoogleClientInfo(keyval ...string) { 162 c.internalClient.setGoogleClientInfo(keyval...) 163 } 164 165 // Connection returns a connection to the API service. 166 // 167 // Deprecated: Connections are now pooled so this method does not always 168 // return the same resource. 169 func (c *IndexEndpointClient) Connection() *grpc.ClientConn { 170 return c.internalClient.Connection() 171 } 172 173 // CreateIndexEndpoint creates an IndexEndpoint. 174 func (c *IndexEndpointClient) CreateIndexEndpoint(ctx context.Context, req *aiplatformpb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) { 175 return c.internalClient.CreateIndexEndpoint(ctx, req, opts...) 176 } 177 178 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name. 179 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process. 180 func (c *IndexEndpointClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation { 181 return c.internalClient.CreateIndexEndpointOperation(name) 182 } 183 184 // GetIndexEndpoint gets an IndexEndpoint. 185 func (c *IndexEndpointClient) GetIndexEndpoint(ctx context.Context, req *aiplatformpb.GetIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 186 return c.internalClient.GetIndexEndpoint(ctx, req, opts...) 187 } 188 189 // ListIndexEndpoints lists IndexEndpoints in a Location. 190 func (c *IndexEndpointClient) ListIndexEndpoints(ctx context.Context, req *aiplatformpb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator { 191 return c.internalClient.ListIndexEndpoints(ctx, req, opts...) 192 } 193 194 // UpdateIndexEndpoint updates an IndexEndpoint. 195 func (c *IndexEndpointClient) UpdateIndexEndpoint(ctx context.Context, req *aiplatformpb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 196 return c.internalClient.UpdateIndexEndpoint(ctx, req, opts...) 197 } 198 199 // DeleteIndexEndpoint deletes an IndexEndpoint. 200 func (c *IndexEndpointClient) DeleteIndexEndpoint(ctx context.Context, req *aiplatformpb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) { 201 return c.internalClient.DeleteIndexEndpoint(ctx, req, opts...) 202 } 203 204 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name. 205 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process. 206 func (c *IndexEndpointClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation { 207 return c.internalClient.DeleteIndexEndpointOperation(name) 208 } 209 210 // DeployIndex deploys an Index into this IndexEndpoint, creating a DeployedIndex within 211 // it. 212 // Only non-empty Indexes can be deployed. 213 func (c *IndexEndpointClient) DeployIndex(ctx context.Context, req *aiplatformpb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) { 214 return c.internalClient.DeployIndex(ctx, req, opts...) 215 } 216 217 // DeployIndexOperation returns a new DeployIndexOperation from a given name. 218 // The name must be that of a previously created DeployIndexOperation, possibly from a different process. 219 func (c *IndexEndpointClient) DeployIndexOperation(name string) *DeployIndexOperation { 220 return c.internalClient.DeployIndexOperation(name) 221 } 222 223 // UndeployIndex undeploys an Index from an IndexEndpoint, removing a DeployedIndex from it, 224 // and freeing all resources it’s using. 225 func (c *IndexEndpointClient) UndeployIndex(ctx context.Context, req *aiplatformpb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) { 226 return c.internalClient.UndeployIndex(ctx, req, opts...) 227 } 228 229 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name. 230 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process. 231 func (c *IndexEndpointClient) UndeployIndexOperation(name string) *UndeployIndexOperation { 232 return c.internalClient.UndeployIndexOperation(name) 233 } 234 235 // MutateDeployedIndex update an existing DeployedIndex under an IndexEndpoint. 236 func (c *IndexEndpointClient) MutateDeployedIndex(ctx context.Context, req *aiplatformpb.MutateDeployedIndexRequest, opts ...gax.CallOption) (*MutateDeployedIndexOperation, error) { 237 return c.internalClient.MutateDeployedIndex(ctx, req, opts...) 238 } 239 240 // MutateDeployedIndexOperation returns a new MutateDeployedIndexOperation from a given name. 241 // The name must be that of a previously created MutateDeployedIndexOperation, possibly from a different process. 242 func (c *IndexEndpointClient) MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation { 243 return c.internalClient.MutateDeployedIndexOperation(name) 244 } 245 246 // GetLocation gets information about a location. 247 func (c *IndexEndpointClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 248 return c.internalClient.GetLocation(ctx, req, opts...) 249 } 250 251 // ListLocations lists information about the supported locations for this service. 252 func (c *IndexEndpointClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 253 return c.internalClient.ListLocations(ctx, req, opts...) 254 } 255 256 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 257 // if the resource exists and does not have a policy set. 258 func (c *IndexEndpointClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 259 return c.internalClient.GetIamPolicy(ctx, req, opts...) 260 } 261 262 // SetIamPolicy sets the access control policy on the specified resource. Replaces 263 // any existing policy. 264 // 265 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 266 // errors. 267 func (c *IndexEndpointClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 268 return c.internalClient.SetIamPolicy(ctx, req, opts...) 269 } 270 271 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 272 // resource does not exist, this will return an empty set of 273 // permissions, not a NOT_FOUND error. 274 // 275 // Note: This operation is designed to be used for building 276 // permission-aware UIs and command-line tools, not for authorization 277 // checking. This operation may “fail open” without warning. 278 func (c *IndexEndpointClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 279 return c.internalClient.TestIamPermissions(ctx, req, opts...) 280 } 281 282 // CancelOperation is a utility method from google.longrunning.Operations. 283 func (c *IndexEndpointClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 284 return c.internalClient.CancelOperation(ctx, req, opts...) 285 } 286 287 // DeleteOperation is a utility method from google.longrunning.Operations. 288 func (c *IndexEndpointClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 289 return c.internalClient.DeleteOperation(ctx, req, opts...) 290 } 291 292 // GetOperation is a utility method from google.longrunning.Operations. 293 func (c *IndexEndpointClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 294 return c.internalClient.GetOperation(ctx, req, opts...) 295 } 296 297 // ListOperations is a utility method from google.longrunning.Operations. 298 func (c *IndexEndpointClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 299 return c.internalClient.ListOperations(ctx, req, opts...) 300 } 301 302 // WaitOperation is a utility method from google.longrunning.Operations. 303 func (c *IndexEndpointClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 304 return c.internalClient.WaitOperation(ctx, req, opts...) 305 } 306 307 // indexEndpointGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 308 // 309 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 310 type indexEndpointGRPCClient struct { 311 // Connection pool of gRPC connections to the service. 312 connPool gtransport.ConnPool 313 314 // Points back to the CallOptions field of the containing IndexEndpointClient 315 CallOptions **IndexEndpointCallOptions 316 317 // The gRPC API client. 318 indexEndpointClient aiplatformpb.IndexEndpointServiceClient 319 320 // LROClient is used internally to handle long-running operations. 321 // It is exposed so that its CallOptions can be modified if required. 322 // Users should not Close this client. 323 LROClient **lroauto.OperationsClient 324 325 operationsClient longrunningpb.OperationsClient 326 327 iamPolicyClient iampb.IAMPolicyClient 328 329 locationsClient locationpb.LocationsClient 330 331 // The x-goog-* metadata to be sent with each request. 332 xGoogHeaders []string 333 334 logger *slog.Logger 335 } 336 337 // NewIndexEndpointClient creates a new index endpoint service client based on gRPC. 338 // The returned client must be Closed when it is done being used to clean up its underlying connections. 339 // 340 // A service for managing Vertex AI’s IndexEndpoints. 341 func NewIndexEndpointClient(ctx context.Context, opts ...option.ClientOption) (*IndexEndpointClient, error) { 342 clientOpts := defaultIndexEndpointGRPCClientOptions() 343 if newIndexEndpointClientHook != nil { 344 hookOpts, err := newIndexEndpointClientHook(ctx, clientHookParams{}) 345 if err != nil { 346 return nil, err 347 } 348 clientOpts = append(clientOpts, hookOpts...) 349 } 350 351 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 352 if err != nil { 353 return nil, err 354 } 355 client := IndexEndpointClient{CallOptions: defaultIndexEndpointCallOptions()} 356 357 c := &indexEndpointGRPCClient{ 358 connPool: connPool, 359 indexEndpointClient: aiplatformpb.NewIndexEndpointServiceClient(connPool), 360 CallOptions: &client.CallOptions, 361 logger: internaloption.GetLogger(opts), 362 operationsClient: longrunningpb.NewOperationsClient(connPool), 363 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 364 locationsClient: locationpb.NewLocationsClient(connPool), 365 } 366 c.setGoogleClientInfo() 367 368 client.internalClient = c 369 370 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 371 if err != nil { 372 // This error "should not happen", since we are just reusing old connection pool 373 // and never actually need to dial. 374 // If this does happen, we could leak connp. However, we cannot close conn: 375 // If the user invoked the constructor with option.WithGRPCConn, 376 // we would close a connection that's still in use. 377 // TODO: investigate error conditions. 378 return nil, err 379 } 380 c.LROClient = &client.LROClient 381 return &client, nil 382 } 383 384 // Connection returns a connection to the API service. 385 // 386 // Deprecated: Connections are now pooled so this method does not always 387 // return the same resource. 388 func (c *indexEndpointGRPCClient) Connection() *grpc.ClientConn { 389 return c.connPool.Conn() 390 } 391 392 // setGoogleClientInfo sets the name and version of the application in 393 // the `x-goog-api-client` header passed on each request. Intended for 394 // use by Google-written clients. 395 func (c *indexEndpointGRPCClient) setGoogleClientInfo(keyval ...string) { 396 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 397 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 398 c.xGoogHeaders = []string{ 399 "x-goog-api-client", gax.XGoogHeader(kv...), 400 } 401 } 402 403 // Close closes the connection to the API service. The user should invoke this when 404 // the client is no longer required. 405 func (c *indexEndpointGRPCClient) Close() error { 406 return c.connPool.Close() 407 } 408 409 func (c *indexEndpointGRPCClient) CreateIndexEndpoint(ctx context.Context, req *aiplatformpb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) { 410 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 411 412 hds = append(c.xGoogHeaders, hds...) 413 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 414 opts = append((*c.CallOptions).CreateIndexEndpoint[0:len((*c.CallOptions).CreateIndexEndpoint):len((*c.CallOptions).CreateIndexEndpoint)], opts...) 415 var resp *longrunningpb.Operation 416 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 417 var err error 418 resp, err = executeRPC(ctx, c.indexEndpointClient.CreateIndexEndpoint, req, settings.GRPC, c.logger, "CreateIndexEndpoint") 419 return err 420 }, opts...) 421 if err != nil { 422 return nil, err 423 } 424 return &CreateIndexEndpointOperation{ 425 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 426 }, nil 427 } 428 429 func (c *indexEndpointGRPCClient) GetIndexEndpoint(ctx context.Context, req *aiplatformpb.GetIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 430 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 431 432 hds = append(c.xGoogHeaders, hds...) 433 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 434 opts = append((*c.CallOptions).GetIndexEndpoint[0:len((*c.CallOptions).GetIndexEndpoint):len((*c.CallOptions).GetIndexEndpoint)], opts...) 435 var resp *aiplatformpb.IndexEndpoint 436 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 437 var err error 438 resp, err = executeRPC(ctx, c.indexEndpointClient.GetIndexEndpoint, req, settings.GRPC, c.logger, "GetIndexEndpoint") 439 return err 440 }, opts...) 441 if err != nil { 442 return nil, err 443 } 444 return resp, nil 445 } 446 447 func (c *indexEndpointGRPCClient) ListIndexEndpoints(ctx context.Context, req *aiplatformpb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator { 448 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 449 450 hds = append(c.xGoogHeaders, hds...) 451 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 452 opts = append((*c.CallOptions).ListIndexEndpoints[0:len((*c.CallOptions).ListIndexEndpoints):len((*c.CallOptions).ListIndexEndpoints)], opts...) 453 it := &IndexEndpointIterator{} 454 req = proto.Clone(req).(*aiplatformpb.ListIndexEndpointsRequest) 455 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.IndexEndpoint, string, error) { 456 resp := &aiplatformpb.ListIndexEndpointsResponse{} 457 if pageToken != "" { 458 req.PageToken = pageToken 459 } 460 if pageSize > math.MaxInt32 { 461 req.PageSize = math.MaxInt32 462 } else if pageSize != 0 { 463 req.PageSize = int32(pageSize) 464 } 465 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 466 var err error 467 resp, err = executeRPC(ctx, c.indexEndpointClient.ListIndexEndpoints, req, settings.GRPC, c.logger, "ListIndexEndpoints") 468 return err 469 }, opts...) 470 if err != nil { 471 return nil, "", err 472 } 473 474 it.Response = resp 475 return resp.GetIndexEndpoints(), resp.GetNextPageToken(), nil 476 } 477 fetch := func(pageSize int, pageToken string) (string, error) { 478 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 479 if err != nil { 480 return "", err 481 } 482 it.items = append(it.items, items...) 483 return nextPageToken, nil 484 } 485 486 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 487 it.pageInfo.MaxSize = int(req.GetPageSize()) 488 it.pageInfo.Token = req.GetPageToken() 489 490 return it 491 } 492 493 func (c *indexEndpointGRPCClient) UpdateIndexEndpoint(ctx context.Context, req *aiplatformpb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint.name", url.QueryEscape(req.GetIndexEndpoint().GetName()))} 495 496 hds = append(c.xGoogHeaders, hds...) 497 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 498 opts = append((*c.CallOptions).UpdateIndexEndpoint[0:len((*c.CallOptions).UpdateIndexEndpoint):len((*c.CallOptions).UpdateIndexEndpoint)], opts...) 499 var resp *aiplatformpb.IndexEndpoint 500 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 501 var err error 502 resp, err = executeRPC(ctx, c.indexEndpointClient.UpdateIndexEndpoint, req, settings.GRPC, c.logger, "UpdateIndexEndpoint") 503 return err 504 }, opts...) 505 if err != nil { 506 return nil, err 507 } 508 return resp, nil 509 } 510 511 func (c *indexEndpointGRPCClient) DeleteIndexEndpoint(ctx context.Context, req *aiplatformpb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, 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).DeleteIndexEndpoint[0:len((*c.CallOptions).DeleteIndexEndpoint):len((*c.CallOptions).DeleteIndexEndpoint)], 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.indexEndpointClient.DeleteIndexEndpoint, req, settings.GRPC, c.logger, "DeleteIndexEndpoint") 521 return err 522 }, opts...) 523 if err != nil { 524 return nil, err 525 } 526 return &DeleteIndexEndpointOperation{ 527 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 528 }, nil 529 } 530 531 func (c *indexEndpointGRPCClient) DeployIndex(ctx context.Context, req *aiplatformpb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) { 532 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 533 534 hds = append(c.xGoogHeaders, hds...) 535 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 536 opts = append((*c.CallOptions).DeployIndex[0:len((*c.CallOptions).DeployIndex):len((*c.CallOptions).DeployIndex)], opts...) 537 var resp *longrunningpb.Operation 538 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 539 var err error 540 resp, err = executeRPC(ctx, c.indexEndpointClient.DeployIndex, req, settings.GRPC, c.logger, "DeployIndex") 541 return err 542 }, opts...) 543 if err != nil { 544 return nil, err 545 } 546 return &DeployIndexOperation{ 547 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 548 }, nil 549 } 550 551 func (c *indexEndpointGRPCClient) UndeployIndex(ctx context.Context, req *aiplatformpb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) { 552 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 553 554 hds = append(c.xGoogHeaders, hds...) 555 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 556 opts = append((*c.CallOptions).UndeployIndex[0:len((*c.CallOptions).UndeployIndex):len((*c.CallOptions).UndeployIndex)], opts...) 557 var resp *longrunningpb.Operation 558 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 559 var err error 560 resp, err = executeRPC(ctx, c.indexEndpointClient.UndeployIndex, req, settings.GRPC, c.logger, "UndeployIndex") 561 return err 562 }, opts...) 563 if err != nil { 564 return nil, err 565 } 566 return &UndeployIndexOperation{ 567 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 568 }, nil 569 } 570 571 func (c *indexEndpointGRPCClient) MutateDeployedIndex(ctx context.Context, req *aiplatformpb.MutateDeployedIndexRequest, opts ...gax.CallOption) (*MutateDeployedIndexOperation, error) { 572 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 573 574 hds = append(c.xGoogHeaders, hds...) 575 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 576 opts = append((*c.CallOptions).MutateDeployedIndex[0:len((*c.CallOptions).MutateDeployedIndex):len((*c.CallOptions).MutateDeployedIndex)], opts...) 577 var resp *longrunningpb.Operation 578 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 579 var err error 580 resp, err = executeRPC(ctx, c.indexEndpointClient.MutateDeployedIndex, req, settings.GRPC, c.logger, "MutateDeployedIndex") 581 return err 582 }, opts...) 583 if err != nil { 584 return nil, err 585 } 586 return &MutateDeployedIndexOperation{ 587 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 588 }, nil 589 } 590 591 func (c *indexEndpointGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 592 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 593 594 hds = append(c.xGoogHeaders, hds...) 595 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 596 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 597 var resp *locationpb.Location 598 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 599 var err error 600 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 601 return err 602 }, opts...) 603 if err != nil { 604 return nil, err 605 } 606 return resp, nil 607 } 608 609 func (c *indexEndpointGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 610 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 611 612 hds = append(c.xGoogHeaders, hds...) 613 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 614 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 615 it := &LocationIterator{} 616 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 617 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 618 resp := &locationpb.ListLocationsResponse{} 619 if pageToken != "" { 620 req.PageToken = pageToken 621 } 622 if pageSize > math.MaxInt32 { 623 req.PageSize = math.MaxInt32 624 } else if pageSize != 0 { 625 req.PageSize = int32(pageSize) 626 } 627 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 628 var err error 629 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 630 return err 631 }, opts...) 632 if err != nil { 633 return nil, "", err 634 } 635 636 it.Response = resp 637 return resp.GetLocations(), resp.GetNextPageToken(), nil 638 } 639 fetch := func(pageSize int, pageToken string) (string, error) { 640 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 641 if err != nil { 642 return "", err 643 } 644 it.items = append(it.items, items...) 645 return nextPageToken, nil 646 } 647 648 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 649 it.pageInfo.MaxSize = int(req.GetPageSize()) 650 it.pageInfo.Token = req.GetPageToken() 651 652 return it 653 } 654 655 func (c *indexEndpointGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 656 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 657 658 hds = append(c.xGoogHeaders, hds...) 659 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 660 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 661 var resp *iampb.Policy 662 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 663 var err error 664 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 665 return err 666 }, opts...) 667 if err != nil { 668 return nil, err 669 } 670 return resp, nil 671 } 672 673 func (c *indexEndpointGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 674 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 675 676 hds = append(c.xGoogHeaders, hds...) 677 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 678 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 679 var resp *iampb.Policy 680 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 681 var err error 682 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 683 return err 684 }, opts...) 685 if err != nil { 686 return nil, err 687 } 688 return resp, nil 689 } 690 691 func (c *indexEndpointGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 692 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 693 694 hds = append(c.xGoogHeaders, hds...) 695 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 696 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 697 var resp *iampb.TestIamPermissionsResponse 698 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 699 var err error 700 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 701 return err 702 }, opts...) 703 if err != nil { 704 return nil, err 705 } 706 return resp, nil 707 } 708 709 func (c *indexEndpointGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 710 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 711 712 hds = append(c.xGoogHeaders, hds...) 713 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 714 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 715 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 716 var err error 717 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 718 return err 719 }, opts...) 720 return err 721 } 722 723 func (c *indexEndpointGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 724 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 725 726 hds = append(c.xGoogHeaders, hds...) 727 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 728 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 729 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 730 var err error 731 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 732 return err 733 }, opts...) 734 return err 735 } 736 737 func (c *indexEndpointGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 738 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 739 740 hds = append(c.xGoogHeaders, hds...) 741 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 742 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 743 var resp *longrunningpb.Operation 744 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 745 var err error 746 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 747 return err 748 }, opts...) 749 if err != nil { 750 return nil, err 751 } 752 return resp, nil 753 } 754 755 func (c *indexEndpointGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 756 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 757 758 hds = append(c.xGoogHeaders, hds...) 759 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 760 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 761 it := &OperationIterator{} 762 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 763 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 764 resp := &longrunningpb.ListOperationsResponse{} 765 if pageToken != "" { 766 req.PageToken = pageToken 767 } 768 if pageSize > math.MaxInt32 { 769 req.PageSize = math.MaxInt32 770 } else if pageSize != 0 { 771 req.PageSize = int32(pageSize) 772 } 773 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 774 var err error 775 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 776 return err 777 }, opts...) 778 if err != nil { 779 return nil, "", err 780 } 781 782 it.Response = resp 783 return resp.GetOperations(), resp.GetNextPageToken(), nil 784 } 785 fetch := func(pageSize int, pageToken string) (string, error) { 786 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 787 if err != nil { 788 return "", err 789 } 790 it.items = append(it.items, items...) 791 return nextPageToken, nil 792 } 793 794 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 795 it.pageInfo.MaxSize = int(req.GetPageSize()) 796 it.pageInfo.Token = req.GetPageToken() 797 798 return it 799 } 800 801 func (c *indexEndpointGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 802 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 803 804 hds = append(c.xGoogHeaders, hds...) 805 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 806 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 807 var resp *longrunningpb.Operation 808 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 809 var err error 810 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 811 return err 812 }, opts...) 813 if err != nil { 814 return nil, err 815 } 816 return resp, nil 817 } 818 819 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name. 820 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process. 821 func (c *indexEndpointGRPCClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation { 822 return &CreateIndexEndpointOperation{ 823 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 824 } 825 } 826 827 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name. 828 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process. 829 func (c *indexEndpointGRPCClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation { 830 return &DeleteIndexEndpointOperation{ 831 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 832 } 833 } 834 835 // DeployIndexOperation returns a new DeployIndexOperation from a given name. 836 // The name must be that of a previously created DeployIndexOperation, possibly from a different process. 837 func (c *indexEndpointGRPCClient) DeployIndexOperation(name string) *DeployIndexOperation { 838 return &DeployIndexOperation{ 839 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 840 } 841 } 842 843 // MutateDeployedIndexOperation returns a new MutateDeployedIndexOperation from a given name. 844 // The name must be that of a previously created MutateDeployedIndexOperation, possibly from a different process. 845 func (c *indexEndpointGRPCClient) MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation { 846 return &MutateDeployedIndexOperation{ 847 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 848 } 849 } 850 851 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name. 852 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process. 853 func (c *indexEndpointGRPCClient) UndeployIndexOperation(name string) *UndeployIndexOperation { 854 return &UndeployIndexOperation{ 855 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 856 } 857 }