cloud.google.com/go/aiplatform@v1.106.0/apiv1/job_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 newJobClientHook clientHook 42 43 // JobCallOptions contains the retry settings for each method of JobClient. 44 type JobCallOptions struct { 45 CreateCustomJob []gax.CallOption 46 GetCustomJob []gax.CallOption 47 ListCustomJobs []gax.CallOption 48 DeleteCustomJob []gax.CallOption 49 CancelCustomJob []gax.CallOption 50 CreateDataLabelingJob []gax.CallOption 51 GetDataLabelingJob []gax.CallOption 52 ListDataLabelingJobs []gax.CallOption 53 DeleteDataLabelingJob []gax.CallOption 54 CancelDataLabelingJob []gax.CallOption 55 CreateHyperparameterTuningJob []gax.CallOption 56 GetHyperparameterTuningJob []gax.CallOption 57 ListHyperparameterTuningJobs []gax.CallOption 58 DeleteHyperparameterTuningJob []gax.CallOption 59 CancelHyperparameterTuningJob []gax.CallOption 60 CreateNasJob []gax.CallOption 61 GetNasJob []gax.CallOption 62 ListNasJobs []gax.CallOption 63 DeleteNasJob []gax.CallOption 64 CancelNasJob []gax.CallOption 65 GetNasTrialDetail []gax.CallOption 66 ListNasTrialDetails []gax.CallOption 67 CreateBatchPredictionJob []gax.CallOption 68 GetBatchPredictionJob []gax.CallOption 69 ListBatchPredictionJobs []gax.CallOption 70 DeleteBatchPredictionJob []gax.CallOption 71 CancelBatchPredictionJob []gax.CallOption 72 CreateModelDeploymentMonitoringJob []gax.CallOption 73 SearchModelDeploymentMonitoringStatsAnomalies []gax.CallOption 74 GetModelDeploymentMonitoringJob []gax.CallOption 75 ListModelDeploymentMonitoringJobs []gax.CallOption 76 UpdateModelDeploymentMonitoringJob []gax.CallOption 77 DeleteModelDeploymentMonitoringJob []gax.CallOption 78 PauseModelDeploymentMonitoringJob []gax.CallOption 79 ResumeModelDeploymentMonitoringJob []gax.CallOption 80 GetLocation []gax.CallOption 81 ListLocations []gax.CallOption 82 GetIamPolicy []gax.CallOption 83 SetIamPolicy []gax.CallOption 84 TestIamPermissions []gax.CallOption 85 CancelOperation []gax.CallOption 86 DeleteOperation []gax.CallOption 87 GetOperation []gax.CallOption 88 ListOperations []gax.CallOption 89 WaitOperation []gax.CallOption 90 } 91 92 func defaultJobGRPCClientOptions() []option.ClientOption { 93 return []option.ClientOption{ 94 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 95 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 96 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 97 internaloption.WithDefaultUniverseDomain("googleapis.com"), 98 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 99 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 100 internaloption.EnableJwtWithScope(), 101 internaloption.EnableNewAuthLibrary(), 102 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 103 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 104 } 105 } 106 107 func defaultJobCallOptions() *JobCallOptions { 108 return &JobCallOptions{ 109 CreateCustomJob: []gax.CallOption{}, 110 GetCustomJob: []gax.CallOption{}, 111 ListCustomJobs: []gax.CallOption{}, 112 DeleteCustomJob: []gax.CallOption{}, 113 CancelCustomJob: []gax.CallOption{}, 114 CreateDataLabelingJob: []gax.CallOption{}, 115 GetDataLabelingJob: []gax.CallOption{}, 116 ListDataLabelingJobs: []gax.CallOption{}, 117 DeleteDataLabelingJob: []gax.CallOption{}, 118 CancelDataLabelingJob: []gax.CallOption{}, 119 CreateHyperparameterTuningJob: []gax.CallOption{}, 120 GetHyperparameterTuningJob: []gax.CallOption{}, 121 ListHyperparameterTuningJobs: []gax.CallOption{}, 122 DeleteHyperparameterTuningJob: []gax.CallOption{}, 123 CancelHyperparameterTuningJob: []gax.CallOption{}, 124 CreateNasJob: []gax.CallOption{}, 125 GetNasJob: []gax.CallOption{}, 126 ListNasJobs: []gax.CallOption{}, 127 DeleteNasJob: []gax.CallOption{}, 128 CancelNasJob: []gax.CallOption{}, 129 GetNasTrialDetail: []gax.CallOption{}, 130 ListNasTrialDetails: []gax.CallOption{}, 131 CreateBatchPredictionJob: []gax.CallOption{}, 132 GetBatchPredictionJob: []gax.CallOption{}, 133 ListBatchPredictionJobs: []gax.CallOption{}, 134 DeleteBatchPredictionJob: []gax.CallOption{}, 135 CancelBatchPredictionJob: []gax.CallOption{}, 136 CreateModelDeploymentMonitoringJob: []gax.CallOption{}, 137 SearchModelDeploymentMonitoringStatsAnomalies: []gax.CallOption{}, 138 GetModelDeploymentMonitoringJob: []gax.CallOption{}, 139 ListModelDeploymentMonitoringJobs: []gax.CallOption{}, 140 UpdateModelDeploymentMonitoringJob: []gax.CallOption{}, 141 DeleteModelDeploymentMonitoringJob: []gax.CallOption{}, 142 PauseModelDeploymentMonitoringJob: []gax.CallOption{}, 143 ResumeModelDeploymentMonitoringJob: []gax.CallOption{}, 144 GetLocation: []gax.CallOption{}, 145 ListLocations: []gax.CallOption{}, 146 GetIamPolicy: []gax.CallOption{}, 147 SetIamPolicy: []gax.CallOption{}, 148 TestIamPermissions: []gax.CallOption{}, 149 CancelOperation: []gax.CallOption{}, 150 DeleteOperation: []gax.CallOption{}, 151 GetOperation: []gax.CallOption{}, 152 ListOperations: []gax.CallOption{}, 153 WaitOperation: []gax.CallOption{}, 154 } 155 } 156 157 // internalJobClient is an interface that defines the methods available from Vertex AI API. 158 type internalJobClient interface { 159 Close() error 160 setGoogleClientInfo(...string) 161 Connection() *grpc.ClientConn 162 CreateCustomJob(context.Context, *aiplatformpb.CreateCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error) 163 GetCustomJob(context.Context, *aiplatformpb.GetCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error) 164 ListCustomJobs(context.Context, *aiplatformpb.ListCustomJobsRequest, ...gax.CallOption) *CustomJobIterator 165 DeleteCustomJob(context.Context, *aiplatformpb.DeleteCustomJobRequest, ...gax.CallOption) (*DeleteCustomJobOperation, error) 166 DeleteCustomJobOperation(name string) *DeleteCustomJobOperation 167 CancelCustomJob(context.Context, *aiplatformpb.CancelCustomJobRequest, ...gax.CallOption) error 168 CreateDataLabelingJob(context.Context, *aiplatformpb.CreateDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) 169 GetDataLabelingJob(context.Context, *aiplatformpb.GetDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) 170 ListDataLabelingJobs(context.Context, *aiplatformpb.ListDataLabelingJobsRequest, ...gax.CallOption) *DataLabelingJobIterator 171 DeleteDataLabelingJob(context.Context, *aiplatformpb.DeleteDataLabelingJobRequest, ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) 172 DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation 173 CancelDataLabelingJob(context.Context, *aiplatformpb.CancelDataLabelingJobRequest, ...gax.CallOption) error 174 CreateHyperparameterTuningJob(context.Context, *aiplatformpb.CreateHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) 175 GetHyperparameterTuningJob(context.Context, *aiplatformpb.GetHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) 176 ListHyperparameterTuningJobs(context.Context, *aiplatformpb.ListHyperparameterTuningJobsRequest, ...gax.CallOption) *HyperparameterTuningJobIterator 177 DeleteHyperparameterTuningJob(context.Context, *aiplatformpb.DeleteHyperparameterTuningJobRequest, ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) 178 DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation 179 CancelHyperparameterTuningJob(context.Context, *aiplatformpb.CancelHyperparameterTuningJobRequest, ...gax.CallOption) error 180 CreateNasJob(context.Context, *aiplatformpb.CreateNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error) 181 GetNasJob(context.Context, *aiplatformpb.GetNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error) 182 ListNasJobs(context.Context, *aiplatformpb.ListNasJobsRequest, ...gax.CallOption) *NasJobIterator 183 DeleteNasJob(context.Context, *aiplatformpb.DeleteNasJobRequest, ...gax.CallOption) (*DeleteNasJobOperation, error) 184 DeleteNasJobOperation(name string) *DeleteNasJobOperation 185 CancelNasJob(context.Context, *aiplatformpb.CancelNasJobRequest, ...gax.CallOption) error 186 GetNasTrialDetail(context.Context, *aiplatformpb.GetNasTrialDetailRequest, ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) 187 ListNasTrialDetails(context.Context, *aiplatformpb.ListNasTrialDetailsRequest, ...gax.CallOption) *NasTrialDetailIterator 188 CreateBatchPredictionJob(context.Context, *aiplatformpb.CreateBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) 189 GetBatchPredictionJob(context.Context, *aiplatformpb.GetBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) 190 ListBatchPredictionJobs(context.Context, *aiplatformpb.ListBatchPredictionJobsRequest, ...gax.CallOption) *BatchPredictionJobIterator 191 DeleteBatchPredictionJob(context.Context, *aiplatformpb.DeleteBatchPredictionJobRequest, ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) 192 DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation 193 CancelBatchPredictionJob(context.Context, *aiplatformpb.CancelBatchPredictionJobRequest, ...gax.CallOption) error 194 CreateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) 195 SearchModelDeploymentMonitoringStatsAnomalies(context.Context, *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator 196 GetModelDeploymentMonitoringJob(context.Context, *aiplatformpb.GetModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) 197 ListModelDeploymentMonitoringJobs(context.Context, *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, ...gax.CallOption) *ModelDeploymentMonitoringJobIterator 198 UpdateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) 199 UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation 200 DeleteModelDeploymentMonitoringJob(context.Context, *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) 201 DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation 202 PauseModelDeploymentMonitoringJob(context.Context, *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, ...gax.CallOption) error 203 ResumeModelDeploymentMonitoringJob(context.Context, *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, ...gax.CallOption) error 204 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 205 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 206 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 207 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 208 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 209 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 210 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 211 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 212 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 213 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 214 } 215 216 // JobClient is a client for interacting with Vertex AI API. 217 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 218 // 219 // A service for creating and managing Vertex AI’s jobs. 220 type JobClient struct { 221 // The internal transport-dependent client. 222 internalClient internalJobClient 223 224 // The call options for this service. 225 CallOptions *JobCallOptions 226 227 // LROClient is used internally to handle long-running operations. 228 // It is exposed so that its CallOptions can be modified if required. 229 // Users should not Close this client. 230 LROClient *lroauto.OperationsClient 231 } 232 233 // Wrapper methods routed to the internal client. 234 235 // Close closes the connection to the API service. The user should invoke this when 236 // the client is no longer required. 237 func (c *JobClient) Close() error { 238 return c.internalClient.Close() 239 } 240 241 // setGoogleClientInfo sets the name and version of the application in 242 // the `x-goog-api-client` header passed on each request. Intended for 243 // use by Google-written clients. 244 func (c *JobClient) setGoogleClientInfo(keyval ...string) { 245 c.internalClient.setGoogleClientInfo(keyval...) 246 } 247 248 // Connection returns a connection to the API service. 249 // 250 // Deprecated: Connections are now pooled so this method does not always 251 // return the same resource. 252 func (c *JobClient) Connection() *grpc.ClientConn { 253 return c.internalClient.Connection() 254 } 255 256 // CreateCustomJob creates a CustomJob. A created CustomJob right away 257 // will be attempted to be run. 258 func (c *JobClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) { 259 return c.internalClient.CreateCustomJob(ctx, req, opts...) 260 } 261 262 // GetCustomJob gets a CustomJob. 263 func (c *JobClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) { 264 return c.internalClient.GetCustomJob(ctx, req, opts...) 265 } 266 267 // ListCustomJobs lists CustomJobs in a Location. 268 func (c *JobClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator { 269 return c.internalClient.ListCustomJobs(ctx, req, opts...) 270 } 271 272 // DeleteCustomJob deletes a CustomJob. 273 func (c *JobClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) { 274 return c.internalClient.DeleteCustomJob(ctx, req, opts...) 275 } 276 277 // DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name. 278 // The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process. 279 func (c *JobClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation { 280 return c.internalClient.DeleteCustomJobOperation(name) 281 } 282 283 // CancelCustomJob cancels a CustomJob. 284 // Starts asynchronous cancellation on the CustomJob. The server 285 // makes a best effort to cancel the job, but success is not 286 // guaranteed. Clients can use 287 // JobService.GetCustomJob 288 // or other methods to check whether the cancellation succeeded or whether the 289 // job completed despite cancellation. On successful cancellation, 290 // the CustomJob is not deleted; instead it becomes a job with 291 // a CustomJob.error value with 292 // a google.rpc.Status.code of 1, corresponding to 293 // Code.CANCELLED, and 294 // CustomJob.state is set to 295 // CANCELLED. 296 func (c *JobClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error { 297 return c.internalClient.CancelCustomJob(ctx, req, opts...) 298 } 299 300 // CreateDataLabelingJob creates a DataLabelingJob. 301 func (c *JobClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) { 302 return c.internalClient.CreateDataLabelingJob(ctx, req, opts...) 303 } 304 305 // GetDataLabelingJob gets a DataLabelingJob. 306 func (c *JobClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) { 307 return c.internalClient.GetDataLabelingJob(ctx, req, opts...) 308 } 309 310 // ListDataLabelingJobs lists DataLabelingJobs in a Location. 311 func (c *JobClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator { 312 return c.internalClient.ListDataLabelingJobs(ctx, req, opts...) 313 } 314 315 // DeleteDataLabelingJob deletes a DataLabelingJob. 316 func (c *JobClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) { 317 return c.internalClient.DeleteDataLabelingJob(ctx, req, opts...) 318 } 319 320 // DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name. 321 // The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process. 322 func (c *JobClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation { 323 return c.internalClient.DeleteDataLabelingJobOperation(name) 324 } 325 326 // CancelDataLabelingJob cancels a DataLabelingJob. Success of cancellation is not guaranteed. 327 func (c *JobClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error { 328 return c.internalClient.CancelDataLabelingJob(ctx, req, opts...) 329 } 330 331 // CreateHyperparameterTuningJob creates a HyperparameterTuningJob 332 func (c *JobClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) { 333 return c.internalClient.CreateHyperparameterTuningJob(ctx, req, opts...) 334 } 335 336 // GetHyperparameterTuningJob gets a HyperparameterTuningJob 337 func (c *JobClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) { 338 return c.internalClient.GetHyperparameterTuningJob(ctx, req, opts...) 339 } 340 341 // ListHyperparameterTuningJobs lists HyperparameterTuningJobs in a Location. 342 func (c *JobClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator { 343 return c.internalClient.ListHyperparameterTuningJobs(ctx, req, opts...) 344 } 345 346 // DeleteHyperparameterTuningJob deletes a HyperparameterTuningJob. 347 func (c *JobClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) { 348 return c.internalClient.DeleteHyperparameterTuningJob(ctx, req, opts...) 349 } 350 351 // DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name. 352 // The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process. 353 func (c *JobClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation { 354 return c.internalClient.DeleteHyperparameterTuningJobOperation(name) 355 } 356 357 // CancelHyperparameterTuningJob cancels a HyperparameterTuningJob. 358 // Starts asynchronous cancellation on the HyperparameterTuningJob. The server 359 // makes a best effort to cancel the job, but success is not 360 // guaranteed. Clients can use 361 // JobService.GetHyperparameterTuningJob 362 // or other methods to check whether the cancellation succeeded or whether the 363 // job completed despite cancellation. On successful cancellation, 364 // the HyperparameterTuningJob is not deleted; instead it becomes a job with 365 // a 366 // HyperparameterTuningJob.error 367 // value with a google.rpc.Status.code of 1, 368 // corresponding to Code.CANCELLED, and 369 // HyperparameterTuningJob.state 370 // is set to CANCELLED. 371 func (c *JobClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error { 372 return c.internalClient.CancelHyperparameterTuningJob(ctx, req, opts...) 373 } 374 375 // CreateNasJob creates a NasJob 376 func (c *JobClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) { 377 return c.internalClient.CreateNasJob(ctx, req, opts...) 378 } 379 380 // GetNasJob gets a NasJob 381 func (c *JobClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) { 382 return c.internalClient.GetNasJob(ctx, req, opts...) 383 } 384 385 // ListNasJobs lists NasJobs in a Location. 386 func (c *JobClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator { 387 return c.internalClient.ListNasJobs(ctx, req, opts...) 388 } 389 390 // DeleteNasJob deletes a NasJob. 391 func (c *JobClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) { 392 return c.internalClient.DeleteNasJob(ctx, req, opts...) 393 } 394 395 // DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name. 396 // The name must be that of a previously created DeleteNasJobOperation, possibly from a different process. 397 func (c *JobClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation { 398 return c.internalClient.DeleteNasJobOperation(name) 399 } 400 401 // CancelNasJob cancels a NasJob. 402 // Starts asynchronous cancellation on the NasJob. The server 403 // makes a best effort to cancel the job, but success is not 404 // guaranteed. Clients can use 405 // JobService.GetNasJob or 406 // other methods to check whether the cancellation succeeded or whether the 407 // job completed despite cancellation. On successful cancellation, 408 // the NasJob is not deleted; instead it becomes a job with 409 // a NasJob.error value with a 410 // google.rpc.Status.code of 1, corresponding to 411 // Code.CANCELLED, and 412 // NasJob.state is set to 413 // CANCELLED. 414 func (c *JobClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) error { 415 return c.internalClient.CancelNasJob(ctx, req, opts...) 416 } 417 418 // GetNasTrialDetail gets a NasTrialDetail. 419 func (c *JobClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) { 420 return c.internalClient.GetNasTrialDetail(ctx, req, opts...) 421 } 422 423 // ListNasTrialDetails list top NasTrialDetails of a NasJob. 424 func (c *JobClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator { 425 return c.internalClient.ListNasTrialDetails(ctx, req, opts...) 426 } 427 428 // CreateBatchPredictionJob creates a BatchPredictionJob. A BatchPredictionJob once created will 429 // right away be attempted to start. 430 func (c *JobClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) { 431 return c.internalClient.CreateBatchPredictionJob(ctx, req, opts...) 432 } 433 434 // GetBatchPredictionJob gets a BatchPredictionJob 435 func (c *JobClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) { 436 return c.internalClient.GetBatchPredictionJob(ctx, req, opts...) 437 } 438 439 // ListBatchPredictionJobs lists BatchPredictionJobs in a Location. 440 func (c *JobClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator { 441 return c.internalClient.ListBatchPredictionJobs(ctx, req, opts...) 442 } 443 444 // DeleteBatchPredictionJob deletes a BatchPredictionJob. Can only be called on jobs that already 445 // finished. 446 func (c *JobClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) { 447 return c.internalClient.DeleteBatchPredictionJob(ctx, req, opts...) 448 } 449 450 // DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name. 451 // The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process. 452 func (c *JobClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation { 453 return c.internalClient.DeleteBatchPredictionJobOperation(name) 454 } 455 456 // CancelBatchPredictionJob cancels a BatchPredictionJob. 457 // 458 // Starts asynchronous cancellation on the BatchPredictionJob. The server 459 // makes the best effort to cancel the job, but success is not 460 // guaranteed. Clients can use 461 // JobService.GetBatchPredictionJob 462 // or other methods to check whether the cancellation succeeded or whether the 463 // job completed despite cancellation. On a successful cancellation, 464 // the BatchPredictionJob is not deleted;instead its 465 // BatchPredictionJob.state 466 // is set to CANCELLED. Any files already outputted by the job are not 467 // deleted. 468 func (c *JobClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error { 469 return c.internalClient.CancelBatchPredictionJob(ctx, req, opts...) 470 } 471 472 // CreateModelDeploymentMonitoringJob creates a ModelDeploymentMonitoringJob. It will run periodically on a 473 // configured interval. 474 func (c *JobClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) { 475 return c.internalClient.CreateModelDeploymentMonitoringJob(ctx, req, opts...) 476 } 477 478 // SearchModelDeploymentMonitoringStatsAnomalies searches Model Monitoring Statistics generated within a given time window. 479 func (c *JobClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator { 480 return c.internalClient.SearchModelDeploymentMonitoringStatsAnomalies(ctx, req, opts...) 481 } 482 483 // GetModelDeploymentMonitoringJob gets a ModelDeploymentMonitoringJob. 484 func (c *JobClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) { 485 return c.internalClient.GetModelDeploymentMonitoringJob(ctx, req, opts...) 486 } 487 488 // ListModelDeploymentMonitoringJobs lists ModelDeploymentMonitoringJobs in a Location. 489 func (c *JobClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator { 490 return c.internalClient.ListModelDeploymentMonitoringJobs(ctx, req, opts...) 491 } 492 493 // UpdateModelDeploymentMonitoringJob updates a ModelDeploymentMonitoringJob. 494 func (c *JobClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) { 495 return c.internalClient.UpdateModelDeploymentMonitoringJob(ctx, req, opts...) 496 } 497 498 // UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name. 499 // The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process. 500 func (c *JobClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation { 501 return c.internalClient.UpdateModelDeploymentMonitoringJobOperation(name) 502 } 503 504 // DeleteModelDeploymentMonitoringJob deletes a ModelDeploymentMonitoringJob. 505 func (c *JobClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) { 506 return c.internalClient.DeleteModelDeploymentMonitoringJob(ctx, req, opts...) 507 } 508 509 // DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name. 510 // The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process. 511 func (c *JobClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation { 512 return c.internalClient.DeleteModelDeploymentMonitoringJobOperation(name) 513 } 514 515 // PauseModelDeploymentMonitoringJob pauses a ModelDeploymentMonitoringJob. If the job is running, the server 516 // makes a best effort to cancel the job. Will mark 517 // ModelDeploymentMonitoringJob.state 518 // to ‘PAUSED’. 519 func (c *JobClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error { 520 return c.internalClient.PauseModelDeploymentMonitoringJob(ctx, req, opts...) 521 } 522 523 // ResumeModelDeploymentMonitoringJob resumes a paused ModelDeploymentMonitoringJob. It will start to run from 524 // next scheduled time. A deleted ModelDeploymentMonitoringJob can’t be 525 // resumed. 526 func (c *JobClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error { 527 return c.internalClient.ResumeModelDeploymentMonitoringJob(ctx, req, opts...) 528 } 529 530 // GetLocation gets information about a location. 531 func (c *JobClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 532 return c.internalClient.GetLocation(ctx, req, opts...) 533 } 534 535 // ListLocations lists information about the supported locations for this service. 536 func (c *JobClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 537 return c.internalClient.ListLocations(ctx, req, opts...) 538 } 539 540 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 541 // if the resource exists and does not have a policy set. 542 func (c *JobClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 543 return c.internalClient.GetIamPolicy(ctx, req, opts...) 544 } 545 546 // SetIamPolicy sets the access control policy on the specified resource. Replaces 547 // any existing policy. 548 // 549 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 550 // errors. 551 func (c *JobClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 552 return c.internalClient.SetIamPolicy(ctx, req, opts...) 553 } 554 555 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 556 // resource does not exist, this will return an empty set of 557 // permissions, not a NOT_FOUND error. 558 // 559 // Note: This operation is designed to be used for building 560 // permission-aware UIs and command-line tools, not for authorization 561 // checking. This operation may “fail open” without warning. 562 func (c *JobClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 563 return c.internalClient.TestIamPermissions(ctx, req, opts...) 564 } 565 566 // CancelOperation is a utility method from google.longrunning.Operations. 567 func (c *JobClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 568 return c.internalClient.CancelOperation(ctx, req, opts...) 569 } 570 571 // DeleteOperation is a utility method from google.longrunning.Operations. 572 func (c *JobClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 573 return c.internalClient.DeleteOperation(ctx, req, opts...) 574 } 575 576 // GetOperation is a utility method from google.longrunning.Operations. 577 func (c *JobClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 578 return c.internalClient.GetOperation(ctx, req, opts...) 579 } 580 581 // ListOperations is a utility method from google.longrunning.Operations. 582 func (c *JobClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 583 return c.internalClient.ListOperations(ctx, req, opts...) 584 } 585 586 // WaitOperation is a utility method from google.longrunning.Operations. 587 func (c *JobClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 588 return c.internalClient.WaitOperation(ctx, req, opts...) 589 } 590 591 // jobGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 592 // 593 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 594 type jobGRPCClient struct { 595 // Connection pool of gRPC connections to the service. 596 connPool gtransport.ConnPool 597 598 // Points back to the CallOptions field of the containing JobClient 599 CallOptions **JobCallOptions 600 601 // The gRPC API client. 602 jobClient aiplatformpb.JobServiceClient 603 604 // LROClient is used internally to handle long-running operations. 605 // It is exposed so that its CallOptions can be modified if required. 606 // Users should not Close this client. 607 LROClient **lroauto.OperationsClient 608 609 operationsClient longrunningpb.OperationsClient 610 611 iamPolicyClient iampb.IAMPolicyClient 612 613 locationsClient locationpb.LocationsClient 614 615 // The x-goog-* metadata to be sent with each request. 616 xGoogHeaders []string 617 618 logger *slog.Logger 619 } 620 621 // NewJobClient creates a new job service client based on gRPC. 622 // The returned client must be Closed when it is done being used to clean up its underlying connections. 623 // 624 // A service for creating and managing Vertex AI’s jobs. 625 func NewJobClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) { 626 clientOpts := defaultJobGRPCClientOptions() 627 if newJobClientHook != nil { 628 hookOpts, err := newJobClientHook(ctx, clientHookParams{}) 629 if err != nil { 630 return nil, err 631 } 632 clientOpts = append(clientOpts, hookOpts...) 633 } 634 635 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 636 if err != nil { 637 return nil, err 638 } 639 client := JobClient{CallOptions: defaultJobCallOptions()} 640 641 c := &jobGRPCClient{ 642 connPool: connPool, 643 jobClient: aiplatformpb.NewJobServiceClient(connPool), 644 CallOptions: &client.CallOptions, 645 logger: internaloption.GetLogger(opts), 646 operationsClient: longrunningpb.NewOperationsClient(connPool), 647 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 648 locationsClient: locationpb.NewLocationsClient(connPool), 649 } 650 c.setGoogleClientInfo() 651 652 client.internalClient = c 653 654 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 655 if err != nil { 656 // This error "should not happen", since we are just reusing old connection pool 657 // and never actually need to dial. 658 // If this does happen, we could leak connp. However, we cannot close conn: 659 // If the user invoked the constructor with option.WithGRPCConn, 660 // we would close a connection that's still in use. 661 // TODO: investigate error conditions. 662 return nil, err 663 } 664 c.LROClient = &client.LROClient 665 return &client, nil 666 } 667 668 // Connection returns a connection to the API service. 669 // 670 // Deprecated: Connections are now pooled so this method does not always 671 // return the same resource. 672 func (c *jobGRPCClient) Connection() *grpc.ClientConn { 673 return c.connPool.Conn() 674 } 675 676 // setGoogleClientInfo sets the name and version of the application in 677 // the `x-goog-api-client` header passed on each request. Intended for 678 // use by Google-written clients. 679 func (c *jobGRPCClient) setGoogleClientInfo(keyval ...string) { 680 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 681 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 682 c.xGoogHeaders = []string{ 683 "x-goog-api-client", gax.XGoogHeader(kv...), 684 } 685 } 686 687 // Close closes the connection to the API service. The user should invoke this when 688 // the client is no longer required. 689 func (c *jobGRPCClient) Close() error { 690 return c.connPool.Close() 691 } 692 693 func (c *jobGRPCClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) { 694 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 695 696 hds = append(c.xGoogHeaders, hds...) 697 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 698 opts = append((*c.CallOptions).CreateCustomJob[0:len((*c.CallOptions).CreateCustomJob):len((*c.CallOptions).CreateCustomJob)], opts...) 699 var resp *aiplatformpb.CustomJob 700 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 701 var err error 702 resp, err = executeRPC(ctx, c.jobClient.CreateCustomJob, req, settings.GRPC, c.logger, "CreateCustomJob") 703 return err 704 }, opts...) 705 if err != nil { 706 return nil, err 707 } 708 return resp, nil 709 } 710 711 func (c *jobGRPCClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) { 712 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 713 714 hds = append(c.xGoogHeaders, hds...) 715 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 716 opts = append((*c.CallOptions).GetCustomJob[0:len((*c.CallOptions).GetCustomJob):len((*c.CallOptions).GetCustomJob)], opts...) 717 var resp *aiplatformpb.CustomJob 718 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 719 var err error 720 resp, err = executeRPC(ctx, c.jobClient.GetCustomJob, req, settings.GRPC, c.logger, "GetCustomJob") 721 return err 722 }, opts...) 723 if err != nil { 724 return nil, err 725 } 726 return resp, nil 727 } 728 729 func (c *jobGRPCClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator { 730 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 731 732 hds = append(c.xGoogHeaders, hds...) 733 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 734 opts = append((*c.CallOptions).ListCustomJobs[0:len((*c.CallOptions).ListCustomJobs):len((*c.CallOptions).ListCustomJobs)], opts...) 735 it := &CustomJobIterator{} 736 req = proto.Clone(req).(*aiplatformpb.ListCustomJobsRequest) 737 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.CustomJob, string, error) { 738 resp := &aiplatformpb.ListCustomJobsResponse{} 739 if pageToken != "" { 740 req.PageToken = pageToken 741 } 742 if pageSize > math.MaxInt32 { 743 req.PageSize = math.MaxInt32 744 } else if pageSize != 0 { 745 req.PageSize = int32(pageSize) 746 } 747 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 748 var err error 749 resp, err = executeRPC(ctx, c.jobClient.ListCustomJobs, req, settings.GRPC, c.logger, "ListCustomJobs") 750 return err 751 }, opts...) 752 if err != nil { 753 return nil, "", err 754 } 755 756 it.Response = resp 757 return resp.GetCustomJobs(), resp.GetNextPageToken(), nil 758 } 759 fetch := func(pageSize int, pageToken string) (string, error) { 760 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 761 if err != nil { 762 return "", err 763 } 764 it.items = append(it.items, items...) 765 return nextPageToken, nil 766 } 767 768 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 769 it.pageInfo.MaxSize = int(req.GetPageSize()) 770 it.pageInfo.Token = req.GetPageToken() 771 772 return it 773 } 774 775 func (c *jobGRPCClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) { 776 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 777 778 hds = append(c.xGoogHeaders, hds...) 779 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 780 opts = append((*c.CallOptions).DeleteCustomJob[0:len((*c.CallOptions).DeleteCustomJob):len((*c.CallOptions).DeleteCustomJob)], opts...) 781 var resp *longrunningpb.Operation 782 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 783 var err error 784 resp, err = executeRPC(ctx, c.jobClient.DeleteCustomJob, req, settings.GRPC, c.logger, "DeleteCustomJob") 785 return err 786 }, opts...) 787 if err != nil { 788 return nil, err 789 } 790 return &DeleteCustomJobOperation{ 791 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 792 }, nil 793 } 794 795 func (c *jobGRPCClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error { 796 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 797 798 hds = append(c.xGoogHeaders, hds...) 799 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 800 opts = append((*c.CallOptions).CancelCustomJob[0:len((*c.CallOptions).CancelCustomJob):len((*c.CallOptions).CancelCustomJob)], opts...) 801 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 802 var err error 803 _, err = executeRPC(ctx, c.jobClient.CancelCustomJob, req, settings.GRPC, c.logger, "CancelCustomJob") 804 return err 805 }, opts...) 806 return err 807 } 808 809 func (c *jobGRPCClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) { 810 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 811 812 hds = append(c.xGoogHeaders, hds...) 813 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 814 opts = append((*c.CallOptions).CreateDataLabelingJob[0:len((*c.CallOptions).CreateDataLabelingJob):len((*c.CallOptions).CreateDataLabelingJob)], opts...) 815 var resp *aiplatformpb.DataLabelingJob 816 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 817 var err error 818 resp, err = executeRPC(ctx, c.jobClient.CreateDataLabelingJob, req, settings.GRPC, c.logger, "CreateDataLabelingJob") 819 return err 820 }, opts...) 821 if err != nil { 822 return nil, err 823 } 824 return resp, nil 825 } 826 827 func (c *jobGRPCClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) { 828 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 829 830 hds = append(c.xGoogHeaders, hds...) 831 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 832 opts = append((*c.CallOptions).GetDataLabelingJob[0:len((*c.CallOptions).GetDataLabelingJob):len((*c.CallOptions).GetDataLabelingJob)], opts...) 833 var resp *aiplatformpb.DataLabelingJob 834 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 835 var err error 836 resp, err = executeRPC(ctx, c.jobClient.GetDataLabelingJob, req, settings.GRPC, c.logger, "GetDataLabelingJob") 837 return err 838 }, opts...) 839 if err != nil { 840 return nil, err 841 } 842 return resp, nil 843 } 844 845 func (c *jobGRPCClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator { 846 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 847 848 hds = append(c.xGoogHeaders, hds...) 849 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 850 opts = append((*c.CallOptions).ListDataLabelingJobs[0:len((*c.CallOptions).ListDataLabelingJobs):len((*c.CallOptions).ListDataLabelingJobs)], opts...) 851 it := &DataLabelingJobIterator{} 852 req = proto.Clone(req).(*aiplatformpb.ListDataLabelingJobsRequest) 853 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.DataLabelingJob, string, error) { 854 resp := &aiplatformpb.ListDataLabelingJobsResponse{} 855 if pageToken != "" { 856 req.PageToken = pageToken 857 } 858 if pageSize > math.MaxInt32 { 859 req.PageSize = math.MaxInt32 860 } else if pageSize != 0 { 861 req.PageSize = int32(pageSize) 862 } 863 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 864 var err error 865 resp, err = executeRPC(ctx, c.jobClient.ListDataLabelingJobs, req, settings.GRPC, c.logger, "ListDataLabelingJobs") 866 return err 867 }, opts...) 868 if err != nil { 869 return nil, "", err 870 } 871 872 it.Response = resp 873 return resp.GetDataLabelingJobs(), resp.GetNextPageToken(), nil 874 } 875 fetch := func(pageSize int, pageToken string) (string, error) { 876 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 877 if err != nil { 878 return "", err 879 } 880 it.items = append(it.items, items...) 881 return nextPageToken, nil 882 } 883 884 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 885 it.pageInfo.MaxSize = int(req.GetPageSize()) 886 it.pageInfo.Token = req.GetPageToken() 887 888 return it 889 } 890 891 func (c *jobGRPCClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) { 892 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 893 894 hds = append(c.xGoogHeaders, hds...) 895 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 896 opts = append((*c.CallOptions).DeleteDataLabelingJob[0:len((*c.CallOptions).DeleteDataLabelingJob):len((*c.CallOptions).DeleteDataLabelingJob)], opts...) 897 var resp *longrunningpb.Operation 898 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 899 var err error 900 resp, err = executeRPC(ctx, c.jobClient.DeleteDataLabelingJob, req, settings.GRPC, c.logger, "DeleteDataLabelingJob") 901 return err 902 }, opts...) 903 if err != nil { 904 return nil, err 905 } 906 return &DeleteDataLabelingJobOperation{ 907 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 908 }, nil 909 } 910 911 func (c *jobGRPCClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error { 912 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 913 914 hds = append(c.xGoogHeaders, hds...) 915 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 916 opts = append((*c.CallOptions).CancelDataLabelingJob[0:len((*c.CallOptions).CancelDataLabelingJob):len((*c.CallOptions).CancelDataLabelingJob)], opts...) 917 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 918 var err error 919 _, err = executeRPC(ctx, c.jobClient.CancelDataLabelingJob, req, settings.GRPC, c.logger, "CancelDataLabelingJob") 920 return err 921 }, opts...) 922 return err 923 } 924 925 func (c *jobGRPCClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) { 926 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 927 928 hds = append(c.xGoogHeaders, hds...) 929 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 930 opts = append((*c.CallOptions).CreateHyperparameterTuningJob[0:len((*c.CallOptions).CreateHyperparameterTuningJob):len((*c.CallOptions).CreateHyperparameterTuningJob)], opts...) 931 var resp *aiplatformpb.HyperparameterTuningJob 932 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 933 var err error 934 resp, err = executeRPC(ctx, c.jobClient.CreateHyperparameterTuningJob, req, settings.GRPC, c.logger, "CreateHyperparameterTuningJob") 935 return err 936 }, opts...) 937 if err != nil { 938 return nil, err 939 } 940 return resp, nil 941 } 942 943 func (c *jobGRPCClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) { 944 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 945 946 hds = append(c.xGoogHeaders, hds...) 947 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 948 opts = append((*c.CallOptions).GetHyperparameterTuningJob[0:len((*c.CallOptions).GetHyperparameterTuningJob):len((*c.CallOptions).GetHyperparameterTuningJob)], opts...) 949 var resp *aiplatformpb.HyperparameterTuningJob 950 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 951 var err error 952 resp, err = executeRPC(ctx, c.jobClient.GetHyperparameterTuningJob, req, settings.GRPC, c.logger, "GetHyperparameterTuningJob") 953 return err 954 }, opts...) 955 if err != nil { 956 return nil, err 957 } 958 return resp, nil 959 } 960 961 func (c *jobGRPCClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator { 962 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 963 964 hds = append(c.xGoogHeaders, hds...) 965 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 966 opts = append((*c.CallOptions).ListHyperparameterTuningJobs[0:len((*c.CallOptions).ListHyperparameterTuningJobs):len((*c.CallOptions).ListHyperparameterTuningJobs)], opts...) 967 it := &HyperparameterTuningJobIterator{} 968 req = proto.Clone(req).(*aiplatformpb.ListHyperparameterTuningJobsRequest) 969 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.HyperparameterTuningJob, string, error) { 970 resp := &aiplatformpb.ListHyperparameterTuningJobsResponse{} 971 if pageToken != "" { 972 req.PageToken = pageToken 973 } 974 if pageSize > math.MaxInt32 { 975 req.PageSize = math.MaxInt32 976 } else if pageSize != 0 { 977 req.PageSize = int32(pageSize) 978 } 979 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 980 var err error 981 resp, err = executeRPC(ctx, c.jobClient.ListHyperparameterTuningJobs, req, settings.GRPC, c.logger, "ListHyperparameterTuningJobs") 982 return err 983 }, opts...) 984 if err != nil { 985 return nil, "", err 986 } 987 988 it.Response = resp 989 return resp.GetHyperparameterTuningJobs(), resp.GetNextPageToken(), nil 990 } 991 fetch := func(pageSize int, pageToken string) (string, error) { 992 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 993 if err != nil { 994 return "", err 995 } 996 it.items = append(it.items, items...) 997 return nextPageToken, nil 998 } 999 1000 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1001 it.pageInfo.MaxSize = int(req.GetPageSize()) 1002 it.pageInfo.Token = req.GetPageToken() 1003 1004 return it 1005 } 1006 1007 func (c *jobGRPCClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) { 1008 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1009 1010 hds = append(c.xGoogHeaders, hds...) 1011 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1012 opts = append((*c.CallOptions).DeleteHyperparameterTuningJob[0:len((*c.CallOptions).DeleteHyperparameterTuningJob):len((*c.CallOptions).DeleteHyperparameterTuningJob)], opts...) 1013 var resp *longrunningpb.Operation 1014 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1015 var err error 1016 resp, err = executeRPC(ctx, c.jobClient.DeleteHyperparameterTuningJob, req, settings.GRPC, c.logger, "DeleteHyperparameterTuningJob") 1017 return err 1018 }, opts...) 1019 if err != nil { 1020 return nil, err 1021 } 1022 return &DeleteHyperparameterTuningJobOperation{ 1023 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1024 }, nil 1025 } 1026 1027 func (c *jobGRPCClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error { 1028 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1029 1030 hds = append(c.xGoogHeaders, hds...) 1031 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1032 opts = append((*c.CallOptions).CancelHyperparameterTuningJob[0:len((*c.CallOptions).CancelHyperparameterTuningJob):len((*c.CallOptions).CancelHyperparameterTuningJob)], opts...) 1033 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1034 var err error 1035 _, err = executeRPC(ctx, c.jobClient.CancelHyperparameterTuningJob, req, settings.GRPC, c.logger, "CancelHyperparameterTuningJob") 1036 return err 1037 }, opts...) 1038 return err 1039 } 1040 1041 func (c *jobGRPCClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) { 1042 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1043 1044 hds = append(c.xGoogHeaders, hds...) 1045 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1046 opts = append((*c.CallOptions).CreateNasJob[0:len((*c.CallOptions).CreateNasJob):len((*c.CallOptions).CreateNasJob)], opts...) 1047 var resp *aiplatformpb.NasJob 1048 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1049 var err error 1050 resp, err = executeRPC(ctx, c.jobClient.CreateNasJob, req, settings.GRPC, c.logger, "CreateNasJob") 1051 return err 1052 }, opts...) 1053 if err != nil { 1054 return nil, err 1055 } 1056 return resp, nil 1057 } 1058 1059 func (c *jobGRPCClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) { 1060 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1061 1062 hds = append(c.xGoogHeaders, hds...) 1063 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1064 opts = append((*c.CallOptions).GetNasJob[0:len((*c.CallOptions).GetNasJob):len((*c.CallOptions).GetNasJob)], opts...) 1065 var resp *aiplatformpb.NasJob 1066 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1067 var err error 1068 resp, err = executeRPC(ctx, c.jobClient.GetNasJob, req, settings.GRPC, c.logger, "GetNasJob") 1069 return err 1070 }, opts...) 1071 if err != nil { 1072 return nil, err 1073 } 1074 return resp, nil 1075 } 1076 1077 func (c *jobGRPCClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator { 1078 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1079 1080 hds = append(c.xGoogHeaders, hds...) 1081 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1082 opts = append((*c.CallOptions).ListNasJobs[0:len((*c.CallOptions).ListNasJobs):len((*c.CallOptions).ListNasJobs)], opts...) 1083 it := &NasJobIterator{} 1084 req = proto.Clone(req).(*aiplatformpb.ListNasJobsRequest) 1085 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasJob, string, error) { 1086 resp := &aiplatformpb.ListNasJobsResponse{} 1087 if pageToken != "" { 1088 req.PageToken = pageToken 1089 } 1090 if pageSize > math.MaxInt32 { 1091 req.PageSize = math.MaxInt32 1092 } else if pageSize != 0 { 1093 req.PageSize = int32(pageSize) 1094 } 1095 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1096 var err error 1097 resp, err = executeRPC(ctx, c.jobClient.ListNasJobs, req, settings.GRPC, c.logger, "ListNasJobs") 1098 return err 1099 }, opts...) 1100 if err != nil { 1101 return nil, "", err 1102 } 1103 1104 it.Response = resp 1105 return resp.GetNasJobs(), resp.GetNextPageToken(), nil 1106 } 1107 fetch := func(pageSize int, pageToken string) (string, error) { 1108 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1109 if err != nil { 1110 return "", err 1111 } 1112 it.items = append(it.items, items...) 1113 return nextPageToken, nil 1114 } 1115 1116 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1117 it.pageInfo.MaxSize = int(req.GetPageSize()) 1118 it.pageInfo.Token = req.GetPageToken() 1119 1120 return it 1121 } 1122 1123 func (c *jobGRPCClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) { 1124 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1125 1126 hds = append(c.xGoogHeaders, hds...) 1127 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1128 opts = append((*c.CallOptions).DeleteNasJob[0:len((*c.CallOptions).DeleteNasJob):len((*c.CallOptions).DeleteNasJob)], opts...) 1129 var resp *longrunningpb.Operation 1130 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1131 var err error 1132 resp, err = executeRPC(ctx, c.jobClient.DeleteNasJob, req, settings.GRPC, c.logger, "DeleteNasJob") 1133 return err 1134 }, opts...) 1135 if err != nil { 1136 return nil, err 1137 } 1138 return &DeleteNasJobOperation{ 1139 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1140 }, nil 1141 } 1142 1143 func (c *jobGRPCClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) error { 1144 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1145 1146 hds = append(c.xGoogHeaders, hds...) 1147 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1148 opts = append((*c.CallOptions).CancelNasJob[0:len((*c.CallOptions).CancelNasJob):len((*c.CallOptions).CancelNasJob)], opts...) 1149 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1150 var err error 1151 _, err = executeRPC(ctx, c.jobClient.CancelNasJob, req, settings.GRPC, c.logger, "CancelNasJob") 1152 return err 1153 }, opts...) 1154 return err 1155 } 1156 1157 func (c *jobGRPCClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) { 1158 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1159 1160 hds = append(c.xGoogHeaders, hds...) 1161 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1162 opts = append((*c.CallOptions).GetNasTrialDetail[0:len((*c.CallOptions).GetNasTrialDetail):len((*c.CallOptions).GetNasTrialDetail)], opts...) 1163 var resp *aiplatformpb.NasTrialDetail 1164 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1165 var err error 1166 resp, err = executeRPC(ctx, c.jobClient.GetNasTrialDetail, req, settings.GRPC, c.logger, "GetNasTrialDetail") 1167 return err 1168 }, opts...) 1169 if err != nil { 1170 return nil, err 1171 } 1172 return resp, nil 1173 } 1174 1175 func (c *jobGRPCClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator { 1176 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1177 1178 hds = append(c.xGoogHeaders, hds...) 1179 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1180 opts = append((*c.CallOptions).ListNasTrialDetails[0:len((*c.CallOptions).ListNasTrialDetails):len((*c.CallOptions).ListNasTrialDetails)], opts...) 1181 it := &NasTrialDetailIterator{} 1182 req = proto.Clone(req).(*aiplatformpb.ListNasTrialDetailsRequest) 1183 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasTrialDetail, string, error) { 1184 resp := &aiplatformpb.ListNasTrialDetailsResponse{} 1185 if pageToken != "" { 1186 req.PageToken = pageToken 1187 } 1188 if pageSize > math.MaxInt32 { 1189 req.PageSize = math.MaxInt32 1190 } else if pageSize != 0 { 1191 req.PageSize = int32(pageSize) 1192 } 1193 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1194 var err error 1195 resp, err = executeRPC(ctx, c.jobClient.ListNasTrialDetails, req, settings.GRPC, c.logger, "ListNasTrialDetails") 1196 return err 1197 }, opts...) 1198 if err != nil { 1199 return nil, "", err 1200 } 1201 1202 it.Response = resp 1203 return resp.GetNasTrialDetails(), resp.GetNextPageToken(), nil 1204 } 1205 fetch := func(pageSize int, pageToken string) (string, error) { 1206 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1207 if err != nil { 1208 return "", err 1209 } 1210 it.items = append(it.items, items...) 1211 return nextPageToken, nil 1212 } 1213 1214 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1215 it.pageInfo.MaxSize = int(req.GetPageSize()) 1216 it.pageInfo.Token = req.GetPageToken() 1217 1218 return it 1219 } 1220 1221 func (c *jobGRPCClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) { 1222 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1223 1224 hds = append(c.xGoogHeaders, hds...) 1225 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1226 opts = append((*c.CallOptions).CreateBatchPredictionJob[0:len((*c.CallOptions).CreateBatchPredictionJob):len((*c.CallOptions).CreateBatchPredictionJob)], opts...) 1227 var resp *aiplatformpb.BatchPredictionJob 1228 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1229 var err error 1230 resp, err = executeRPC(ctx, c.jobClient.CreateBatchPredictionJob, req, settings.GRPC, c.logger, "CreateBatchPredictionJob") 1231 return err 1232 }, opts...) 1233 if err != nil { 1234 return nil, err 1235 } 1236 return resp, nil 1237 } 1238 1239 func (c *jobGRPCClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) { 1240 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1241 1242 hds = append(c.xGoogHeaders, hds...) 1243 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1244 opts = append((*c.CallOptions).GetBatchPredictionJob[0:len((*c.CallOptions).GetBatchPredictionJob):len((*c.CallOptions).GetBatchPredictionJob)], opts...) 1245 var resp *aiplatformpb.BatchPredictionJob 1246 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1247 var err error 1248 resp, err = executeRPC(ctx, c.jobClient.GetBatchPredictionJob, req, settings.GRPC, c.logger, "GetBatchPredictionJob") 1249 return err 1250 }, opts...) 1251 if err != nil { 1252 return nil, err 1253 } 1254 return resp, nil 1255 } 1256 1257 func (c *jobGRPCClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator { 1258 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1259 1260 hds = append(c.xGoogHeaders, hds...) 1261 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1262 opts = append((*c.CallOptions).ListBatchPredictionJobs[0:len((*c.CallOptions).ListBatchPredictionJobs):len((*c.CallOptions).ListBatchPredictionJobs)], opts...) 1263 it := &BatchPredictionJobIterator{} 1264 req = proto.Clone(req).(*aiplatformpb.ListBatchPredictionJobsRequest) 1265 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.BatchPredictionJob, string, error) { 1266 resp := &aiplatformpb.ListBatchPredictionJobsResponse{} 1267 if pageToken != "" { 1268 req.PageToken = pageToken 1269 } 1270 if pageSize > math.MaxInt32 { 1271 req.PageSize = math.MaxInt32 1272 } else if pageSize != 0 { 1273 req.PageSize = int32(pageSize) 1274 } 1275 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1276 var err error 1277 resp, err = executeRPC(ctx, c.jobClient.ListBatchPredictionJobs, req, settings.GRPC, c.logger, "ListBatchPredictionJobs") 1278 return err 1279 }, opts...) 1280 if err != nil { 1281 return nil, "", err 1282 } 1283 1284 it.Response = resp 1285 return resp.GetBatchPredictionJobs(), resp.GetNextPageToken(), nil 1286 } 1287 fetch := func(pageSize int, pageToken string) (string, error) { 1288 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1289 if err != nil { 1290 return "", err 1291 } 1292 it.items = append(it.items, items...) 1293 return nextPageToken, nil 1294 } 1295 1296 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1297 it.pageInfo.MaxSize = int(req.GetPageSize()) 1298 it.pageInfo.Token = req.GetPageToken() 1299 1300 return it 1301 } 1302 1303 func (c *jobGRPCClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) { 1304 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1305 1306 hds = append(c.xGoogHeaders, hds...) 1307 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1308 opts = append((*c.CallOptions).DeleteBatchPredictionJob[0:len((*c.CallOptions).DeleteBatchPredictionJob):len((*c.CallOptions).DeleteBatchPredictionJob)], opts...) 1309 var resp *longrunningpb.Operation 1310 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1311 var err error 1312 resp, err = executeRPC(ctx, c.jobClient.DeleteBatchPredictionJob, req, settings.GRPC, c.logger, "DeleteBatchPredictionJob") 1313 return err 1314 }, opts...) 1315 if err != nil { 1316 return nil, err 1317 } 1318 return &DeleteBatchPredictionJobOperation{ 1319 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1320 }, nil 1321 } 1322 1323 func (c *jobGRPCClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error { 1324 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1325 1326 hds = append(c.xGoogHeaders, hds...) 1327 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1328 opts = append((*c.CallOptions).CancelBatchPredictionJob[0:len((*c.CallOptions).CancelBatchPredictionJob):len((*c.CallOptions).CancelBatchPredictionJob)], opts...) 1329 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1330 var err error 1331 _, err = executeRPC(ctx, c.jobClient.CancelBatchPredictionJob, req, settings.GRPC, c.logger, "CancelBatchPredictionJob") 1332 return err 1333 }, opts...) 1334 return err 1335 } 1336 1337 func (c *jobGRPCClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) { 1338 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1339 1340 hds = append(c.xGoogHeaders, hds...) 1341 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1342 opts = append((*c.CallOptions).CreateModelDeploymentMonitoringJob[0:len((*c.CallOptions).CreateModelDeploymentMonitoringJob):len((*c.CallOptions).CreateModelDeploymentMonitoringJob)], opts...) 1343 var resp *aiplatformpb.ModelDeploymentMonitoringJob 1344 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1345 var err error 1346 resp, err = executeRPC(ctx, c.jobClient.CreateModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "CreateModelDeploymentMonitoringJob") 1347 return err 1348 }, opts...) 1349 if err != nil { 1350 return nil, err 1351 } 1352 return resp, nil 1353 } 1354 1355 func (c *jobGRPCClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator { 1356 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model_deployment_monitoring_job", url.QueryEscape(req.GetModelDeploymentMonitoringJob()))} 1357 1358 hds = append(c.xGoogHeaders, hds...) 1359 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1360 opts = append((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies[0:len((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies):len((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies)], opts...) 1361 it := &ModelMonitoringStatsAnomaliesIterator{} 1362 req = proto.Clone(req).(*aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest) 1363 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelMonitoringStatsAnomalies, string, error) { 1364 resp := &aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesResponse{} 1365 if pageToken != "" { 1366 req.PageToken = pageToken 1367 } 1368 if pageSize > math.MaxInt32 { 1369 req.PageSize = math.MaxInt32 1370 } else if pageSize != 0 { 1371 req.PageSize = int32(pageSize) 1372 } 1373 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1374 var err error 1375 resp, err = executeRPC(ctx, c.jobClient.SearchModelDeploymentMonitoringStatsAnomalies, req, settings.GRPC, c.logger, "SearchModelDeploymentMonitoringStatsAnomalies") 1376 return err 1377 }, opts...) 1378 if err != nil { 1379 return nil, "", err 1380 } 1381 1382 it.Response = resp 1383 return resp.GetMonitoringStats(), resp.GetNextPageToken(), nil 1384 } 1385 fetch := func(pageSize int, pageToken string) (string, error) { 1386 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1387 if err != nil { 1388 return "", err 1389 } 1390 it.items = append(it.items, items...) 1391 return nextPageToken, nil 1392 } 1393 1394 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1395 it.pageInfo.MaxSize = int(req.GetPageSize()) 1396 it.pageInfo.Token = req.GetPageToken() 1397 1398 return it 1399 } 1400 1401 func (c *jobGRPCClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) { 1402 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1403 1404 hds = append(c.xGoogHeaders, hds...) 1405 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1406 opts = append((*c.CallOptions).GetModelDeploymentMonitoringJob[0:len((*c.CallOptions).GetModelDeploymentMonitoringJob):len((*c.CallOptions).GetModelDeploymentMonitoringJob)], opts...) 1407 var resp *aiplatformpb.ModelDeploymentMonitoringJob 1408 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1409 var err error 1410 resp, err = executeRPC(ctx, c.jobClient.GetModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "GetModelDeploymentMonitoringJob") 1411 return err 1412 }, opts...) 1413 if err != nil { 1414 return nil, err 1415 } 1416 return resp, nil 1417 } 1418 1419 func (c *jobGRPCClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator { 1420 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1421 1422 hds = append(c.xGoogHeaders, hds...) 1423 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1424 opts = append((*c.CallOptions).ListModelDeploymentMonitoringJobs[0:len((*c.CallOptions).ListModelDeploymentMonitoringJobs):len((*c.CallOptions).ListModelDeploymentMonitoringJobs)], opts...) 1425 it := &ModelDeploymentMonitoringJobIterator{} 1426 req = proto.Clone(req).(*aiplatformpb.ListModelDeploymentMonitoringJobsRequest) 1427 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelDeploymentMonitoringJob, string, error) { 1428 resp := &aiplatformpb.ListModelDeploymentMonitoringJobsResponse{} 1429 if pageToken != "" { 1430 req.PageToken = pageToken 1431 } 1432 if pageSize > math.MaxInt32 { 1433 req.PageSize = math.MaxInt32 1434 } else if pageSize != 0 { 1435 req.PageSize = int32(pageSize) 1436 } 1437 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1438 var err error 1439 resp, err = executeRPC(ctx, c.jobClient.ListModelDeploymentMonitoringJobs, req, settings.GRPC, c.logger, "ListModelDeploymentMonitoringJobs") 1440 return err 1441 }, opts...) 1442 if err != nil { 1443 return nil, "", err 1444 } 1445 1446 it.Response = resp 1447 return resp.GetModelDeploymentMonitoringJobs(), resp.GetNextPageToken(), nil 1448 } 1449 fetch := func(pageSize int, pageToken string) (string, error) { 1450 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1451 if err != nil { 1452 return "", err 1453 } 1454 it.items = append(it.items, items...) 1455 return nextPageToken, nil 1456 } 1457 1458 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1459 it.pageInfo.MaxSize = int(req.GetPageSize()) 1460 it.pageInfo.Token = req.GetPageToken() 1461 1462 return it 1463 } 1464 1465 func (c *jobGRPCClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) { 1466 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model_deployment_monitoring_job.name", url.QueryEscape(req.GetModelDeploymentMonitoringJob().GetName()))} 1467 1468 hds = append(c.xGoogHeaders, hds...) 1469 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1470 opts = append((*c.CallOptions).UpdateModelDeploymentMonitoringJob[0:len((*c.CallOptions).UpdateModelDeploymentMonitoringJob):len((*c.CallOptions).UpdateModelDeploymentMonitoringJob)], opts...) 1471 var resp *longrunningpb.Operation 1472 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1473 var err error 1474 resp, err = executeRPC(ctx, c.jobClient.UpdateModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "UpdateModelDeploymentMonitoringJob") 1475 return err 1476 }, opts...) 1477 if err != nil { 1478 return nil, err 1479 } 1480 return &UpdateModelDeploymentMonitoringJobOperation{ 1481 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1482 }, nil 1483 } 1484 1485 func (c *jobGRPCClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) { 1486 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1487 1488 hds = append(c.xGoogHeaders, hds...) 1489 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1490 opts = append((*c.CallOptions).DeleteModelDeploymentMonitoringJob[0:len((*c.CallOptions).DeleteModelDeploymentMonitoringJob):len((*c.CallOptions).DeleteModelDeploymentMonitoringJob)], opts...) 1491 var resp *longrunningpb.Operation 1492 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1493 var err error 1494 resp, err = executeRPC(ctx, c.jobClient.DeleteModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "DeleteModelDeploymentMonitoringJob") 1495 return err 1496 }, opts...) 1497 if err != nil { 1498 return nil, err 1499 } 1500 return &DeleteModelDeploymentMonitoringJobOperation{ 1501 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1502 }, nil 1503 } 1504 1505 func (c *jobGRPCClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error { 1506 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1507 1508 hds = append(c.xGoogHeaders, hds...) 1509 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1510 opts = append((*c.CallOptions).PauseModelDeploymentMonitoringJob[0:len((*c.CallOptions).PauseModelDeploymentMonitoringJob):len((*c.CallOptions).PauseModelDeploymentMonitoringJob)], opts...) 1511 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1512 var err error 1513 _, err = executeRPC(ctx, c.jobClient.PauseModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "PauseModelDeploymentMonitoringJob") 1514 return err 1515 }, opts...) 1516 return err 1517 } 1518 1519 func (c *jobGRPCClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error { 1520 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1521 1522 hds = append(c.xGoogHeaders, hds...) 1523 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1524 opts = append((*c.CallOptions).ResumeModelDeploymentMonitoringJob[0:len((*c.CallOptions).ResumeModelDeploymentMonitoringJob):len((*c.CallOptions).ResumeModelDeploymentMonitoringJob)], opts...) 1525 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1526 var err error 1527 _, err = executeRPC(ctx, c.jobClient.ResumeModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "ResumeModelDeploymentMonitoringJob") 1528 return err 1529 }, opts...) 1530 return err 1531 } 1532 1533 func (c *jobGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 1534 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1535 1536 hds = append(c.xGoogHeaders, hds...) 1537 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1538 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 1539 var resp *locationpb.Location 1540 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1541 var err error 1542 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 1543 return err 1544 }, opts...) 1545 if err != nil { 1546 return nil, err 1547 } 1548 return resp, nil 1549 } 1550 1551 func (c *jobGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 1552 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1553 1554 hds = append(c.xGoogHeaders, hds...) 1555 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1556 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 1557 it := &LocationIterator{} 1558 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 1559 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 1560 resp := &locationpb.ListLocationsResponse{} 1561 if pageToken != "" { 1562 req.PageToken = pageToken 1563 } 1564 if pageSize > math.MaxInt32 { 1565 req.PageSize = math.MaxInt32 1566 } else if pageSize != 0 { 1567 req.PageSize = int32(pageSize) 1568 } 1569 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1570 var err error 1571 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 1572 return err 1573 }, opts...) 1574 if err != nil { 1575 return nil, "", err 1576 } 1577 1578 it.Response = resp 1579 return resp.GetLocations(), resp.GetNextPageToken(), nil 1580 } 1581 fetch := func(pageSize int, pageToken string) (string, error) { 1582 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1583 if err != nil { 1584 return "", err 1585 } 1586 it.items = append(it.items, items...) 1587 return nextPageToken, nil 1588 } 1589 1590 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1591 it.pageInfo.MaxSize = int(req.GetPageSize()) 1592 it.pageInfo.Token = req.GetPageToken() 1593 1594 return it 1595 } 1596 1597 func (c *jobGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1598 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1599 1600 hds = append(c.xGoogHeaders, hds...) 1601 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1602 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 1603 var resp *iampb.Policy 1604 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1605 var err error 1606 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 1607 return err 1608 }, opts...) 1609 if err != nil { 1610 return nil, err 1611 } 1612 return resp, nil 1613 } 1614 1615 func (c *jobGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1616 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1617 1618 hds = append(c.xGoogHeaders, hds...) 1619 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1620 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 1621 var resp *iampb.Policy 1622 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1623 var err error 1624 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 1625 return err 1626 }, opts...) 1627 if err != nil { 1628 return nil, err 1629 } 1630 return resp, nil 1631 } 1632 1633 func (c *jobGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 1634 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1635 1636 hds = append(c.xGoogHeaders, hds...) 1637 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1638 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 1639 var resp *iampb.TestIamPermissionsResponse 1640 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1641 var err error 1642 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 1643 return err 1644 }, opts...) 1645 if err != nil { 1646 return nil, err 1647 } 1648 return resp, nil 1649 } 1650 1651 func (c *jobGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 1652 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1653 1654 hds = append(c.xGoogHeaders, hds...) 1655 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1656 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 1657 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1658 var err error 1659 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 1660 return err 1661 }, opts...) 1662 return err 1663 } 1664 1665 func (c *jobGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 1666 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1667 1668 hds = append(c.xGoogHeaders, hds...) 1669 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1670 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 1671 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1672 var err error 1673 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 1674 return err 1675 }, opts...) 1676 return err 1677 } 1678 1679 func (c *jobGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1680 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1681 1682 hds = append(c.xGoogHeaders, hds...) 1683 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1684 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 1685 var resp *longrunningpb.Operation 1686 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1687 var err error 1688 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 1689 return err 1690 }, opts...) 1691 if err != nil { 1692 return nil, err 1693 } 1694 return resp, nil 1695 } 1696 1697 func (c *jobGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 1698 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1699 1700 hds = append(c.xGoogHeaders, hds...) 1701 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1702 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 1703 it := &OperationIterator{} 1704 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 1705 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 1706 resp := &longrunningpb.ListOperationsResponse{} 1707 if pageToken != "" { 1708 req.PageToken = pageToken 1709 } 1710 if pageSize > math.MaxInt32 { 1711 req.PageSize = math.MaxInt32 1712 } else if pageSize != 0 { 1713 req.PageSize = int32(pageSize) 1714 } 1715 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1716 var err error 1717 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 1718 return err 1719 }, opts...) 1720 if err != nil { 1721 return nil, "", err 1722 } 1723 1724 it.Response = resp 1725 return resp.GetOperations(), resp.GetNextPageToken(), nil 1726 } 1727 fetch := func(pageSize int, pageToken string) (string, error) { 1728 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1729 if err != nil { 1730 return "", err 1731 } 1732 it.items = append(it.items, items...) 1733 return nextPageToken, nil 1734 } 1735 1736 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1737 it.pageInfo.MaxSize = int(req.GetPageSize()) 1738 it.pageInfo.Token = req.GetPageToken() 1739 1740 return it 1741 } 1742 1743 func (c *jobGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1744 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1745 1746 hds = append(c.xGoogHeaders, hds...) 1747 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1748 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 1749 var resp *longrunningpb.Operation 1750 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1751 var err error 1752 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 1753 return err 1754 }, opts...) 1755 if err != nil { 1756 return nil, err 1757 } 1758 return resp, nil 1759 } 1760 1761 // DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name. 1762 // The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process. 1763 func (c *jobGRPCClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation { 1764 return &DeleteBatchPredictionJobOperation{ 1765 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1766 } 1767 } 1768 1769 // DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name. 1770 // The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process. 1771 func (c *jobGRPCClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation { 1772 return &DeleteCustomJobOperation{ 1773 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1774 } 1775 } 1776 1777 // DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name. 1778 // The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process. 1779 func (c *jobGRPCClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation { 1780 return &DeleteDataLabelingJobOperation{ 1781 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1782 } 1783 } 1784 1785 // DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name. 1786 // The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process. 1787 func (c *jobGRPCClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation { 1788 return &DeleteHyperparameterTuningJobOperation{ 1789 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1790 } 1791 } 1792 1793 // DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name. 1794 // The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process. 1795 func (c *jobGRPCClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation { 1796 return &DeleteModelDeploymentMonitoringJobOperation{ 1797 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1798 } 1799 } 1800 1801 // DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name. 1802 // The name must be that of a previously created DeleteNasJobOperation, possibly from a different process. 1803 func (c *jobGRPCClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation { 1804 return &DeleteNasJobOperation{ 1805 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1806 } 1807 } 1808 1809 // UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name. 1810 // The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process. 1811 func (c *jobGRPCClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation { 1812 return &UpdateModelDeploymentMonitoringJobOperation{ 1813 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1814 } 1815 }