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