cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/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 "bytes" 21 "context" 22 "fmt" 23 "log/slog" 24 "math" 25 "net/http" 26 "net/url" 27 "time" 28 29 aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb" 30 iampb "cloud.google.com/go/iam/apiv1/iampb" 31 "cloud.google.com/go/longrunning" 32 lroauto "cloud.google.com/go/longrunning/autogen" 33 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 34 gax "github.com/googleapis/gax-go/v2" 35 "google.golang.org/api/iterator" 36 "google.golang.org/api/option" 37 "google.golang.org/api/option/internaloption" 38 gtransport "google.golang.org/api/transport/grpc" 39 httptransport "google.golang.org/api/transport/http" 40 locationpb "google.golang.org/genproto/googleapis/cloud/location" 41 "google.golang.org/grpc" 42 "google.golang.org/protobuf/encoding/protojson" 43 "google.golang.org/protobuf/proto" 44 ) 45 46 var newIndexEndpointClientHook clientHook 47 48 // IndexEndpointCallOptions contains the retry settings for each method of IndexEndpointClient. 49 type IndexEndpointCallOptions struct { 50 CreateIndexEndpoint []gax.CallOption 51 GetIndexEndpoint []gax.CallOption 52 ListIndexEndpoints []gax.CallOption 53 UpdateIndexEndpoint []gax.CallOption 54 DeleteIndexEndpoint []gax.CallOption 55 DeployIndex []gax.CallOption 56 UndeployIndex []gax.CallOption 57 MutateDeployedIndex []gax.CallOption 58 GetLocation []gax.CallOption 59 ListLocations []gax.CallOption 60 GetIamPolicy []gax.CallOption 61 SetIamPolicy []gax.CallOption 62 TestIamPermissions []gax.CallOption 63 CancelOperation []gax.CallOption 64 DeleteOperation []gax.CallOption 65 GetOperation []gax.CallOption 66 ListOperations []gax.CallOption 67 WaitOperation []gax.CallOption 68 } 69 70 func defaultIndexEndpointGRPCClientOptions() []option.ClientOption { 71 return []option.ClientOption{ 72 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 73 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 74 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 75 internaloption.WithDefaultUniverseDomain("googleapis.com"), 76 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 77 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 78 internaloption.EnableJwtWithScope(), 79 internaloption.EnableNewAuthLibrary(), 80 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 81 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 82 } 83 } 84 85 func defaultIndexEndpointCallOptions() *IndexEndpointCallOptions { 86 return &IndexEndpointCallOptions{ 87 CreateIndexEndpoint: []gax.CallOption{ 88 gax.WithTimeout(5000 * time.Millisecond), 89 }, 90 GetIndexEndpoint: []gax.CallOption{ 91 gax.WithTimeout(5000 * time.Millisecond), 92 }, 93 ListIndexEndpoints: []gax.CallOption{ 94 gax.WithTimeout(5000 * time.Millisecond), 95 }, 96 UpdateIndexEndpoint: []gax.CallOption{ 97 gax.WithTimeout(5000 * time.Millisecond), 98 }, 99 DeleteIndexEndpoint: []gax.CallOption{ 100 gax.WithTimeout(5000 * time.Millisecond), 101 }, 102 DeployIndex: []gax.CallOption{ 103 gax.WithTimeout(5000 * time.Millisecond), 104 }, 105 UndeployIndex: []gax.CallOption{ 106 gax.WithTimeout(5000 * time.Millisecond), 107 }, 108 MutateDeployedIndex: []gax.CallOption{}, 109 GetLocation: []gax.CallOption{}, 110 ListLocations: []gax.CallOption{}, 111 GetIamPolicy: []gax.CallOption{}, 112 SetIamPolicy: []gax.CallOption{}, 113 TestIamPermissions: []gax.CallOption{}, 114 CancelOperation: []gax.CallOption{}, 115 DeleteOperation: []gax.CallOption{}, 116 GetOperation: []gax.CallOption{}, 117 ListOperations: []gax.CallOption{}, 118 WaitOperation: []gax.CallOption{}, 119 } 120 } 121 122 func defaultIndexEndpointRESTCallOptions() *IndexEndpointCallOptions { 123 return &IndexEndpointCallOptions{ 124 CreateIndexEndpoint: []gax.CallOption{ 125 gax.WithTimeout(5000 * time.Millisecond), 126 }, 127 GetIndexEndpoint: []gax.CallOption{ 128 gax.WithTimeout(5000 * time.Millisecond), 129 }, 130 ListIndexEndpoints: []gax.CallOption{ 131 gax.WithTimeout(5000 * time.Millisecond), 132 }, 133 UpdateIndexEndpoint: []gax.CallOption{ 134 gax.WithTimeout(5000 * time.Millisecond), 135 }, 136 DeleteIndexEndpoint: []gax.CallOption{ 137 gax.WithTimeout(5000 * time.Millisecond), 138 }, 139 DeployIndex: []gax.CallOption{ 140 gax.WithTimeout(5000 * time.Millisecond), 141 }, 142 UndeployIndex: []gax.CallOption{ 143 gax.WithTimeout(5000 * time.Millisecond), 144 }, 145 MutateDeployedIndex: []gax.CallOption{}, 146 GetLocation: []gax.CallOption{}, 147 ListLocations: []gax.CallOption{}, 148 GetIamPolicy: []gax.CallOption{}, 149 SetIamPolicy: []gax.CallOption{}, 150 TestIamPermissions: []gax.CallOption{}, 151 CancelOperation: []gax.CallOption{}, 152 DeleteOperation: []gax.CallOption{}, 153 GetOperation: []gax.CallOption{}, 154 ListOperations: []gax.CallOption{}, 155 WaitOperation: []gax.CallOption{}, 156 } 157 } 158 159 // internalIndexEndpointClient is an interface that defines the methods available from Vertex AI API. 160 type internalIndexEndpointClient interface { 161 Close() error 162 setGoogleClientInfo(...string) 163 Connection() *grpc.ClientConn 164 CreateIndexEndpoint(context.Context, *aiplatformpb.CreateIndexEndpointRequest, ...gax.CallOption) (*CreateIndexEndpointOperation, error) 165 CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation 166 GetIndexEndpoint(context.Context, *aiplatformpb.GetIndexEndpointRequest, ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) 167 ListIndexEndpoints(context.Context, *aiplatformpb.ListIndexEndpointsRequest, ...gax.CallOption) *IndexEndpointIterator 168 UpdateIndexEndpoint(context.Context, *aiplatformpb.UpdateIndexEndpointRequest, ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) 169 DeleteIndexEndpoint(context.Context, *aiplatformpb.DeleteIndexEndpointRequest, ...gax.CallOption) (*DeleteIndexEndpointOperation, error) 170 DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation 171 DeployIndex(context.Context, *aiplatformpb.DeployIndexRequest, ...gax.CallOption) (*DeployIndexOperation, error) 172 DeployIndexOperation(name string) *DeployIndexOperation 173 UndeployIndex(context.Context, *aiplatformpb.UndeployIndexRequest, ...gax.CallOption) (*UndeployIndexOperation, error) 174 UndeployIndexOperation(name string) *UndeployIndexOperation 175 MutateDeployedIndex(context.Context, *aiplatformpb.MutateDeployedIndexRequest, ...gax.CallOption) (*MutateDeployedIndexOperation, error) 176 MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation 177 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 178 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 179 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 180 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 181 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 182 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 183 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 184 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 185 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 186 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 187 } 188 189 // IndexEndpointClient is a client for interacting with Vertex AI API. 190 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 191 // 192 // A service for managing Vertex AI’s IndexEndpoints. 193 type IndexEndpointClient struct { 194 // The internal transport-dependent client. 195 internalClient internalIndexEndpointClient 196 197 // The call options for this service. 198 CallOptions *IndexEndpointCallOptions 199 200 // LROClient is used internally to handle long-running operations. 201 // It is exposed so that its CallOptions can be modified if required. 202 // Users should not Close this client. 203 LROClient *lroauto.OperationsClient 204 } 205 206 // Wrapper methods routed to the internal client. 207 208 // Close closes the connection to the API service. The user should invoke this when 209 // the client is no longer required. 210 func (c *IndexEndpointClient) Close() error { 211 return c.internalClient.Close() 212 } 213 214 // setGoogleClientInfo sets the name and version of the application in 215 // the `x-goog-api-client` header passed on each request. Intended for 216 // use by Google-written clients. 217 func (c *IndexEndpointClient) setGoogleClientInfo(keyval ...string) { 218 c.internalClient.setGoogleClientInfo(keyval...) 219 } 220 221 // Connection returns a connection to the API service. 222 // 223 // Deprecated: Connections are now pooled so this method does not always 224 // return the same resource. 225 func (c *IndexEndpointClient) Connection() *grpc.ClientConn { 226 return c.internalClient.Connection() 227 } 228 229 // CreateIndexEndpoint creates an IndexEndpoint. 230 func (c *IndexEndpointClient) CreateIndexEndpoint(ctx context.Context, req *aiplatformpb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) { 231 return c.internalClient.CreateIndexEndpoint(ctx, req, opts...) 232 } 233 234 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name. 235 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process. 236 func (c *IndexEndpointClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation { 237 return c.internalClient.CreateIndexEndpointOperation(name) 238 } 239 240 // GetIndexEndpoint gets an IndexEndpoint. 241 func (c *IndexEndpointClient) GetIndexEndpoint(ctx context.Context, req *aiplatformpb.GetIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 242 return c.internalClient.GetIndexEndpoint(ctx, req, opts...) 243 } 244 245 // ListIndexEndpoints lists IndexEndpoints in a Location. 246 func (c *IndexEndpointClient) ListIndexEndpoints(ctx context.Context, req *aiplatformpb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator { 247 return c.internalClient.ListIndexEndpoints(ctx, req, opts...) 248 } 249 250 // UpdateIndexEndpoint updates an IndexEndpoint. 251 func (c *IndexEndpointClient) UpdateIndexEndpoint(ctx context.Context, req *aiplatformpb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 252 return c.internalClient.UpdateIndexEndpoint(ctx, req, opts...) 253 } 254 255 // DeleteIndexEndpoint deletes an IndexEndpoint. 256 func (c *IndexEndpointClient) DeleteIndexEndpoint(ctx context.Context, req *aiplatformpb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) { 257 return c.internalClient.DeleteIndexEndpoint(ctx, req, opts...) 258 } 259 260 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name. 261 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process. 262 func (c *IndexEndpointClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation { 263 return c.internalClient.DeleteIndexEndpointOperation(name) 264 } 265 266 // DeployIndex deploys an Index into this IndexEndpoint, creating a DeployedIndex within 267 // it. 268 // Only non-empty Indexes can be deployed. 269 func (c *IndexEndpointClient) DeployIndex(ctx context.Context, req *aiplatformpb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) { 270 return c.internalClient.DeployIndex(ctx, req, opts...) 271 } 272 273 // DeployIndexOperation returns a new DeployIndexOperation from a given name. 274 // The name must be that of a previously created DeployIndexOperation, possibly from a different process. 275 func (c *IndexEndpointClient) DeployIndexOperation(name string) *DeployIndexOperation { 276 return c.internalClient.DeployIndexOperation(name) 277 } 278 279 // UndeployIndex undeploys an Index from an IndexEndpoint, removing a DeployedIndex from it, 280 // and freeing all resources it’s using. 281 func (c *IndexEndpointClient) UndeployIndex(ctx context.Context, req *aiplatformpb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) { 282 return c.internalClient.UndeployIndex(ctx, req, opts...) 283 } 284 285 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name. 286 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process. 287 func (c *IndexEndpointClient) UndeployIndexOperation(name string) *UndeployIndexOperation { 288 return c.internalClient.UndeployIndexOperation(name) 289 } 290 291 // MutateDeployedIndex update an existing DeployedIndex under an IndexEndpoint. 292 func (c *IndexEndpointClient) MutateDeployedIndex(ctx context.Context, req *aiplatformpb.MutateDeployedIndexRequest, opts ...gax.CallOption) (*MutateDeployedIndexOperation, error) { 293 return c.internalClient.MutateDeployedIndex(ctx, req, opts...) 294 } 295 296 // MutateDeployedIndexOperation returns a new MutateDeployedIndexOperation from a given name. 297 // The name must be that of a previously created MutateDeployedIndexOperation, possibly from a different process. 298 func (c *IndexEndpointClient) MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation { 299 return c.internalClient.MutateDeployedIndexOperation(name) 300 } 301 302 // GetLocation gets information about a location. 303 func (c *IndexEndpointClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 304 return c.internalClient.GetLocation(ctx, req, opts...) 305 } 306 307 // ListLocations lists information about the supported locations for this service. 308 func (c *IndexEndpointClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 309 return c.internalClient.ListLocations(ctx, req, opts...) 310 } 311 312 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 313 // if the resource exists and does not have a policy set. 314 func (c *IndexEndpointClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 315 return c.internalClient.GetIamPolicy(ctx, req, opts...) 316 } 317 318 // SetIamPolicy sets the access control policy on the specified resource. Replaces 319 // any existing policy. 320 // 321 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 322 // errors. 323 func (c *IndexEndpointClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 324 return c.internalClient.SetIamPolicy(ctx, req, opts...) 325 } 326 327 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 328 // resource does not exist, this will return an empty set of 329 // permissions, not a NOT_FOUND error. 330 // 331 // Note: This operation is designed to be used for building 332 // permission-aware UIs and command-line tools, not for authorization 333 // checking. This operation may “fail open” without warning. 334 func (c *IndexEndpointClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 335 return c.internalClient.TestIamPermissions(ctx, req, opts...) 336 } 337 338 // CancelOperation is a utility method from google.longrunning.Operations. 339 func (c *IndexEndpointClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 340 return c.internalClient.CancelOperation(ctx, req, opts...) 341 } 342 343 // DeleteOperation is a utility method from google.longrunning.Operations. 344 func (c *IndexEndpointClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 345 return c.internalClient.DeleteOperation(ctx, req, opts...) 346 } 347 348 // GetOperation is a utility method from google.longrunning.Operations. 349 func (c *IndexEndpointClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 350 return c.internalClient.GetOperation(ctx, req, opts...) 351 } 352 353 // ListOperations is a utility method from google.longrunning.Operations. 354 func (c *IndexEndpointClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 355 return c.internalClient.ListOperations(ctx, req, opts...) 356 } 357 358 // WaitOperation is a utility method from google.longrunning.Operations. 359 func (c *IndexEndpointClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 360 return c.internalClient.WaitOperation(ctx, req, opts...) 361 } 362 363 // indexEndpointGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 364 // 365 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 366 type indexEndpointGRPCClient struct { 367 // Connection pool of gRPC connections to the service. 368 connPool gtransport.ConnPool 369 370 // Points back to the CallOptions field of the containing IndexEndpointClient 371 CallOptions **IndexEndpointCallOptions 372 373 // The gRPC API client. 374 indexEndpointClient aiplatformpb.IndexEndpointServiceClient 375 376 // LROClient is used internally to handle long-running operations. 377 // It is exposed so that its CallOptions can be modified if required. 378 // Users should not Close this client. 379 LROClient **lroauto.OperationsClient 380 381 operationsClient longrunningpb.OperationsClient 382 383 iamPolicyClient iampb.IAMPolicyClient 384 385 locationsClient locationpb.LocationsClient 386 387 // The x-goog-* metadata to be sent with each request. 388 xGoogHeaders []string 389 390 logger *slog.Logger 391 } 392 393 // NewIndexEndpointClient creates a new index endpoint service client based on gRPC. 394 // The returned client must be Closed when it is done being used to clean up its underlying connections. 395 // 396 // A service for managing Vertex AI’s IndexEndpoints. 397 func NewIndexEndpointClient(ctx context.Context, opts ...option.ClientOption) (*IndexEndpointClient, error) { 398 clientOpts := defaultIndexEndpointGRPCClientOptions() 399 if newIndexEndpointClientHook != nil { 400 hookOpts, err := newIndexEndpointClientHook(ctx, clientHookParams{}) 401 if err != nil { 402 return nil, err 403 } 404 clientOpts = append(clientOpts, hookOpts...) 405 } 406 407 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 408 if err != nil { 409 return nil, err 410 } 411 client := IndexEndpointClient{CallOptions: defaultIndexEndpointCallOptions()} 412 413 c := &indexEndpointGRPCClient{ 414 connPool: connPool, 415 indexEndpointClient: aiplatformpb.NewIndexEndpointServiceClient(connPool), 416 CallOptions: &client.CallOptions, 417 logger: internaloption.GetLogger(opts), 418 operationsClient: longrunningpb.NewOperationsClient(connPool), 419 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 420 locationsClient: locationpb.NewLocationsClient(connPool), 421 } 422 c.setGoogleClientInfo() 423 424 client.internalClient = c 425 426 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 427 if err != nil { 428 // This error "should not happen", since we are just reusing old connection pool 429 // and never actually need to dial. 430 // If this does happen, we could leak connp. However, we cannot close conn: 431 // If the user invoked the constructor with option.WithGRPCConn, 432 // we would close a connection that's still in use. 433 // TODO: investigate error conditions. 434 return nil, err 435 } 436 c.LROClient = &client.LROClient 437 return &client, nil 438 } 439 440 // Connection returns a connection to the API service. 441 // 442 // Deprecated: Connections are now pooled so this method does not always 443 // return the same resource. 444 func (c *indexEndpointGRPCClient) Connection() *grpc.ClientConn { 445 return c.connPool.Conn() 446 } 447 448 // setGoogleClientInfo sets the name and version of the application in 449 // the `x-goog-api-client` header passed on each request. Intended for 450 // use by Google-written clients. 451 func (c *indexEndpointGRPCClient) setGoogleClientInfo(keyval ...string) { 452 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 453 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 454 c.xGoogHeaders = []string{ 455 "x-goog-api-client", gax.XGoogHeader(kv...), 456 } 457 } 458 459 // Close closes the connection to the API service. The user should invoke this when 460 // the client is no longer required. 461 func (c *indexEndpointGRPCClient) Close() error { 462 return c.connPool.Close() 463 } 464 465 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 466 type indexEndpointRESTClient struct { 467 // The http endpoint to connect to. 468 endpoint string 469 470 // The http client. 471 httpClient *http.Client 472 473 // LROClient is used internally to handle long-running operations. 474 // It is exposed so that its CallOptions can be modified if required. 475 // Users should not Close this client. 476 LROClient **lroauto.OperationsClient 477 478 // The x-goog-* headers to be sent with each request. 479 xGoogHeaders []string 480 481 // Points back to the CallOptions field of the containing IndexEndpointClient 482 CallOptions **IndexEndpointCallOptions 483 484 logger *slog.Logger 485 } 486 487 // NewIndexEndpointRESTClient creates a new index endpoint service rest client. 488 // 489 // A service for managing Vertex AI’s IndexEndpoints. 490 func NewIndexEndpointRESTClient(ctx context.Context, opts ...option.ClientOption) (*IndexEndpointClient, error) { 491 clientOpts := append(defaultIndexEndpointRESTClientOptions(), opts...) 492 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) 493 if err != nil { 494 return nil, err 495 } 496 497 callOpts := defaultIndexEndpointRESTCallOptions() 498 c := &indexEndpointRESTClient{ 499 endpoint: endpoint, 500 httpClient: httpClient, 501 CallOptions: &callOpts, 502 logger: internaloption.GetLogger(opts), 503 } 504 c.setGoogleClientInfo() 505 506 lroOpts := []option.ClientOption{ 507 option.WithHTTPClient(httpClient), 508 option.WithEndpoint(endpoint), 509 } 510 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...) 511 if err != nil { 512 return nil, err 513 } 514 c.LROClient = &opClient 515 516 return &IndexEndpointClient{internalClient: c, CallOptions: callOpts}, nil 517 } 518 519 func defaultIndexEndpointRESTClientOptions() []option.ClientOption { 520 return []option.ClientOption{ 521 internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"), 522 internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"), 523 internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"), 524 internaloption.WithDefaultUniverseDomain("googleapis.com"), 525 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 526 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 527 internaloption.EnableNewAuthLibrary(), 528 } 529 } 530 531 // setGoogleClientInfo sets the name and version of the application in 532 // the `x-goog-api-client` header passed on each request. Intended for 533 // use by Google-written clients. 534 func (c *indexEndpointRESTClient) setGoogleClientInfo(keyval ...string) { 535 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 536 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) 537 c.xGoogHeaders = []string{ 538 "x-goog-api-client", gax.XGoogHeader(kv...), 539 } 540 } 541 542 // Close closes the connection to the API service. The user should invoke this when 543 // the client is no longer required. 544 func (c *indexEndpointRESTClient) Close() error { 545 // Replace httpClient with nil to force cleanup. 546 c.httpClient = nil 547 return nil 548 } 549 550 // Connection returns a connection to the API service. 551 // 552 // Deprecated: This method always returns nil. 553 func (c *indexEndpointRESTClient) Connection() *grpc.ClientConn { 554 return nil 555 } 556 func (c *indexEndpointGRPCClient) CreateIndexEndpoint(ctx context.Context, req *aiplatformpb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) { 557 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 558 559 hds = append(c.xGoogHeaders, hds...) 560 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 561 opts = append((*c.CallOptions).CreateIndexEndpoint[0:len((*c.CallOptions).CreateIndexEndpoint):len((*c.CallOptions).CreateIndexEndpoint)], opts...) 562 var resp *longrunningpb.Operation 563 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 564 var err error 565 resp, err = executeRPC(ctx, c.indexEndpointClient.CreateIndexEndpoint, req, settings.GRPC, c.logger, "CreateIndexEndpoint") 566 return err 567 }, opts...) 568 if err != nil { 569 return nil, err 570 } 571 return &CreateIndexEndpointOperation{ 572 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 573 }, nil 574 } 575 576 func (c *indexEndpointGRPCClient) GetIndexEndpoint(ctx context.Context, req *aiplatformpb.GetIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 577 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 578 579 hds = append(c.xGoogHeaders, hds...) 580 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 581 opts = append((*c.CallOptions).GetIndexEndpoint[0:len((*c.CallOptions).GetIndexEndpoint):len((*c.CallOptions).GetIndexEndpoint)], opts...) 582 var resp *aiplatformpb.IndexEndpoint 583 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 584 var err error 585 resp, err = executeRPC(ctx, c.indexEndpointClient.GetIndexEndpoint, req, settings.GRPC, c.logger, "GetIndexEndpoint") 586 return err 587 }, opts...) 588 if err != nil { 589 return nil, err 590 } 591 return resp, nil 592 } 593 594 func (c *indexEndpointGRPCClient) ListIndexEndpoints(ctx context.Context, req *aiplatformpb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator { 595 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 596 597 hds = append(c.xGoogHeaders, hds...) 598 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 599 opts = append((*c.CallOptions).ListIndexEndpoints[0:len((*c.CallOptions).ListIndexEndpoints):len((*c.CallOptions).ListIndexEndpoints)], opts...) 600 it := &IndexEndpointIterator{} 601 req = proto.Clone(req).(*aiplatformpb.ListIndexEndpointsRequest) 602 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.IndexEndpoint, string, error) { 603 resp := &aiplatformpb.ListIndexEndpointsResponse{} 604 if pageToken != "" { 605 req.PageToken = pageToken 606 } 607 if pageSize > math.MaxInt32 { 608 req.PageSize = math.MaxInt32 609 } else if pageSize != 0 { 610 req.PageSize = int32(pageSize) 611 } 612 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 613 var err error 614 resp, err = executeRPC(ctx, c.indexEndpointClient.ListIndexEndpoints, req, settings.GRPC, c.logger, "ListIndexEndpoints") 615 return err 616 }, opts...) 617 if err != nil { 618 return nil, "", err 619 } 620 621 it.Response = resp 622 return resp.GetIndexEndpoints(), resp.GetNextPageToken(), nil 623 } 624 fetch := func(pageSize int, pageToken string) (string, error) { 625 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 626 if err != nil { 627 return "", err 628 } 629 it.items = append(it.items, items...) 630 return nextPageToken, nil 631 } 632 633 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 634 it.pageInfo.MaxSize = int(req.GetPageSize()) 635 it.pageInfo.Token = req.GetPageToken() 636 637 return it 638 } 639 640 func (c *indexEndpointGRPCClient) UpdateIndexEndpoint(ctx context.Context, req *aiplatformpb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 641 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint.name", url.QueryEscape(req.GetIndexEndpoint().GetName()))} 642 643 hds = append(c.xGoogHeaders, hds...) 644 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 645 opts = append((*c.CallOptions).UpdateIndexEndpoint[0:len((*c.CallOptions).UpdateIndexEndpoint):len((*c.CallOptions).UpdateIndexEndpoint)], opts...) 646 var resp *aiplatformpb.IndexEndpoint 647 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 648 var err error 649 resp, err = executeRPC(ctx, c.indexEndpointClient.UpdateIndexEndpoint, req, settings.GRPC, c.logger, "UpdateIndexEndpoint") 650 return err 651 }, opts...) 652 if err != nil { 653 return nil, err 654 } 655 return resp, nil 656 } 657 658 func (c *indexEndpointGRPCClient) DeleteIndexEndpoint(ctx context.Context, req *aiplatformpb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) { 659 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 660 661 hds = append(c.xGoogHeaders, hds...) 662 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 663 opts = append((*c.CallOptions).DeleteIndexEndpoint[0:len((*c.CallOptions).DeleteIndexEndpoint):len((*c.CallOptions).DeleteIndexEndpoint)], opts...) 664 var resp *longrunningpb.Operation 665 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 666 var err error 667 resp, err = executeRPC(ctx, c.indexEndpointClient.DeleteIndexEndpoint, req, settings.GRPC, c.logger, "DeleteIndexEndpoint") 668 return err 669 }, opts...) 670 if err != nil { 671 return nil, err 672 } 673 return &DeleteIndexEndpointOperation{ 674 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 675 }, nil 676 } 677 678 func (c *indexEndpointGRPCClient) DeployIndex(ctx context.Context, req *aiplatformpb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) { 679 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 680 681 hds = append(c.xGoogHeaders, hds...) 682 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 683 opts = append((*c.CallOptions).DeployIndex[0:len((*c.CallOptions).DeployIndex):len((*c.CallOptions).DeployIndex)], opts...) 684 var resp *longrunningpb.Operation 685 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 686 var err error 687 resp, err = executeRPC(ctx, c.indexEndpointClient.DeployIndex, req, settings.GRPC, c.logger, "DeployIndex") 688 return err 689 }, opts...) 690 if err != nil { 691 return nil, err 692 } 693 return &DeployIndexOperation{ 694 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 695 }, nil 696 } 697 698 func (c *indexEndpointGRPCClient) UndeployIndex(ctx context.Context, req *aiplatformpb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) { 699 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 700 701 hds = append(c.xGoogHeaders, hds...) 702 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 703 opts = append((*c.CallOptions).UndeployIndex[0:len((*c.CallOptions).UndeployIndex):len((*c.CallOptions).UndeployIndex)], opts...) 704 var resp *longrunningpb.Operation 705 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 706 var err error 707 resp, err = executeRPC(ctx, c.indexEndpointClient.UndeployIndex, req, settings.GRPC, c.logger, "UndeployIndex") 708 return err 709 }, opts...) 710 if err != nil { 711 return nil, err 712 } 713 return &UndeployIndexOperation{ 714 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 715 }, nil 716 } 717 718 func (c *indexEndpointGRPCClient) MutateDeployedIndex(ctx context.Context, req *aiplatformpb.MutateDeployedIndexRequest, opts ...gax.CallOption) (*MutateDeployedIndexOperation, error) { 719 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 720 721 hds = append(c.xGoogHeaders, hds...) 722 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 723 opts = append((*c.CallOptions).MutateDeployedIndex[0:len((*c.CallOptions).MutateDeployedIndex):len((*c.CallOptions).MutateDeployedIndex)], opts...) 724 var resp *longrunningpb.Operation 725 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 726 var err error 727 resp, err = executeRPC(ctx, c.indexEndpointClient.MutateDeployedIndex, req, settings.GRPC, c.logger, "MutateDeployedIndex") 728 return err 729 }, opts...) 730 if err != nil { 731 return nil, err 732 } 733 return &MutateDeployedIndexOperation{ 734 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 735 }, nil 736 } 737 738 func (c *indexEndpointGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 739 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 740 741 hds = append(c.xGoogHeaders, hds...) 742 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 743 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 744 var resp *locationpb.Location 745 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 746 var err error 747 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 748 return err 749 }, opts...) 750 if err != nil { 751 return nil, err 752 } 753 return resp, nil 754 } 755 756 func (c *indexEndpointGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 757 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 758 759 hds = append(c.xGoogHeaders, hds...) 760 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 761 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 762 it := &LocationIterator{} 763 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 764 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 765 resp := &locationpb.ListLocationsResponse{} 766 if pageToken != "" { 767 req.PageToken = pageToken 768 } 769 if pageSize > math.MaxInt32 { 770 req.PageSize = math.MaxInt32 771 } else if pageSize != 0 { 772 req.PageSize = int32(pageSize) 773 } 774 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 775 var err error 776 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 777 return err 778 }, opts...) 779 if err != nil { 780 return nil, "", err 781 } 782 783 it.Response = resp 784 return resp.GetLocations(), resp.GetNextPageToken(), nil 785 } 786 fetch := func(pageSize int, pageToken string) (string, error) { 787 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 788 if err != nil { 789 return "", err 790 } 791 it.items = append(it.items, items...) 792 return nextPageToken, nil 793 } 794 795 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 796 it.pageInfo.MaxSize = int(req.GetPageSize()) 797 it.pageInfo.Token = req.GetPageToken() 798 799 return it 800 } 801 802 func (c *indexEndpointGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 803 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 804 805 hds = append(c.xGoogHeaders, hds...) 806 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 807 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 808 var resp *iampb.Policy 809 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 810 var err error 811 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 812 return err 813 }, opts...) 814 if err != nil { 815 return nil, err 816 } 817 return resp, nil 818 } 819 820 func (c *indexEndpointGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 821 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 822 823 hds = append(c.xGoogHeaders, hds...) 824 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 825 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 826 var resp *iampb.Policy 827 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 828 var err error 829 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 830 return err 831 }, opts...) 832 if err != nil { 833 return nil, err 834 } 835 return resp, nil 836 } 837 838 func (c *indexEndpointGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 839 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 840 841 hds = append(c.xGoogHeaders, hds...) 842 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 843 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 844 var resp *iampb.TestIamPermissionsResponse 845 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 846 var err error 847 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 848 return err 849 }, opts...) 850 if err != nil { 851 return nil, err 852 } 853 return resp, nil 854 } 855 856 func (c *indexEndpointGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 857 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 858 859 hds = append(c.xGoogHeaders, hds...) 860 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 861 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 862 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 863 var err error 864 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 865 return err 866 }, opts...) 867 return err 868 } 869 870 func (c *indexEndpointGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 871 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 872 873 hds = append(c.xGoogHeaders, hds...) 874 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 875 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 876 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 877 var err error 878 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 879 return err 880 }, opts...) 881 return err 882 } 883 884 func (c *indexEndpointGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 885 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 886 887 hds = append(c.xGoogHeaders, hds...) 888 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 889 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 890 var resp *longrunningpb.Operation 891 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 892 var err error 893 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 894 return err 895 }, opts...) 896 if err != nil { 897 return nil, err 898 } 899 return resp, nil 900 } 901 902 func (c *indexEndpointGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 903 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 904 905 hds = append(c.xGoogHeaders, hds...) 906 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 907 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 908 it := &OperationIterator{} 909 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 910 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 911 resp := &longrunningpb.ListOperationsResponse{} 912 if pageToken != "" { 913 req.PageToken = pageToken 914 } 915 if pageSize > math.MaxInt32 { 916 req.PageSize = math.MaxInt32 917 } else if pageSize != 0 { 918 req.PageSize = int32(pageSize) 919 } 920 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 921 var err error 922 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 923 return err 924 }, opts...) 925 if err != nil { 926 return nil, "", err 927 } 928 929 it.Response = resp 930 return resp.GetOperations(), resp.GetNextPageToken(), nil 931 } 932 fetch := func(pageSize int, pageToken string) (string, error) { 933 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 934 if err != nil { 935 return "", err 936 } 937 it.items = append(it.items, items...) 938 return nextPageToken, nil 939 } 940 941 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 942 it.pageInfo.MaxSize = int(req.GetPageSize()) 943 it.pageInfo.Token = req.GetPageToken() 944 945 return it 946 } 947 948 func (c *indexEndpointGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 949 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 950 951 hds = append(c.xGoogHeaders, hds...) 952 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 953 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 954 var resp *longrunningpb.Operation 955 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 956 var err error 957 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 958 return err 959 }, opts...) 960 if err != nil { 961 return nil, err 962 } 963 return resp, nil 964 } 965 966 // CreateIndexEndpoint creates an IndexEndpoint. 967 func (c *indexEndpointRESTClient) CreateIndexEndpoint(ctx context.Context, req *aiplatformpb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) { 968 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 969 body := req.GetIndexEndpoint() 970 jsonReq, err := m.Marshal(body) 971 if err != nil { 972 return nil, err 973 } 974 975 baseUrl, err := url.Parse(c.endpoint) 976 if err != nil { 977 return nil, err 978 } 979 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/indexEndpoints", req.GetParent()) 980 981 params := url.Values{} 982 params.Add("$alt", "json;enum-encoding=int") 983 984 baseUrl.RawQuery = params.Encode() 985 986 // Build HTTP headers from client and context metadata. 987 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 988 989 hds = append(c.xGoogHeaders, hds...) 990 hds = append(hds, "Content-Type", "application/json") 991 headers := gax.BuildHeaders(ctx, hds...) 992 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 993 resp := &longrunningpb.Operation{} 994 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 995 if settings.Path != "" { 996 baseUrl.Path = settings.Path 997 } 998 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 999 if err != nil { 1000 return err 1001 } 1002 httpReq = httpReq.WithContext(ctx) 1003 httpReq.Header = headers 1004 1005 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateIndexEndpoint") 1006 if err != nil { 1007 return err 1008 } 1009 if err := unm.Unmarshal(buf, resp); err != nil { 1010 return err 1011 } 1012 1013 return nil 1014 }, opts...) 1015 if e != nil { 1016 return nil, e 1017 } 1018 1019 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1020 return &CreateIndexEndpointOperation{ 1021 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1022 pollPath: override, 1023 }, nil 1024 } 1025 1026 // GetIndexEndpoint gets an IndexEndpoint. 1027 func (c *indexEndpointRESTClient) GetIndexEndpoint(ctx context.Context, req *aiplatformpb.GetIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 1028 baseUrl, err := url.Parse(c.endpoint) 1029 if err != nil { 1030 return nil, err 1031 } 1032 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1033 1034 params := url.Values{} 1035 params.Add("$alt", "json;enum-encoding=int") 1036 1037 baseUrl.RawQuery = params.Encode() 1038 1039 // Build HTTP headers from client and context metadata. 1040 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1041 1042 hds = append(c.xGoogHeaders, hds...) 1043 hds = append(hds, "Content-Type", "application/json") 1044 headers := gax.BuildHeaders(ctx, hds...) 1045 opts = append((*c.CallOptions).GetIndexEndpoint[0:len((*c.CallOptions).GetIndexEndpoint):len((*c.CallOptions).GetIndexEndpoint)], opts...) 1046 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1047 resp := &aiplatformpb.IndexEndpoint{} 1048 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1049 if settings.Path != "" { 1050 baseUrl.Path = settings.Path 1051 } 1052 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1053 if err != nil { 1054 return err 1055 } 1056 httpReq = httpReq.WithContext(ctx) 1057 httpReq.Header = headers 1058 1059 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIndexEndpoint") 1060 if err != nil { 1061 return err 1062 } 1063 1064 if err := unm.Unmarshal(buf, resp); err != nil { 1065 return err 1066 } 1067 1068 return nil 1069 }, opts...) 1070 if e != nil { 1071 return nil, e 1072 } 1073 return resp, nil 1074 } 1075 1076 // ListIndexEndpoints lists IndexEndpoints in a Location. 1077 func (c *indexEndpointRESTClient) ListIndexEndpoints(ctx context.Context, req *aiplatformpb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator { 1078 it := &IndexEndpointIterator{} 1079 req = proto.Clone(req).(*aiplatformpb.ListIndexEndpointsRequest) 1080 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1081 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.IndexEndpoint, string, error) { 1082 resp := &aiplatformpb.ListIndexEndpointsResponse{} 1083 if pageToken != "" { 1084 req.PageToken = pageToken 1085 } 1086 if pageSize > math.MaxInt32 { 1087 req.PageSize = math.MaxInt32 1088 } else if pageSize != 0 { 1089 req.PageSize = int32(pageSize) 1090 } 1091 baseUrl, err := url.Parse(c.endpoint) 1092 if err != nil { 1093 return nil, "", err 1094 } 1095 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/indexEndpoints", req.GetParent()) 1096 1097 params := url.Values{} 1098 params.Add("$alt", "json;enum-encoding=int") 1099 if req.GetFilter() != "" { 1100 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1101 } 1102 if req.GetPageSize() != 0 { 1103 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1104 } 1105 if req.GetPageToken() != "" { 1106 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1107 } 1108 if req.GetReadMask() != nil { 1109 field, err := protojson.Marshal(req.GetReadMask()) 1110 if err != nil { 1111 return nil, "", err 1112 } 1113 params.Add("readMask", string(field[1:len(field)-1])) 1114 } 1115 1116 baseUrl.RawQuery = params.Encode() 1117 1118 // Build HTTP headers from client and context metadata. 1119 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1120 headers := gax.BuildHeaders(ctx, hds...) 1121 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1122 if settings.Path != "" { 1123 baseUrl.Path = settings.Path 1124 } 1125 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1126 if err != nil { 1127 return err 1128 } 1129 httpReq.Header = headers 1130 1131 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListIndexEndpoints") 1132 if err != nil { 1133 return err 1134 } 1135 if err := unm.Unmarshal(buf, resp); err != nil { 1136 return err 1137 } 1138 1139 return nil 1140 }, opts...) 1141 if e != nil { 1142 return nil, "", e 1143 } 1144 it.Response = resp 1145 return resp.GetIndexEndpoints(), resp.GetNextPageToken(), nil 1146 } 1147 1148 fetch := func(pageSize int, pageToken string) (string, error) { 1149 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1150 if err != nil { 1151 return "", err 1152 } 1153 it.items = append(it.items, items...) 1154 return nextPageToken, nil 1155 } 1156 1157 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1158 it.pageInfo.MaxSize = int(req.GetPageSize()) 1159 it.pageInfo.Token = req.GetPageToken() 1160 1161 return it 1162 } 1163 1164 // UpdateIndexEndpoint updates an IndexEndpoint. 1165 func (c *indexEndpointRESTClient) UpdateIndexEndpoint(ctx context.Context, req *aiplatformpb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*aiplatformpb.IndexEndpoint, error) { 1166 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1167 body := req.GetIndexEndpoint() 1168 jsonReq, err := m.Marshal(body) 1169 if err != nil { 1170 return nil, err 1171 } 1172 1173 baseUrl, err := url.Parse(c.endpoint) 1174 if err != nil { 1175 return nil, err 1176 } 1177 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetIndexEndpoint().GetName()) 1178 1179 params := url.Values{} 1180 params.Add("$alt", "json;enum-encoding=int") 1181 if req.GetUpdateMask() != nil { 1182 field, err := protojson.Marshal(req.GetUpdateMask()) 1183 if err != nil { 1184 return nil, err 1185 } 1186 params.Add("updateMask", string(field[1:len(field)-1])) 1187 } 1188 1189 baseUrl.RawQuery = params.Encode() 1190 1191 // Build HTTP headers from client and context metadata. 1192 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint.name", url.QueryEscape(req.GetIndexEndpoint().GetName()))} 1193 1194 hds = append(c.xGoogHeaders, hds...) 1195 hds = append(hds, "Content-Type", "application/json") 1196 headers := gax.BuildHeaders(ctx, hds...) 1197 opts = append((*c.CallOptions).UpdateIndexEndpoint[0:len((*c.CallOptions).UpdateIndexEndpoint):len((*c.CallOptions).UpdateIndexEndpoint)], opts...) 1198 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1199 resp := &aiplatformpb.IndexEndpoint{} 1200 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1201 if settings.Path != "" { 1202 baseUrl.Path = settings.Path 1203 } 1204 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 1205 if err != nil { 1206 return err 1207 } 1208 httpReq = httpReq.WithContext(ctx) 1209 httpReq.Header = headers 1210 1211 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateIndexEndpoint") 1212 if err != nil { 1213 return err 1214 } 1215 1216 if err := unm.Unmarshal(buf, resp); err != nil { 1217 return err 1218 } 1219 1220 return nil 1221 }, opts...) 1222 if e != nil { 1223 return nil, e 1224 } 1225 return resp, nil 1226 } 1227 1228 // DeleteIndexEndpoint deletes an IndexEndpoint. 1229 func (c *indexEndpointRESTClient) DeleteIndexEndpoint(ctx context.Context, req *aiplatformpb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) { 1230 baseUrl, err := url.Parse(c.endpoint) 1231 if err != nil { 1232 return nil, err 1233 } 1234 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1235 1236 params := url.Values{} 1237 params.Add("$alt", "json;enum-encoding=int") 1238 1239 baseUrl.RawQuery = params.Encode() 1240 1241 // Build HTTP headers from client and context metadata. 1242 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1243 1244 hds = append(c.xGoogHeaders, hds...) 1245 hds = append(hds, "Content-Type", "application/json") 1246 headers := gax.BuildHeaders(ctx, hds...) 1247 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1248 resp := &longrunningpb.Operation{} 1249 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1250 if settings.Path != "" { 1251 baseUrl.Path = settings.Path 1252 } 1253 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 1254 if err != nil { 1255 return err 1256 } 1257 httpReq = httpReq.WithContext(ctx) 1258 httpReq.Header = headers 1259 1260 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteIndexEndpoint") 1261 if err != nil { 1262 return err 1263 } 1264 if err := unm.Unmarshal(buf, resp); err != nil { 1265 return err 1266 } 1267 1268 return nil 1269 }, opts...) 1270 if e != nil { 1271 return nil, e 1272 } 1273 1274 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1275 return &DeleteIndexEndpointOperation{ 1276 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1277 pollPath: override, 1278 }, nil 1279 } 1280 1281 // DeployIndex deploys an Index into this IndexEndpoint, creating a DeployedIndex within 1282 // it. 1283 // Only non-empty Indexes can be deployed. 1284 func (c *indexEndpointRESTClient) DeployIndex(ctx context.Context, req *aiplatformpb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) { 1285 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1286 jsonReq, err := m.Marshal(req) 1287 if err != nil { 1288 return nil, err 1289 } 1290 1291 baseUrl, err := url.Parse(c.endpoint) 1292 if err != nil { 1293 return nil, err 1294 } 1295 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:deployIndex", req.GetIndexEndpoint()) 1296 1297 params := url.Values{} 1298 params.Add("$alt", "json;enum-encoding=int") 1299 1300 baseUrl.RawQuery = params.Encode() 1301 1302 // Build HTTP headers from client and context metadata. 1303 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 1304 1305 hds = append(c.xGoogHeaders, hds...) 1306 hds = append(hds, "Content-Type", "application/json") 1307 headers := gax.BuildHeaders(ctx, hds...) 1308 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1309 resp := &longrunningpb.Operation{} 1310 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1311 if settings.Path != "" { 1312 baseUrl.Path = settings.Path 1313 } 1314 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1315 if err != nil { 1316 return err 1317 } 1318 httpReq = httpReq.WithContext(ctx) 1319 httpReq.Header = headers 1320 1321 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "DeployIndex") 1322 if err != nil { 1323 return err 1324 } 1325 if err := unm.Unmarshal(buf, resp); err != nil { 1326 return err 1327 } 1328 1329 return nil 1330 }, opts...) 1331 if e != nil { 1332 return nil, e 1333 } 1334 1335 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1336 return &DeployIndexOperation{ 1337 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1338 pollPath: override, 1339 }, nil 1340 } 1341 1342 // UndeployIndex undeploys an Index from an IndexEndpoint, removing a DeployedIndex from it, 1343 // and freeing all resources it’s using. 1344 func (c *indexEndpointRESTClient) UndeployIndex(ctx context.Context, req *aiplatformpb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) { 1345 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1346 jsonReq, err := m.Marshal(req) 1347 if err != nil { 1348 return nil, err 1349 } 1350 1351 baseUrl, err := url.Parse(c.endpoint) 1352 if err != nil { 1353 return nil, err 1354 } 1355 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:undeployIndex", req.GetIndexEndpoint()) 1356 1357 params := url.Values{} 1358 params.Add("$alt", "json;enum-encoding=int") 1359 1360 baseUrl.RawQuery = params.Encode() 1361 1362 // Build HTTP headers from client and context metadata. 1363 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 1364 1365 hds = append(c.xGoogHeaders, hds...) 1366 hds = append(hds, "Content-Type", "application/json") 1367 headers := gax.BuildHeaders(ctx, hds...) 1368 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1369 resp := &longrunningpb.Operation{} 1370 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1371 if settings.Path != "" { 1372 baseUrl.Path = settings.Path 1373 } 1374 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1375 if err != nil { 1376 return err 1377 } 1378 httpReq = httpReq.WithContext(ctx) 1379 httpReq.Header = headers 1380 1381 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UndeployIndex") 1382 if err != nil { 1383 return err 1384 } 1385 if err := unm.Unmarshal(buf, resp); err != nil { 1386 return err 1387 } 1388 1389 return nil 1390 }, opts...) 1391 if e != nil { 1392 return nil, e 1393 } 1394 1395 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1396 return &UndeployIndexOperation{ 1397 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1398 pollPath: override, 1399 }, nil 1400 } 1401 1402 // MutateDeployedIndex update an existing DeployedIndex under an IndexEndpoint. 1403 func (c *indexEndpointRESTClient) MutateDeployedIndex(ctx context.Context, req *aiplatformpb.MutateDeployedIndexRequest, opts ...gax.CallOption) (*MutateDeployedIndexOperation, error) { 1404 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1405 body := req.GetDeployedIndex() 1406 jsonReq, err := m.Marshal(body) 1407 if err != nil { 1408 return nil, err 1409 } 1410 1411 baseUrl, err := url.Parse(c.endpoint) 1412 if err != nil { 1413 return nil, err 1414 } 1415 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:mutateDeployedIndex", req.GetIndexEndpoint()) 1416 1417 params := url.Values{} 1418 params.Add("$alt", "json;enum-encoding=int") 1419 1420 baseUrl.RawQuery = params.Encode() 1421 1422 // Build HTTP headers from client and context metadata. 1423 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))} 1424 1425 hds = append(c.xGoogHeaders, hds...) 1426 hds = append(hds, "Content-Type", "application/json") 1427 headers := gax.BuildHeaders(ctx, hds...) 1428 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1429 resp := &longrunningpb.Operation{} 1430 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1431 if settings.Path != "" { 1432 baseUrl.Path = settings.Path 1433 } 1434 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1435 if err != nil { 1436 return err 1437 } 1438 httpReq = httpReq.WithContext(ctx) 1439 httpReq.Header = headers 1440 1441 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "MutateDeployedIndex") 1442 if err != nil { 1443 return err 1444 } 1445 if err := unm.Unmarshal(buf, resp); err != nil { 1446 return err 1447 } 1448 1449 return nil 1450 }, opts...) 1451 if e != nil { 1452 return nil, e 1453 } 1454 1455 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1456 return &MutateDeployedIndexOperation{ 1457 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1458 pollPath: override, 1459 }, nil 1460 } 1461 1462 // GetLocation gets information about a location. 1463 func (c *indexEndpointRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 1464 baseUrl, err := url.Parse(c.endpoint) 1465 if err != nil { 1466 return nil, err 1467 } 1468 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1469 1470 params := url.Values{} 1471 params.Add("$alt", "json;enum-encoding=int") 1472 1473 baseUrl.RawQuery = params.Encode() 1474 1475 // Build HTTP headers from client and context metadata. 1476 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1477 1478 hds = append(c.xGoogHeaders, hds...) 1479 hds = append(hds, "Content-Type", "application/json") 1480 headers := gax.BuildHeaders(ctx, hds...) 1481 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 1482 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1483 resp := &locationpb.Location{} 1484 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1485 if settings.Path != "" { 1486 baseUrl.Path = settings.Path 1487 } 1488 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1489 if err != nil { 1490 return err 1491 } 1492 httpReq = httpReq.WithContext(ctx) 1493 httpReq.Header = headers 1494 1495 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation") 1496 if err != nil { 1497 return err 1498 } 1499 1500 if err := unm.Unmarshal(buf, resp); err != nil { 1501 return err 1502 } 1503 1504 return nil 1505 }, opts...) 1506 if e != nil { 1507 return nil, e 1508 } 1509 return resp, nil 1510 } 1511 1512 // ListLocations lists information about the supported locations for this service. 1513 func (c *indexEndpointRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 1514 it := &LocationIterator{} 1515 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 1516 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1517 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 1518 resp := &locationpb.ListLocationsResponse{} 1519 if pageToken != "" { 1520 req.PageToken = pageToken 1521 } 1522 if pageSize > math.MaxInt32 { 1523 req.PageSize = math.MaxInt32 1524 } else if pageSize != 0 { 1525 req.PageSize = int32(pageSize) 1526 } 1527 baseUrl, err := url.Parse(c.endpoint) 1528 if err != nil { 1529 return nil, "", err 1530 } 1531 baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName()) 1532 1533 params := url.Values{} 1534 params.Add("$alt", "json;enum-encoding=int") 1535 if req.GetFilter() != "" { 1536 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1537 } 1538 if req.GetPageSize() != 0 { 1539 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1540 } 1541 if req.GetPageToken() != "" { 1542 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1543 } 1544 1545 baseUrl.RawQuery = params.Encode() 1546 1547 // Build HTTP headers from client and context metadata. 1548 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1549 headers := gax.BuildHeaders(ctx, hds...) 1550 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1551 if settings.Path != "" { 1552 baseUrl.Path = settings.Path 1553 } 1554 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1555 if err != nil { 1556 return err 1557 } 1558 httpReq.Header = headers 1559 1560 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations") 1561 if err != nil { 1562 return err 1563 } 1564 if err := unm.Unmarshal(buf, resp); err != nil { 1565 return err 1566 } 1567 1568 return nil 1569 }, opts...) 1570 if e != nil { 1571 return nil, "", e 1572 } 1573 it.Response = resp 1574 return resp.GetLocations(), resp.GetNextPageToken(), nil 1575 } 1576 1577 fetch := func(pageSize int, pageToken string) (string, error) { 1578 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1579 if err != nil { 1580 return "", err 1581 } 1582 it.items = append(it.items, items...) 1583 return nextPageToken, nil 1584 } 1585 1586 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1587 it.pageInfo.MaxSize = int(req.GetPageSize()) 1588 it.pageInfo.Token = req.GetPageToken() 1589 1590 return it 1591 } 1592 1593 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 1594 // if the resource exists and does not have a policy set. 1595 func (c *indexEndpointRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1596 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1597 jsonReq, err := m.Marshal(req) 1598 if err != nil { 1599 return nil, err 1600 } 1601 1602 baseUrl, err := url.Parse(c.endpoint) 1603 if err != nil { 1604 return nil, err 1605 } 1606 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource()) 1607 1608 params := url.Values{} 1609 params.Add("$alt", "json;enum-encoding=int") 1610 1611 baseUrl.RawQuery = params.Encode() 1612 1613 // Build HTTP headers from client and context metadata. 1614 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1615 1616 hds = append(c.xGoogHeaders, hds...) 1617 hds = append(hds, "Content-Type", "application/json") 1618 headers := gax.BuildHeaders(ctx, hds...) 1619 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 1620 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1621 resp := &iampb.Policy{} 1622 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1623 if settings.Path != "" { 1624 baseUrl.Path = settings.Path 1625 } 1626 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1627 if err != nil { 1628 return err 1629 } 1630 httpReq = httpReq.WithContext(ctx) 1631 httpReq.Header = headers 1632 1633 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy") 1634 if err != nil { 1635 return err 1636 } 1637 1638 if err := unm.Unmarshal(buf, resp); err != nil { 1639 return err 1640 } 1641 1642 return nil 1643 }, opts...) 1644 if e != nil { 1645 return nil, e 1646 } 1647 return resp, nil 1648 } 1649 1650 // SetIamPolicy sets the access control policy on the specified resource. Replaces 1651 // any existing policy. 1652 // 1653 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 1654 // errors. 1655 func (c *indexEndpointRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1656 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1657 jsonReq, err := m.Marshal(req) 1658 if err != nil { 1659 return nil, err 1660 } 1661 1662 baseUrl, err := url.Parse(c.endpoint) 1663 if err != nil { 1664 return nil, err 1665 } 1666 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource()) 1667 1668 params := url.Values{} 1669 params.Add("$alt", "json;enum-encoding=int") 1670 1671 baseUrl.RawQuery = params.Encode() 1672 1673 // Build HTTP headers from client and context metadata. 1674 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1675 1676 hds = append(c.xGoogHeaders, hds...) 1677 hds = append(hds, "Content-Type", "application/json") 1678 headers := gax.BuildHeaders(ctx, hds...) 1679 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 1680 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1681 resp := &iampb.Policy{} 1682 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1683 if settings.Path != "" { 1684 baseUrl.Path = settings.Path 1685 } 1686 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1687 if err != nil { 1688 return err 1689 } 1690 httpReq = httpReq.WithContext(ctx) 1691 httpReq.Header = headers 1692 1693 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy") 1694 if err != nil { 1695 return err 1696 } 1697 1698 if err := unm.Unmarshal(buf, resp); err != nil { 1699 return err 1700 } 1701 1702 return nil 1703 }, opts...) 1704 if e != nil { 1705 return nil, e 1706 } 1707 return resp, nil 1708 } 1709 1710 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 1711 // resource does not exist, this will return an empty set of 1712 // permissions, not a NOT_FOUND error. 1713 // 1714 // Note: This operation is designed to be used for building 1715 // permission-aware UIs and command-line tools, not for authorization 1716 // checking. This operation may “fail open” without warning. 1717 func (c *indexEndpointRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 1718 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1719 jsonReq, err := m.Marshal(req) 1720 if err != nil { 1721 return nil, err 1722 } 1723 1724 baseUrl, err := url.Parse(c.endpoint) 1725 if err != nil { 1726 return nil, err 1727 } 1728 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource()) 1729 1730 params := url.Values{} 1731 params.Add("$alt", "json;enum-encoding=int") 1732 1733 baseUrl.RawQuery = params.Encode() 1734 1735 // Build HTTP headers from client and context metadata. 1736 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1737 1738 hds = append(c.xGoogHeaders, hds...) 1739 hds = append(hds, "Content-Type", "application/json") 1740 headers := gax.BuildHeaders(ctx, hds...) 1741 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 1742 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1743 resp := &iampb.TestIamPermissionsResponse{} 1744 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1745 if settings.Path != "" { 1746 baseUrl.Path = settings.Path 1747 } 1748 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1749 if err != nil { 1750 return err 1751 } 1752 httpReq = httpReq.WithContext(ctx) 1753 httpReq.Header = headers 1754 1755 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions") 1756 if err != nil { 1757 return err 1758 } 1759 1760 if err := unm.Unmarshal(buf, resp); err != nil { 1761 return err 1762 } 1763 1764 return nil 1765 }, opts...) 1766 if e != nil { 1767 return nil, e 1768 } 1769 return resp, nil 1770 } 1771 1772 // CancelOperation is a utility method from google.longrunning.Operations. 1773 func (c *indexEndpointRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 1774 baseUrl, err := url.Parse(c.endpoint) 1775 if err != nil { 1776 return err 1777 } 1778 baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName()) 1779 1780 params := url.Values{} 1781 params.Add("$alt", "json;enum-encoding=int") 1782 1783 baseUrl.RawQuery = params.Encode() 1784 1785 // Build HTTP headers from client and context metadata. 1786 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1787 1788 hds = append(c.xGoogHeaders, hds...) 1789 hds = append(hds, "Content-Type", "application/json") 1790 headers := gax.BuildHeaders(ctx, hds...) 1791 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1792 if settings.Path != "" { 1793 baseUrl.Path = settings.Path 1794 } 1795 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 1796 if err != nil { 1797 return err 1798 } 1799 httpReq = httpReq.WithContext(ctx) 1800 httpReq.Header = headers 1801 1802 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation") 1803 return err 1804 }, opts...) 1805 } 1806 1807 // DeleteOperation is a utility method from google.longrunning.Operations. 1808 func (c *indexEndpointRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 1809 baseUrl, err := url.Parse(c.endpoint) 1810 if err != nil { 1811 return err 1812 } 1813 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1814 1815 params := url.Values{} 1816 params.Add("$alt", "json;enum-encoding=int") 1817 1818 baseUrl.RawQuery = params.Encode() 1819 1820 // Build HTTP headers from client and context metadata. 1821 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1822 1823 hds = append(c.xGoogHeaders, hds...) 1824 hds = append(hds, "Content-Type", "application/json") 1825 headers := gax.BuildHeaders(ctx, hds...) 1826 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1827 if settings.Path != "" { 1828 baseUrl.Path = settings.Path 1829 } 1830 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 1831 if err != nil { 1832 return err 1833 } 1834 httpReq = httpReq.WithContext(ctx) 1835 httpReq.Header = headers 1836 1837 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation") 1838 return err 1839 }, opts...) 1840 } 1841 1842 // GetOperation is a utility method from google.longrunning.Operations. 1843 func (c *indexEndpointRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1844 baseUrl, err := url.Parse(c.endpoint) 1845 if err != nil { 1846 return nil, err 1847 } 1848 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1849 1850 params := url.Values{} 1851 params.Add("$alt", "json;enum-encoding=int") 1852 1853 baseUrl.RawQuery = params.Encode() 1854 1855 // Build HTTP headers from client and context metadata. 1856 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1857 1858 hds = append(c.xGoogHeaders, hds...) 1859 hds = append(hds, "Content-Type", "application/json") 1860 headers := gax.BuildHeaders(ctx, hds...) 1861 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 1862 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1863 resp := &longrunningpb.Operation{} 1864 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1865 if settings.Path != "" { 1866 baseUrl.Path = settings.Path 1867 } 1868 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1869 if err != nil { 1870 return err 1871 } 1872 httpReq = httpReq.WithContext(ctx) 1873 httpReq.Header = headers 1874 1875 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation") 1876 if err != nil { 1877 return err 1878 } 1879 1880 if err := unm.Unmarshal(buf, resp); err != nil { 1881 return err 1882 } 1883 1884 return nil 1885 }, opts...) 1886 if e != nil { 1887 return nil, e 1888 } 1889 return resp, nil 1890 } 1891 1892 // ListOperations is a utility method from google.longrunning.Operations. 1893 func (c *indexEndpointRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 1894 it := &OperationIterator{} 1895 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 1896 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1897 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 1898 resp := &longrunningpb.ListOperationsResponse{} 1899 if pageToken != "" { 1900 req.PageToken = pageToken 1901 } 1902 if pageSize > math.MaxInt32 { 1903 req.PageSize = math.MaxInt32 1904 } else if pageSize != 0 { 1905 req.PageSize = int32(pageSize) 1906 } 1907 baseUrl, err := url.Parse(c.endpoint) 1908 if err != nil { 1909 return nil, "", err 1910 } 1911 baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName()) 1912 1913 params := url.Values{} 1914 params.Add("$alt", "json;enum-encoding=int") 1915 if req.GetFilter() != "" { 1916 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1917 } 1918 if req.GetPageSize() != 0 { 1919 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1920 } 1921 if req.GetPageToken() != "" { 1922 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1923 } 1924 1925 baseUrl.RawQuery = params.Encode() 1926 1927 // Build HTTP headers from client and context metadata. 1928 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1929 headers := gax.BuildHeaders(ctx, hds...) 1930 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1931 if settings.Path != "" { 1932 baseUrl.Path = settings.Path 1933 } 1934 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1935 if err != nil { 1936 return err 1937 } 1938 httpReq.Header = headers 1939 1940 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations") 1941 if err != nil { 1942 return err 1943 } 1944 if err := unm.Unmarshal(buf, resp); err != nil { 1945 return err 1946 } 1947 1948 return nil 1949 }, opts...) 1950 if e != nil { 1951 return nil, "", e 1952 } 1953 it.Response = resp 1954 return resp.GetOperations(), resp.GetNextPageToken(), nil 1955 } 1956 1957 fetch := func(pageSize int, pageToken string) (string, error) { 1958 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1959 if err != nil { 1960 return "", err 1961 } 1962 it.items = append(it.items, items...) 1963 return nextPageToken, nil 1964 } 1965 1966 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1967 it.pageInfo.MaxSize = int(req.GetPageSize()) 1968 it.pageInfo.Token = req.GetPageToken() 1969 1970 return it 1971 } 1972 1973 // WaitOperation is a utility method from google.longrunning.Operations. 1974 func (c *indexEndpointRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1975 baseUrl, err := url.Parse(c.endpoint) 1976 if err != nil { 1977 return nil, err 1978 } 1979 baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName()) 1980 1981 params := url.Values{} 1982 params.Add("$alt", "json;enum-encoding=int") 1983 if req.GetTimeout() != nil { 1984 field, err := protojson.Marshal(req.GetTimeout()) 1985 if err != nil { 1986 return nil, err 1987 } 1988 params.Add("timeout", string(field[1:len(field)-1])) 1989 } 1990 1991 baseUrl.RawQuery = params.Encode() 1992 1993 // Build HTTP headers from client and context metadata. 1994 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1995 1996 hds = append(c.xGoogHeaders, hds...) 1997 hds = append(hds, "Content-Type", "application/json") 1998 headers := gax.BuildHeaders(ctx, hds...) 1999 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 2000 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2001 resp := &longrunningpb.Operation{} 2002 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2003 if settings.Path != "" { 2004 baseUrl.Path = settings.Path 2005 } 2006 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 2007 if err != nil { 2008 return err 2009 } 2010 httpReq = httpReq.WithContext(ctx) 2011 httpReq.Header = headers 2012 2013 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation") 2014 if err != nil { 2015 return err 2016 } 2017 2018 if err := unm.Unmarshal(buf, resp); err != nil { 2019 return err 2020 } 2021 2022 return nil 2023 }, opts...) 2024 if e != nil { 2025 return nil, e 2026 } 2027 return resp, nil 2028 } 2029 2030 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name. 2031 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process. 2032 func (c *indexEndpointGRPCClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation { 2033 return &CreateIndexEndpointOperation{ 2034 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2035 } 2036 } 2037 2038 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name. 2039 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process. 2040 func (c *indexEndpointRESTClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation { 2041 override := fmt.Sprintf("/ui/%s", name) 2042 return &CreateIndexEndpointOperation{ 2043 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2044 pollPath: override, 2045 } 2046 } 2047 2048 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name. 2049 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process. 2050 func (c *indexEndpointGRPCClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation { 2051 return &DeleteIndexEndpointOperation{ 2052 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2053 } 2054 } 2055 2056 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name. 2057 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process. 2058 func (c *indexEndpointRESTClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation { 2059 override := fmt.Sprintf("/ui/%s", name) 2060 return &DeleteIndexEndpointOperation{ 2061 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2062 pollPath: override, 2063 } 2064 } 2065 2066 // DeployIndexOperation returns a new DeployIndexOperation from a given name. 2067 // The name must be that of a previously created DeployIndexOperation, possibly from a different process. 2068 func (c *indexEndpointGRPCClient) DeployIndexOperation(name string) *DeployIndexOperation { 2069 return &DeployIndexOperation{ 2070 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2071 } 2072 } 2073 2074 // DeployIndexOperation returns a new DeployIndexOperation from a given name. 2075 // The name must be that of a previously created DeployIndexOperation, possibly from a different process. 2076 func (c *indexEndpointRESTClient) DeployIndexOperation(name string) *DeployIndexOperation { 2077 override := fmt.Sprintf("/ui/%s", name) 2078 return &DeployIndexOperation{ 2079 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2080 pollPath: override, 2081 } 2082 } 2083 2084 // MutateDeployedIndexOperation returns a new MutateDeployedIndexOperation from a given name. 2085 // The name must be that of a previously created MutateDeployedIndexOperation, possibly from a different process. 2086 func (c *indexEndpointGRPCClient) MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation { 2087 return &MutateDeployedIndexOperation{ 2088 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2089 } 2090 } 2091 2092 // MutateDeployedIndexOperation returns a new MutateDeployedIndexOperation from a given name. 2093 // The name must be that of a previously created MutateDeployedIndexOperation, possibly from a different process. 2094 func (c *indexEndpointRESTClient) MutateDeployedIndexOperation(name string) *MutateDeployedIndexOperation { 2095 override := fmt.Sprintf("/ui/%s", name) 2096 return &MutateDeployedIndexOperation{ 2097 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2098 pollPath: override, 2099 } 2100 } 2101 2102 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name. 2103 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process. 2104 func (c *indexEndpointGRPCClient) UndeployIndexOperation(name string) *UndeployIndexOperation { 2105 return &UndeployIndexOperation{ 2106 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2107 } 2108 } 2109 2110 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name. 2111 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process. 2112 func (c *indexEndpointRESTClient) UndeployIndexOperation(name string) *UndeployIndexOperation { 2113 override := fmt.Sprintf("/ui/%s", name) 2114 return &UndeployIndexOperation{ 2115 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2116 pollPath: override, 2117 } 2118 }