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