cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/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  	"bytes"
    21  	"context"
    22  	"fmt"
    23  	"log/slog"
    24  	"math"
    25  	"net/http"
    26  	"net/url"
    27  	"time"
    28  
    29  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    30  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    31  	"cloud.google.com/go/longrunning"
    32  	lroauto "cloud.google.com/go/longrunning/autogen"
    33  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    34  	gax "github.com/googleapis/gax-go/v2"
    35  	"google.golang.org/api/iterator"
    36  	"google.golang.org/api/option"
    37  	"google.golang.org/api/option/internaloption"
    38  	gtransport "google.golang.org/api/transport/grpc"
    39  	httptransport "google.golang.org/api/transport/http"
    40  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    41  	"google.golang.org/grpc"
    42  	"google.golang.org/protobuf/encoding/protojson"
    43  	"google.golang.org/protobuf/proto"
    44  )
    45  
    46  var newJobClientHook clientHook
    47  
    48  // JobCallOptions contains the retry settings for each method of JobClient.
    49  type JobCallOptions struct {
    50  	CreateCustomJob                               []gax.CallOption
    51  	GetCustomJob                                  []gax.CallOption
    52  	ListCustomJobs                                []gax.CallOption
    53  	DeleteCustomJob                               []gax.CallOption
    54  	CancelCustomJob                               []gax.CallOption
    55  	CreateDataLabelingJob                         []gax.CallOption
    56  	GetDataLabelingJob                            []gax.CallOption
    57  	ListDataLabelingJobs                          []gax.CallOption
    58  	DeleteDataLabelingJob                         []gax.CallOption
    59  	CancelDataLabelingJob                         []gax.CallOption
    60  	CreateHyperparameterTuningJob                 []gax.CallOption
    61  	GetHyperparameterTuningJob                    []gax.CallOption
    62  	ListHyperparameterTuningJobs                  []gax.CallOption
    63  	DeleteHyperparameterTuningJob                 []gax.CallOption
    64  	CancelHyperparameterTuningJob                 []gax.CallOption
    65  	CreateNasJob                                  []gax.CallOption
    66  	GetNasJob                                     []gax.CallOption
    67  	ListNasJobs                                   []gax.CallOption
    68  	DeleteNasJob                                  []gax.CallOption
    69  	CancelNasJob                                  []gax.CallOption
    70  	GetNasTrialDetail                             []gax.CallOption
    71  	ListNasTrialDetails                           []gax.CallOption
    72  	CreateBatchPredictionJob                      []gax.CallOption
    73  	GetBatchPredictionJob                         []gax.CallOption
    74  	ListBatchPredictionJobs                       []gax.CallOption
    75  	DeleteBatchPredictionJob                      []gax.CallOption
    76  	CancelBatchPredictionJob                      []gax.CallOption
    77  	CreateModelDeploymentMonitoringJob            []gax.CallOption
    78  	SearchModelDeploymentMonitoringStatsAnomalies []gax.CallOption
    79  	GetModelDeploymentMonitoringJob               []gax.CallOption
    80  	ListModelDeploymentMonitoringJobs             []gax.CallOption
    81  	UpdateModelDeploymentMonitoringJob            []gax.CallOption
    82  	DeleteModelDeploymentMonitoringJob            []gax.CallOption
    83  	PauseModelDeploymentMonitoringJob             []gax.CallOption
    84  	ResumeModelDeploymentMonitoringJob            []gax.CallOption
    85  	GetLocation                                   []gax.CallOption
    86  	ListLocations                                 []gax.CallOption
    87  	GetIamPolicy                                  []gax.CallOption
    88  	SetIamPolicy                                  []gax.CallOption
    89  	TestIamPermissions                            []gax.CallOption
    90  	CancelOperation                               []gax.CallOption
    91  	DeleteOperation                               []gax.CallOption
    92  	GetOperation                                  []gax.CallOption
    93  	ListOperations                                []gax.CallOption
    94  	WaitOperation                                 []gax.CallOption
    95  }
    96  
    97  func defaultJobGRPCClientOptions() []option.ClientOption {
    98  	return []option.ClientOption{
    99  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
   100  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
   101  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
   102  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   103  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   104  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   105  		internaloption.EnableJwtWithScope(),
   106  		internaloption.EnableNewAuthLibrary(),
   107  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
   108  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
   109  	}
   110  }
   111  
   112  func defaultJobCallOptions() *JobCallOptions {
   113  	return &JobCallOptions{
   114  		CreateCustomJob: []gax.CallOption{
   115  			gax.WithTimeout(5000 * time.Millisecond),
   116  		},
   117  		GetCustomJob: []gax.CallOption{
   118  			gax.WithTimeout(5000 * time.Millisecond),
   119  		},
   120  		ListCustomJobs: []gax.CallOption{
   121  			gax.WithTimeout(5000 * time.Millisecond),
   122  		},
   123  		DeleteCustomJob: []gax.CallOption{
   124  			gax.WithTimeout(5000 * time.Millisecond),
   125  		},
   126  		CancelCustomJob: []gax.CallOption{
   127  			gax.WithTimeout(5000 * time.Millisecond),
   128  		},
   129  		CreateDataLabelingJob: []gax.CallOption{
   130  			gax.WithTimeout(5000 * time.Millisecond),
   131  		},
   132  		GetDataLabelingJob: []gax.CallOption{
   133  			gax.WithTimeout(5000 * time.Millisecond),
   134  		},
   135  		ListDataLabelingJobs: []gax.CallOption{
   136  			gax.WithTimeout(5000 * time.Millisecond),
   137  		},
   138  		DeleteDataLabelingJob: []gax.CallOption{
   139  			gax.WithTimeout(5000 * time.Millisecond),
   140  		},
   141  		CancelDataLabelingJob: []gax.CallOption{
   142  			gax.WithTimeout(5000 * time.Millisecond),
   143  		},
   144  		CreateHyperparameterTuningJob: []gax.CallOption{
   145  			gax.WithTimeout(5000 * time.Millisecond),
   146  		},
   147  		GetHyperparameterTuningJob: []gax.CallOption{
   148  			gax.WithTimeout(5000 * time.Millisecond),
   149  		},
   150  		ListHyperparameterTuningJobs: []gax.CallOption{
   151  			gax.WithTimeout(5000 * time.Millisecond),
   152  		},
   153  		DeleteHyperparameterTuningJob: []gax.CallOption{
   154  			gax.WithTimeout(5000 * time.Millisecond),
   155  		},
   156  		CancelHyperparameterTuningJob: []gax.CallOption{
   157  			gax.WithTimeout(5000 * time.Millisecond),
   158  		},
   159  		CreateNasJob:        []gax.CallOption{},
   160  		GetNasJob:           []gax.CallOption{},
   161  		ListNasJobs:         []gax.CallOption{},
   162  		DeleteNasJob:        []gax.CallOption{},
   163  		CancelNasJob:        []gax.CallOption{},
   164  		GetNasTrialDetail:   []gax.CallOption{},
   165  		ListNasTrialDetails: []gax.CallOption{},
   166  		CreateBatchPredictionJob: []gax.CallOption{
   167  			gax.WithTimeout(5000 * time.Millisecond),
   168  		},
   169  		GetBatchPredictionJob: []gax.CallOption{
   170  			gax.WithTimeout(5000 * time.Millisecond),
   171  		},
   172  		ListBatchPredictionJobs: []gax.CallOption{
   173  			gax.WithTimeout(5000 * time.Millisecond),
   174  		},
   175  		DeleteBatchPredictionJob: []gax.CallOption{
   176  			gax.WithTimeout(5000 * time.Millisecond),
   177  		},
   178  		CancelBatchPredictionJob: []gax.CallOption{
   179  			gax.WithTimeout(5000 * time.Millisecond),
   180  		},
   181  		CreateModelDeploymentMonitoringJob: []gax.CallOption{
   182  			gax.WithTimeout(60000 * time.Millisecond),
   183  		},
   184  		SearchModelDeploymentMonitoringStatsAnomalies: []gax.CallOption{
   185  			gax.WithTimeout(5000 * time.Millisecond),
   186  		},
   187  		GetModelDeploymentMonitoringJob: []gax.CallOption{
   188  			gax.WithTimeout(5000 * time.Millisecond),
   189  		},
   190  		ListModelDeploymentMonitoringJobs: []gax.CallOption{
   191  			gax.WithTimeout(5000 * time.Millisecond),
   192  		},
   193  		UpdateModelDeploymentMonitoringJob: []gax.CallOption{
   194  			gax.WithTimeout(5000 * time.Millisecond),
   195  		},
   196  		DeleteModelDeploymentMonitoringJob: []gax.CallOption{
   197  			gax.WithTimeout(5000 * time.Millisecond),
   198  		},
   199  		PauseModelDeploymentMonitoringJob: []gax.CallOption{
   200  			gax.WithTimeout(5000 * time.Millisecond),
   201  		},
   202  		ResumeModelDeploymentMonitoringJob: []gax.CallOption{
   203  			gax.WithTimeout(5000 * time.Millisecond),
   204  		},
   205  		GetLocation:        []gax.CallOption{},
   206  		ListLocations:      []gax.CallOption{},
   207  		GetIamPolicy:       []gax.CallOption{},
   208  		SetIamPolicy:       []gax.CallOption{},
   209  		TestIamPermissions: []gax.CallOption{},
   210  		CancelOperation:    []gax.CallOption{},
   211  		DeleteOperation:    []gax.CallOption{},
   212  		GetOperation:       []gax.CallOption{},
   213  		ListOperations:     []gax.CallOption{},
   214  		WaitOperation:      []gax.CallOption{},
   215  	}
   216  }
   217  
   218  func defaultJobRESTCallOptions() *JobCallOptions {
   219  	return &JobCallOptions{
   220  		CreateCustomJob: []gax.CallOption{
   221  			gax.WithTimeout(5000 * time.Millisecond),
   222  		},
   223  		GetCustomJob: []gax.CallOption{
   224  			gax.WithTimeout(5000 * time.Millisecond),
   225  		},
   226  		ListCustomJobs: []gax.CallOption{
   227  			gax.WithTimeout(5000 * time.Millisecond),
   228  		},
   229  		DeleteCustomJob: []gax.CallOption{
   230  			gax.WithTimeout(5000 * time.Millisecond),
   231  		},
   232  		CancelCustomJob: []gax.CallOption{
   233  			gax.WithTimeout(5000 * time.Millisecond),
   234  		},
   235  		CreateDataLabelingJob: []gax.CallOption{
   236  			gax.WithTimeout(5000 * time.Millisecond),
   237  		},
   238  		GetDataLabelingJob: []gax.CallOption{
   239  			gax.WithTimeout(5000 * time.Millisecond),
   240  		},
   241  		ListDataLabelingJobs: []gax.CallOption{
   242  			gax.WithTimeout(5000 * time.Millisecond),
   243  		},
   244  		DeleteDataLabelingJob: []gax.CallOption{
   245  			gax.WithTimeout(5000 * time.Millisecond),
   246  		},
   247  		CancelDataLabelingJob: []gax.CallOption{
   248  			gax.WithTimeout(5000 * time.Millisecond),
   249  		},
   250  		CreateHyperparameterTuningJob: []gax.CallOption{
   251  			gax.WithTimeout(5000 * time.Millisecond),
   252  		},
   253  		GetHyperparameterTuningJob: []gax.CallOption{
   254  			gax.WithTimeout(5000 * time.Millisecond),
   255  		},
   256  		ListHyperparameterTuningJobs: []gax.CallOption{
   257  			gax.WithTimeout(5000 * time.Millisecond),
   258  		},
   259  		DeleteHyperparameterTuningJob: []gax.CallOption{
   260  			gax.WithTimeout(5000 * time.Millisecond),
   261  		},
   262  		CancelHyperparameterTuningJob: []gax.CallOption{
   263  			gax.WithTimeout(5000 * time.Millisecond),
   264  		},
   265  		CreateNasJob:        []gax.CallOption{},
   266  		GetNasJob:           []gax.CallOption{},
   267  		ListNasJobs:         []gax.CallOption{},
   268  		DeleteNasJob:        []gax.CallOption{},
   269  		CancelNasJob:        []gax.CallOption{},
   270  		GetNasTrialDetail:   []gax.CallOption{},
   271  		ListNasTrialDetails: []gax.CallOption{},
   272  		CreateBatchPredictionJob: []gax.CallOption{
   273  			gax.WithTimeout(5000 * time.Millisecond),
   274  		},
   275  		GetBatchPredictionJob: []gax.CallOption{
   276  			gax.WithTimeout(5000 * time.Millisecond),
   277  		},
   278  		ListBatchPredictionJobs: []gax.CallOption{
   279  			gax.WithTimeout(5000 * time.Millisecond),
   280  		},
   281  		DeleteBatchPredictionJob: []gax.CallOption{
   282  			gax.WithTimeout(5000 * time.Millisecond),
   283  		},
   284  		CancelBatchPredictionJob: []gax.CallOption{
   285  			gax.WithTimeout(5000 * time.Millisecond),
   286  		},
   287  		CreateModelDeploymentMonitoringJob: []gax.CallOption{
   288  			gax.WithTimeout(60000 * time.Millisecond),
   289  		},
   290  		SearchModelDeploymentMonitoringStatsAnomalies: []gax.CallOption{
   291  			gax.WithTimeout(5000 * time.Millisecond),
   292  		},
   293  		GetModelDeploymentMonitoringJob: []gax.CallOption{
   294  			gax.WithTimeout(5000 * time.Millisecond),
   295  		},
   296  		ListModelDeploymentMonitoringJobs: []gax.CallOption{
   297  			gax.WithTimeout(5000 * time.Millisecond),
   298  		},
   299  		UpdateModelDeploymentMonitoringJob: []gax.CallOption{
   300  			gax.WithTimeout(5000 * time.Millisecond),
   301  		},
   302  		DeleteModelDeploymentMonitoringJob: []gax.CallOption{
   303  			gax.WithTimeout(5000 * time.Millisecond),
   304  		},
   305  		PauseModelDeploymentMonitoringJob: []gax.CallOption{
   306  			gax.WithTimeout(5000 * time.Millisecond),
   307  		},
   308  		ResumeModelDeploymentMonitoringJob: []gax.CallOption{
   309  			gax.WithTimeout(5000 * time.Millisecond),
   310  		},
   311  		GetLocation:        []gax.CallOption{},
   312  		ListLocations:      []gax.CallOption{},
   313  		GetIamPolicy:       []gax.CallOption{},
   314  		SetIamPolicy:       []gax.CallOption{},
   315  		TestIamPermissions: []gax.CallOption{},
   316  		CancelOperation:    []gax.CallOption{},
   317  		DeleteOperation:    []gax.CallOption{},
   318  		GetOperation:       []gax.CallOption{},
   319  		ListOperations:     []gax.CallOption{},
   320  		WaitOperation:      []gax.CallOption{},
   321  	}
   322  }
   323  
   324  // internalJobClient is an interface that defines the methods available from Vertex AI API.
   325  type internalJobClient interface {
   326  	Close() error
   327  	setGoogleClientInfo(...string)
   328  	Connection() *grpc.ClientConn
   329  	CreateCustomJob(context.Context, *aiplatformpb.CreateCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error)
   330  	GetCustomJob(context.Context, *aiplatformpb.GetCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error)
   331  	ListCustomJobs(context.Context, *aiplatformpb.ListCustomJobsRequest, ...gax.CallOption) *CustomJobIterator
   332  	DeleteCustomJob(context.Context, *aiplatformpb.DeleteCustomJobRequest, ...gax.CallOption) (*DeleteCustomJobOperation, error)
   333  	DeleteCustomJobOperation(name string) *DeleteCustomJobOperation
   334  	CancelCustomJob(context.Context, *aiplatformpb.CancelCustomJobRequest, ...gax.CallOption) error
   335  	CreateDataLabelingJob(context.Context, *aiplatformpb.CreateDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error)
   336  	GetDataLabelingJob(context.Context, *aiplatformpb.GetDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error)
   337  	ListDataLabelingJobs(context.Context, *aiplatformpb.ListDataLabelingJobsRequest, ...gax.CallOption) *DataLabelingJobIterator
   338  	DeleteDataLabelingJob(context.Context, *aiplatformpb.DeleteDataLabelingJobRequest, ...gax.CallOption) (*DeleteDataLabelingJobOperation, error)
   339  	DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation
   340  	CancelDataLabelingJob(context.Context, *aiplatformpb.CancelDataLabelingJobRequest, ...gax.CallOption) error
   341  	CreateHyperparameterTuningJob(context.Context, *aiplatformpb.CreateHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error)
   342  	GetHyperparameterTuningJob(context.Context, *aiplatformpb.GetHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error)
   343  	ListHyperparameterTuningJobs(context.Context, *aiplatformpb.ListHyperparameterTuningJobsRequest, ...gax.CallOption) *HyperparameterTuningJobIterator
   344  	DeleteHyperparameterTuningJob(context.Context, *aiplatformpb.DeleteHyperparameterTuningJobRequest, ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error)
   345  	DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation
   346  	CancelHyperparameterTuningJob(context.Context, *aiplatformpb.CancelHyperparameterTuningJobRequest, ...gax.CallOption) error
   347  	CreateNasJob(context.Context, *aiplatformpb.CreateNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error)
   348  	GetNasJob(context.Context, *aiplatformpb.GetNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error)
   349  	ListNasJobs(context.Context, *aiplatformpb.ListNasJobsRequest, ...gax.CallOption) *NasJobIterator
   350  	DeleteNasJob(context.Context, *aiplatformpb.DeleteNasJobRequest, ...gax.CallOption) (*DeleteNasJobOperation, error)
   351  	DeleteNasJobOperation(name string) *DeleteNasJobOperation
   352  	CancelNasJob(context.Context, *aiplatformpb.CancelNasJobRequest, ...gax.CallOption) error
   353  	GetNasTrialDetail(context.Context, *aiplatformpb.GetNasTrialDetailRequest, ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error)
   354  	ListNasTrialDetails(context.Context, *aiplatformpb.ListNasTrialDetailsRequest, ...gax.CallOption) *NasTrialDetailIterator
   355  	CreateBatchPredictionJob(context.Context, *aiplatformpb.CreateBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error)
   356  	GetBatchPredictionJob(context.Context, *aiplatformpb.GetBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error)
   357  	ListBatchPredictionJobs(context.Context, *aiplatformpb.ListBatchPredictionJobsRequest, ...gax.CallOption) *BatchPredictionJobIterator
   358  	DeleteBatchPredictionJob(context.Context, *aiplatformpb.DeleteBatchPredictionJobRequest, ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error)
   359  	DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation
   360  	CancelBatchPredictionJob(context.Context, *aiplatformpb.CancelBatchPredictionJobRequest, ...gax.CallOption) error
   361  	CreateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error)
   362  	SearchModelDeploymentMonitoringStatsAnomalies(context.Context, *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator
   363  	GetModelDeploymentMonitoringJob(context.Context, *aiplatformpb.GetModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error)
   364  	ListModelDeploymentMonitoringJobs(context.Context, *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, ...gax.CallOption) *ModelDeploymentMonitoringJobIterator
   365  	UpdateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error)
   366  	UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation
   367  	DeleteModelDeploymentMonitoringJob(context.Context, *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error)
   368  	DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation
   369  	PauseModelDeploymentMonitoringJob(context.Context, *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, ...gax.CallOption) error
   370  	ResumeModelDeploymentMonitoringJob(context.Context, *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, ...gax.CallOption) error
   371  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   372  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   373  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   374  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   375  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   376  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   377  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   378  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   379  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   380  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   381  }
   382  
   383  // JobClient is a client for interacting with Vertex AI API.
   384  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   385  //
   386  // A service for creating and managing Vertex AI’s jobs.
   387  type JobClient struct {
   388  	// The internal transport-dependent client.
   389  	internalClient internalJobClient
   390  
   391  	// The call options for this service.
   392  	CallOptions *JobCallOptions
   393  
   394  	// LROClient is used internally to handle long-running operations.
   395  	// It is exposed so that its CallOptions can be modified if required.
   396  	// Users should not Close this client.
   397  	LROClient *lroauto.OperationsClient
   398  }
   399  
   400  // Wrapper methods routed to the internal client.
   401  
   402  // Close closes the connection to the API service. The user should invoke this when
   403  // the client is no longer required.
   404  func (c *JobClient) Close() error {
   405  	return c.internalClient.Close()
   406  }
   407  
   408  // setGoogleClientInfo sets the name and version of the application in
   409  // the `x-goog-api-client` header passed on each request. Intended for
   410  // use by Google-written clients.
   411  func (c *JobClient) setGoogleClientInfo(keyval ...string) {
   412  	c.internalClient.setGoogleClientInfo(keyval...)
   413  }
   414  
   415  // Connection returns a connection to the API service.
   416  //
   417  // Deprecated: Connections are now pooled so this method does not always
   418  // return the same resource.
   419  func (c *JobClient) Connection() *grpc.ClientConn {
   420  	return c.internalClient.Connection()
   421  }
   422  
   423  // CreateCustomJob creates a CustomJob. A created CustomJob right away
   424  // will be attempted to be run.
   425  func (c *JobClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
   426  	return c.internalClient.CreateCustomJob(ctx, req, opts...)
   427  }
   428  
   429  // GetCustomJob gets a CustomJob.
   430  func (c *JobClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
   431  	return c.internalClient.GetCustomJob(ctx, req, opts...)
   432  }
   433  
   434  // ListCustomJobs lists CustomJobs in a Location.
   435  func (c *JobClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator {
   436  	return c.internalClient.ListCustomJobs(ctx, req, opts...)
   437  }
   438  
   439  // DeleteCustomJob deletes a CustomJob.
   440  func (c *JobClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) {
   441  	return c.internalClient.DeleteCustomJob(ctx, req, opts...)
   442  }
   443  
   444  // DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name.
   445  // The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process.
   446  func (c *JobClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation {
   447  	return c.internalClient.DeleteCustomJobOperation(name)
   448  }
   449  
   450  // CancelCustomJob cancels a CustomJob.
   451  // Starts asynchronous cancellation on the CustomJob. The server
   452  // makes a best effort to cancel the job, but success is not
   453  // guaranteed. Clients can use
   454  // JobService.GetCustomJob
   455  // or other methods to check whether the cancellation succeeded or whether the
   456  // job completed despite cancellation. On successful cancellation,
   457  // the CustomJob is not deleted; instead it becomes a job with
   458  // a CustomJob.error value
   459  // with a google.rpc.Status.code of 1, corresponding
   460  // to Code.CANCELLED, and
   461  // CustomJob.state is set
   462  // to CANCELLED.
   463  func (c *JobClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error {
   464  	return c.internalClient.CancelCustomJob(ctx, req, opts...)
   465  }
   466  
   467  // CreateDataLabelingJob creates a DataLabelingJob.
   468  func (c *JobClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
   469  	return c.internalClient.CreateDataLabelingJob(ctx, req, opts...)
   470  }
   471  
   472  // GetDataLabelingJob gets a DataLabelingJob.
   473  func (c *JobClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
   474  	return c.internalClient.GetDataLabelingJob(ctx, req, opts...)
   475  }
   476  
   477  // ListDataLabelingJobs lists DataLabelingJobs in a Location.
   478  func (c *JobClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator {
   479  	return c.internalClient.ListDataLabelingJobs(ctx, req, opts...)
   480  }
   481  
   482  // DeleteDataLabelingJob deletes a DataLabelingJob.
   483  func (c *JobClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) {
   484  	return c.internalClient.DeleteDataLabelingJob(ctx, req, opts...)
   485  }
   486  
   487  // DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name.
   488  // The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process.
   489  func (c *JobClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation {
   490  	return c.internalClient.DeleteDataLabelingJobOperation(name)
   491  }
   492  
   493  // CancelDataLabelingJob cancels a DataLabelingJob. Success of cancellation is not guaranteed.
   494  func (c *JobClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error {
   495  	return c.internalClient.CancelDataLabelingJob(ctx, req, opts...)
   496  }
   497  
   498  // CreateHyperparameterTuningJob creates a HyperparameterTuningJob
   499  func (c *JobClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
   500  	return c.internalClient.CreateHyperparameterTuningJob(ctx, req, opts...)
   501  }
   502  
   503  // GetHyperparameterTuningJob gets a HyperparameterTuningJob
   504  func (c *JobClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
   505  	return c.internalClient.GetHyperparameterTuningJob(ctx, req, opts...)
   506  }
   507  
   508  // ListHyperparameterTuningJobs lists HyperparameterTuningJobs in a Location.
   509  func (c *JobClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator {
   510  	return c.internalClient.ListHyperparameterTuningJobs(ctx, req, opts...)
   511  }
   512  
   513  // DeleteHyperparameterTuningJob deletes a HyperparameterTuningJob.
   514  func (c *JobClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) {
   515  	return c.internalClient.DeleteHyperparameterTuningJob(ctx, req, opts...)
   516  }
   517  
   518  // DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name.
   519  // The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process.
   520  func (c *JobClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation {
   521  	return c.internalClient.DeleteHyperparameterTuningJobOperation(name)
   522  }
   523  
   524  // CancelHyperparameterTuningJob cancels a HyperparameterTuningJob.
   525  // Starts asynchronous cancellation on the HyperparameterTuningJob. The server
   526  // makes a best effort to cancel the job, but success is not
   527  // guaranteed. Clients can use
   528  // JobService.GetHyperparameterTuningJob
   529  // or other methods to check whether the cancellation succeeded or whether the
   530  // job completed despite cancellation. On successful cancellation,
   531  // the HyperparameterTuningJob is not deleted; instead it becomes a job with
   532  // a
   533  // HyperparameterTuningJob.error
   534  // value with a google.rpc.Status.code of 1,
   535  // corresponding to Code.CANCELLED, and
   536  // HyperparameterTuningJob.state
   537  // is set to CANCELLED.
   538  func (c *JobClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error {
   539  	return c.internalClient.CancelHyperparameterTuningJob(ctx, req, opts...)
   540  }
   541  
   542  // CreateNasJob creates a NasJob
   543  func (c *JobClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
   544  	return c.internalClient.CreateNasJob(ctx, req, opts...)
   545  }
   546  
   547  // GetNasJob gets a NasJob
   548  func (c *JobClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
   549  	return c.internalClient.GetNasJob(ctx, req, opts...)
   550  }
   551  
   552  // ListNasJobs lists NasJobs in a Location.
   553  func (c *JobClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator {
   554  	return c.internalClient.ListNasJobs(ctx, req, opts...)
   555  }
   556  
   557  // DeleteNasJob deletes a NasJob.
   558  func (c *JobClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) {
   559  	return c.internalClient.DeleteNasJob(ctx, req, opts...)
   560  }
   561  
   562  // DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name.
   563  // The name must be that of a previously created DeleteNasJobOperation, possibly from a different process.
   564  func (c *JobClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation {
   565  	return c.internalClient.DeleteNasJobOperation(name)
   566  }
   567  
   568  // CancelNasJob cancels a NasJob.
   569  // Starts asynchronous cancellation on the NasJob. The server
   570  // makes a best effort to cancel the job, but success is not
   571  // guaranteed. Clients can use
   572  // JobService.GetNasJob
   573  // or other methods to check whether the cancellation succeeded or whether the
   574  // job completed despite cancellation. On successful cancellation,
   575  // the NasJob is not deleted; instead it becomes a job with
   576  // a NasJob.error value with a
   577  // google.rpc.Status.code of 1, corresponding to
   578  // Code.CANCELLED, and
   579  // NasJob.state is set to
   580  // CANCELLED.
   581  func (c *JobClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) error {
   582  	return c.internalClient.CancelNasJob(ctx, req, opts...)
   583  }
   584  
   585  // GetNasTrialDetail gets a NasTrialDetail.
   586  func (c *JobClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) {
   587  	return c.internalClient.GetNasTrialDetail(ctx, req, opts...)
   588  }
   589  
   590  // ListNasTrialDetails list top NasTrialDetails of a NasJob.
   591  func (c *JobClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator {
   592  	return c.internalClient.ListNasTrialDetails(ctx, req, opts...)
   593  }
   594  
   595  // CreateBatchPredictionJob creates a BatchPredictionJob. A BatchPredictionJob once created will
   596  // right away be attempted to start.
   597  func (c *JobClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
   598  	return c.internalClient.CreateBatchPredictionJob(ctx, req, opts...)
   599  }
   600  
   601  // GetBatchPredictionJob gets a BatchPredictionJob
   602  func (c *JobClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
   603  	return c.internalClient.GetBatchPredictionJob(ctx, req, opts...)
   604  }
   605  
   606  // ListBatchPredictionJobs lists BatchPredictionJobs in a Location.
   607  func (c *JobClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator {
   608  	return c.internalClient.ListBatchPredictionJobs(ctx, req, opts...)
   609  }
   610  
   611  // DeleteBatchPredictionJob deletes a BatchPredictionJob. Can only be called on jobs that already
   612  // finished.
   613  func (c *JobClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) {
   614  	return c.internalClient.DeleteBatchPredictionJob(ctx, req, opts...)
   615  }
   616  
   617  // DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name.
   618  // The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process.
   619  func (c *JobClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation {
   620  	return c.internalClient.DeleteBatchPredictionJobOperation(name)
   621  }
   622  
   623  // CancelBatchPredictionJob cancels a BatchPredictionJob.
   624  //
   625  // Starts asynchronous cancellation on the BatchPredictionJob. The server
   626  // makes the best effort to cancel the job, but success is not
   627  // guaranteed. Clients can use
   628  // JobService.GetBatchPredictionJob
   629  // or other methods to check whether the cancellation succeeded or whether the
   630  // job completed despite cancellation. On a successful cancellation,
   631  // the BatchPredictionJob is not deleted;instead its
   632  // BatchPredictionJob.state
   633  // is set to CANCELLED. Any files already outputted by the job are not
   634  // deleted.
   635  func (c *JobClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error {
   636  	return c.internalClient.CancelBatchPredictionJob(ctx, req, opts...)
   637  }
   638  
   639  // CreateModelDeploymentMonitoringJob creates a ModelDeploymentMonitoringJob. It will run periodically on a
   640  // configured interval.
   641  func (c *JobClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
   642  	return c.internalClient.CreateModelDeploymentMonitoringJob(ctx, req, opts...)
   643  }
   644  
   645  // SearchModelDeploymentMonitoringStatsAnomalies searches Model Monitoring Statistics generated within a given time window.
   646  func (c *JobClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator {
   647  	return c.internalClient.SearchModelDeploymentMonitoringStatsAnomalies(ctx, req, opts...)
   648  }
   649  
   650  // GetModelDeploymentMonitoringJob gets a ModelDeploymentMonitoringJob.
   651  func (c *JobClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
   652  	return c.internalClient.GetModelDeploymentMonitoringJob(ctx, req, opts...)
   653  }
   654  
   655  // ListModelDeploymentMonitoringJobs lists ModelDeploymentMonitoringJobs in a Location.
   656  func (c *JobClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator {
   657  	return c.internalClient.ListModelDeploymentMonitoringJobs(ctx, req, opts...)
   658  }
   659  
   660  // UpdateModelDeploymentMonitoringJob updates a ModelDeploymentMonitoringJob.
   661  func (c *JobClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) {
   662  	return c.internalClient.UpdateModelDeploymentMonitoringJob(ctx, req, opts...)
   663  }
   664  
   665  // UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name.
   666  // The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process.
   667  func (c *JobClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation {
   668  	return c.internalClient.UpdateModelDeploymentMonitoringJobOperation(name)
   669  }
   670  
   671  // DeleteModelDeploymentMonitoringJob deletes a ModelDeploymentMonitoringJob.
   672  func (c *JobClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) {
   673  	return c.internalClient.DeleteModelDeploymentMonitoringJob(ctx, req, opts...)
   674  }
   675  
   676  // DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name.
   677  // The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process.
   678  func (c *JobClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation {
   679  	return c.internalClient.DeleteModelDeploymentMonitoringJobOperation(name)
   680  }
   681  
   682  // PauseModelDeploymentMonitoringJob pauses a ModelDeploymentMonitoringJob. If the job is running, the server
   683  // makes a best effort to cancel the job. Will mark
   684  // ModelDeploymentMonitoringJob.state
   685  // to ‘PAUSED’.
   686  func (c *JobClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
   687  	return c.internalClient.PauseModelDeploymentMonitoringJob(ctx, req, opts...)
   688  }
   689  
   690  // ResumeModelDeploymentMonitoringJob resumes a paused ModelDeploymentMonitoringJob. It will start to run from
   691  // next scheduled time. A deleted ModelDeploymentMonitoringJob can’t be
   692  // resumed.
   693  func (c *JobClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
   694  	return c.internalClient.ResumeModelDeploymentMonitoringJob(ctx, req, opts...)
   695  }
   696  
   697  // GetLocation gets information about a location.
   698  func (c *JobClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   699  	return c.internalClient.GetLocation(ctx, req, opts...)
   700  }
   701  
   702  // ListLocations lists information about the supported locations for this service.
   703  func (c *JobClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   704  	return c.internalClient.ListLocations(ctx, req, opts...)
   705  }
   706  
   707  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   708  // if the resource exists and does not have a policy set.
   709  func (c *JobClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   710  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   711  }
   712  
   713  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   714  // any existing policy.
   715  //
   716  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   717  // errors.
   718  func (c *JobClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   719  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   720  }
   721  
   722  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   723  // resource does not exist, this will return an empty set of
   724  // permissions, not a NOT_FOUND error.
   725  //
   726  // Note: This operation is designed to be used for building
   727  // permission-aware UIs and command-line tools, not for authorization
   728  // checking. This operation may “fail open” without warning.
   729  func (c *JobClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   730  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   731  }
   732  
   733  // CancelOperation is a utility method from google.longrunning.Operations.
   734  func (c *JobClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   735  	return c.internalClient.CancelOperation(ctx, req, opts...)
   736  }
   737  
   738  // DeleteOperation is a utility method from google.longrunning.Operations.
   739  func (c *JobClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   740  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   741  }
   742  
   743  // GetOperation is a utility method from google.longrunning.Operations.
   744  func (c *JobClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   745  	return c.internalClient.GetOperation(ctx, req, opts...)
   746  }
   747  
   748  // ListOperations is a utility method from google.longrunning.Operations.
   749  func (c *JobClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   750  	return c.internalClient.ListOperations(ctx, req, opts...)
   751  }
   752  
   753  // WaitOperation is a utility method from google.longrunning.Operations.
   754  func (c *JobClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   755  	return c.internalClient.WaitOperation(ctx, req, opts...)
   756  }
   757  
   758  // jobGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   759  //
   760  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   761  type jobGRPCClient struct {
   762  	// Connection pool of gRPC connections to the service.
   763  	connPool gtransport.ConnPool
   764  
   765  	// Points back to the CallOptions field of the containing JobClient
   766  	CallOptions **JobCallOptions
   767  
   768  	// The gRPC API client.
   769  	jobClient aiplatformpb.JobServiceClient
   770  
   771  	// LROClient is used internally to handle long-running operations.
   772  	// It is exposed so that its CallOptions can be modified if required.
   773  	// Users should not Close this client.
   774  	LROClient **lroauto.OperationsClient
   775  
   776  	operationsClient longrunningpb.OperationsClient
   777  
   778  	iamPolicyClient iampb.IAMPolicyClient
   779  
   780  	locationsClient locationpb.LocationsClient
   781  
   782  	// The x-goog-* metadata to be sent with each request.
   783  	xGoogHeaders []string
   784  
   785  	logger *slog.Logger
   786  }
   787  
   788  // NewJobClient creates a new job service client based on gRPC.
   789  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   790  //
   791  // A service for creating and managing Vertex AI’s jobs.
   792  func NewJobClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) {
   793  	clientOpts := defaultJobGRPCClientOptions()
   794  	if newJobClientHook != nil {
   795  		hookOpts, err := newJobClientHook(ctx, clientHookParams{})
   796  		if err != nil {
   797  			return nil, err
   798  		}
   799  		clientOpts = append(clientOpts, hookOpts...)
   800  	}
   801  
   802  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   803  	if err != nil {
   804  		return nil, err
   805  	}
   806  	client := JobClient{CallOptions: defaultJobCallOptions()}
   807  
   808  	c := &jobGRPCClient{
   809  		connPool:         connPool,
   810  		jobClient:        aiplatformpb.NewJobServiceClient(connPool),
   811  		CallOptions:      &client.CallOptions,
   812  		logger:           internaloption.GetLogger(opts),
   813  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   814  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   815  		locationsClient:  locationpb.NewLocationsClient(connPool),
   816  	}
   817  	c.setGoogleClientInfo()
   818  
   819  	client.internalClient = c
   820  
   821  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   822  	if err != nil {
   823  		// This error "should not happen", since we are just reusing old connection pool
   824  		// and never actually need to dial.
   825  		// If this does happen, we could leak connp. However, we cannot close conn:
   826  		// If the user invoked the constructor with option.WithGRPCConn,
   827  		// we would close a connection that's still in use.
   828  		// TODO: investigate error conditions.
   829  		return nil, err
   830  	}
   831  	c.LROClient = &client.LROClient
   832  	return &client, nil
   833  }
   834  
   835  // Connection returns a connection to the API service.
   836  //
   837  // Deprecated: Connections are now pooled so this method does not always
   838  // return the same resource.
   839  func (c *jobGRPCClient) Connection() *grpc.ClientConn {
   840  	return c.connPool.Conn()
   841  }
   842  
   843  // setGoogleClientInfo sets the name and version of the application in
   844  // the `x-goog-api-client` header passed on each request. Intended for
   845  // use by Google-written clients.
   846  func (c *jobGRPCClient) setGoogleClientInfo(keyval ...string) {
   847  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   848  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   849  	c.xGoogHeaders = []string{
   850  		"x-goog-api-client", gax.XGoogHeader(kv...),
   851  	}
   852  }
   853  
   854  // Close closes the connection to the API service. The user should invoke this when
   855  // the client is no longer required.
   856  func (c *jobGRPCClient) Close() error {
   857  	return c.connPool.Close()
   858  }
   859  
   860  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   861  type jobRESTClient struct {
   862  	// The http endpoint to connect to.
   863  	endpoint string
   864  
   865  	// The http client.
   866  	httpClient *http.Client
   867  
   868  	// LROClient is used internally to handle long-running operations.
   869  	// It is exposed so that its CallOptions can be modified if required.
   870  	// Users should not Close this client.
   871  	LROClient **lroauto.OperationsClient
   872  
   873  	// The x-goog-* headers to be sent with each request.
   874  	xGoogHeaders []string
   875  
   876  	// Points back to the CallOptions field of the containing JobClient
   877  	CallOptions **JobCallOptions
   878  
   879  	logger *slog.Logger
   880  }
   881  
   882  // NewJobRESTClient creates a new job service rest client.
   883  //
   884  // A service for creating and managing Vertex AI’s jobs.
   885  func NewJobRESTClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) {
   886  	clientOpts := append(defaultJobRESTClientOptions(), opts...)
   887  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   888  	if err != nil {
   889  		return nil, err
   890  	}
   891  
   892  	callOpts := defaultJobRESTCallOptions()
   893  	c := &jobRESTClient{
   894  		endpoint:    endpoint,
   895  		httpClient:  httpClient,
   896  		CallOptions: &callOpts,
   897  		logger:      internaloption.GetLogger(opts),
   898  	}
   899  	c.setGoogleClientInfo()
   900  
   901  	lroOpts := []option.ClientOption{
   902  		option.WithHTTPClient(httpClient),
   903  		option.WithEndpoint(endpoint),
   904  	}
   905  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   906  	if err != nil {
   907  		return nil, err
   908  	}
   909  	c.LROClient = &opClient
   910  
   911  	return &JobClient{internalClient: c, CallOptions: callOpts}, nil
   912  }
   913  
   914  func defaultJobRESTClientOptions() []option.ClientOption {
   915  	return []option.ClientOption{
   916  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   917  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   918  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   919  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   920  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   921  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   922  		internaloption.EnableNewAuthLibrary(),
   923  	}
   924  }
   925  
   926  // setGoogleClientInfo sets the name and version of the application in
   927  // the `x-goog-api-client` header passed on each request. Intended for
   928  // use by Google-written clients.
   929  func (c *jobRESTClient) setGoogleClientInfo(keyval ...string) {
   930  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   931  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   932  	c.xGoogHeaders = []string{
   933  		"x-goog-api-client", gax.XGoogHeader(kv...),
   934  	}
   935  }
   936  
   937  // Close closes the connection to the API service. The user should invoke this when
   938  // the client is no longer required.
   939  func (c *jobRESTClient) Close() error {
   940  	// Replace httpClient with nil to force cleanup.
   941  	c.httpClient = nil
   942  	return nil
   943  }
   944  
   945  // Connection returns a connection to the API service.
   946  //
   947  // Deprecated: This method always returns nil.
   948  func (c *jobRESTClient) Connection() *grpc.ClientConn {
   949  	return nil
   950  }
   951  func (c *jobGRPCClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
   952  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   953  
   954  	hds = append(c.xGoogHeaders, hds...)
   955  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   956  	opts = append((*c.CallOptions).CreateCustomJob[0:len((*c.CallOptions).CreateCustomJob):len((*c.CallOptions).CreateCustomJob)], opts...)
   957  	var resp *aiplatformpb.CustomJob
   958  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   959  		var err error
   960  		resp, err = executeRPC(ctx, c.jobClient.CreateCustomJob, req, settings.GRPC, c.logger, "CreateCustomJob")
   961  		return err
   962  	}, opts...)
   963  	if err != nil {
   964  		return nil, err
   965  	}
   966  	return resp, nil
   967  }
   968  
   969  func (c *jobGRPCClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
   970  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   971  
   972  	hds = append(c.xGoogHeaders, hds...)
   973  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   974  	opts = append((*c.CallOptions).GetCustomJob[0:len((*c.CallOptions).GetCustomJob):len((*c.CallOptions).GetCustomJob)], opts...)
   975  	var resp *aiplatformpb.CustomJob
   976  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   977  		var err error
   978  		resp, err = executeRPC(ctx, c.jobClient.GetCustomJob, req, settings.GRPC, c.logger, "GetCustomJob")
   979  		return err
   980  	}, opts...)
   981  	if err != nil {
   982  		return nil, err
   983  	}
   984  	return resp, nil
   985  }
   986  
   987  func (c *jobGRPCClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator {
   988  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   989  
   990  	hds = append(c.xGoogHeaders, hds...)
   991  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   992  	opts = append((*c.CallOptions).ListCustomJobs[0:len((*c.CallOptions).ListCustomJobs):len((*c.CallOptions).ListCustomJobs)], opts...)
   993  	it := &CustomJobIterator{}
   994  	req = proto.Clone(req).(*aiplatformpb.ListCustomJobsRequest)
   995  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.CustomJob, string, error) {
   996  		resp := &aiplatformpb.ListCustomJobsResponse{}
   997  		if pageToken != "" {
   998  			req.PageToken = pageToken
   999  		}
  1000  		if pageSize > math.MaxInt32 {
  1001  			req.PageSize = math.MaxInt32
  1002  		} else if pageSize != 0 {
  1003  			req.PageSize = int32(pageSize)
  1004  		}
  1005  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1006  			var err error
  1007  			resp, err = executeRPC(ctx, c.jobClient.ListCustomJobs, req, settings.GRPC, c.logger, "ListCustomJobs")
  1008  			return err
  1009  		}, opts...)
  1010  		if err != nil {
  1011  			return nil, "", err
  1012  		}
  1013  
  1014  		it.Response = resp
  1015  		return resp.GetCustomJobs(), resp.GetNextPageToken(), nil
  1016  	}
  1017  	fetch := func(pageSize int, pageToken string) (string, error) {
  1018  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1019  		if err != nil {
  1020  			return "", err
  1021  		}
  1022  		it.items = append(it.items, items...)
  1023  		return nextPageToken, nil
  1024  	}
  1025  
  1026  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1027  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1028  	it.pageInfo.Token = req.GetPageToken()
  1029  
  1030  	return it
  1031  }
  1032  
  1033  func (c *jobGRPCClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) {
  1034  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1035  
  1036  	hds = append(c.xGoogHeaders, hds...)
  1037  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1038  	opts = append((*c.CallOptions).DeleteCustomJob[0:len((*c.CallOptions).DeleteCustomJob):len((*c.CallOptions).DeleteCustomJob)], opts...)
  1039  	var resp *longrunningpb.Operation
  1040  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1041  		var err error
  1042  		resp, err = executeRPC(ctx, c.jobClient.DeleteCustomJob, req, settings.GRPC, c.logger, "DeleteCustomJob")
  1043  		return err
  1044  	}, opts...)
  1045  	if err != nil {
  1046  		return nil, err
  1047  	}
  1048  	return &DeleteCustomJobOperation{
  1049  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1050  	}, nil
  1051  }
  1052  
  1053  func (c *jobGRPCClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error {
  1054  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1055  
  1056  	hds = append(c.xGoogHeaders, hds...)
  1057  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1058  	opts = append((*c.CallOptions).CancelCustomJob[0:len((*c.CallOptions).CancelCustomJob):len((*c.CallOptions).CancelCustomJob)], opts...)
  1059  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1060  		var err error
  1061  		_, err = executeRPC(ctx, c.jobClient.CancelCustomJob, req, settings.GRPC, c.logger, "CancelCustomJob")
  1062  		return err
  1063  	}, opts...)
  1064  	return err
  1065  }
  1066  
  1067  func (c *jobGRPCClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
  1068  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1069  
  1070  	hds = append(c.xGoogHeaders, hds...)
  1071  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1072  	opts = append((*c.CallOptions).CreateDataLabelingJob[0:len((*c.CallOptions).CreateDataLabelingJob):len((*c.CallOptions).CreateDataLabelingJob)], opts...)
  1073  	var resp *aiplatformpb.DataLabelingJob
  1074  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1075  		var err error
  1076  		resp, err = executeRPC(ctx, c.jobClient.CreateDataLabelingJob, req, settings.GRPC, c.logger, "CreateDataLabelingJob")
  1077  		return err
  1078  	}, opts...)
  1079  	if err != nil {
  1080  		return nil, err
  1081  	}
  1082  	return resp, nil
  1083  }
  1084  
  1085  func (c *jobGRPCClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
  1086  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1087  
  1088  	hds = append(c.xGoogHeaders, hds...)
  1089  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1090  	opts = append((*c.CallOptions).GetDataLabelingJob[0:len((*c.CallOptions).GetDataLabelingJob):len((*c.CallOptions).GetDataLabelingJob)], opts...)
  1091  	var resp *aiplatformpb.DataLabelingJob
  1092  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1093  		var err error
  1094  		resp, err = executeRPC(ctx, c.jobClient.GetDataLabelingJob, req, settings.GRPC, c.logger, "GetDataLabelingJob")
  1095  		return err
  1096  	}, opts...)
  1097  	if err != nil {
  1098  		return nil, err
  1099  	}
  1100  	return resp, nil
  1101  }
  1102  
  1103  func (c *jobGRPCClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator {
  1104  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1105  
  1106  	hds = append(c.xGoogHeaders, hds...)
  1107  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1108  	opts = append((*c.CallOptions).ListDataLabelingJobs[0:len((*c.CallOptions).ListDataLabelingJobs):len((*c.CallOptions).ListDataLabelingJobs)], opts...)
  1109  	it := &DataLabelingJobIterator{}
  1110  	req = proto.Clone(req).(*aiplatformpb.ListDataLabelingJobsRequest)
  1111  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.DataLabelingJob, string, error) {
  1112  		resp := &aiplatformpb.ListDataLabelingJobsResponse{}
  1113  		if pageToken != "" {
  1114  			req.PageToken = pageToken
  1115  		}
  1116  		if pageSize > math.MaxInt32 {
  1117  			req.PageSize = math.MaxInt32
  1118  		} else if pageSize != 0 {
  1119  			req.PageSize = int32(pageSize)
  1120  		}
  1121  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1122  			var err error
  1123  			resp, err = executeRPC(ctx, c.jobClient.ListDataLabelingJobs, req, settings.GRPC, c.logger, "ListDataLabelingJobs")
  1124  			return err
  1125  		}, opts...)
  1126  		if err != nil {
  1127  			return nil, "", err
  1128  		}
  1129  
  1130  		it.Response = resp
  1131  		return resp.GetDataLabelingJobs(), resp.GetNextPageToken(), nil
  1132  	}
  1133  	fetch := func(pageSize int, pageToken string) (string, error) {
  1134  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1135  		if err != nil {
  1136  			return "", err
  1137  		}
  1138  		it.items = append(it.items, items...)
  1139  		return nextPageToken, nil
  1140  	}
  1141  
  1142  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1143  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1144  	it.pageInfo.Token = req.GetPageToken()
  1145  
  1146  	return it
  1147  }
  1148  
  1149  func (c *jobGRPCClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) {
  1150  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1151  
  1152  	hds = append(c.xGoogHeaders, hds...)
  1153  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1154  	opts = append((*c.CallOptions).DeleteDataLabelingJob[0:len((*c.CallOptions).DeleteDataLabelingJob):len((*c.CallOptions).DeleteDataLabelingJob)], opts...)
  1155  	var resp *longrunningpb.Operation
  1156  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1157  		var err error
  1158  		resp, err = executeRPC(ctx, c.jobClient.DeleteDataLabelingJob, req, settings.GRPC, c.logger, "DeleteDataLabelingJob")
  1159  		return err
  1160  	}, opts...)
  1161  	if err != nil {
  1162  		return nil, err
  1163  	}
  1164  	return &DeleteDataLabelingJobOperation{
  1165  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1166  	}, nil
  1167  }
  1168  
  1169  func (c *jobGRPCClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error {
  1170  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1171  
  1172  	hds = append(c.xGoogHeaders, hds...)
  1173  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1174  	opts = append((*c.CallOptions).CancelDataLabelingJob[0:len((*c.CallOptions).CancelDataLabelingJob):len((*c.CallOptions).CancelDataLabelingJob)], opts...)
  1175  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1176  		var err error
  1177  		_, err = executeRPC(ctx, c.jobClient.CancelDataLabelingJob, req, settings.GRPC, c.logger, "CancelDataLabelingJob")
  1178  		return err
  1179  	}, opts...)
  1180  	return err
  1181  }
  1182  
  1183  func (c *jobGRPCClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
  1184  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1185  
  1186  	hds = append(c.xGoogHeaders, hds...)
  1187  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1188  	opts = append((*c.CallOptions).CreateHyperparameterTuningJob[0:len((*c.CallOptions).CreateHyperparameterTuningJob):len((*c.CallOptions).CreateHyperparameterTuningJob)], opts...)
  1189  	var resp *aiplatformpb.HyperparameterTuningJob
  1190  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1191  		var err error
  1192  		resp, err = executeRPC(ctx, c.jobClient.CreateHyperparameterTuningJob, req, settings.GRPC, c.logger, "CreateHyperparameterTuningJob")
  1193  		return err
  1194  	}, opts...)
  1195  	if err != nil {
  1196  		return nil, err
  1197  	}
  1198  	return resp, nil
  1199  }
  1200  
  1201  func (c *jobGRPCClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
  1202  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1203  
  1204  	hds = append(c.xGoogHeaders, hds...)
  1205  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1206  	opts = append((*c.CallOptions).GetHyperparameterTuningJob[0:len((*c.CallOptions).GetHyperparameterTuningJob):len((*c.CallOptions).GetHyperparameterTuningJob)], opts...)
  1207  	var resp *aiplatformpb.HyperparameterTuningJob
  1208  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1209  		var err error
  1210  		resp, err = executeRPC(ctx, c.jobClient.GetHyperparameterTuningJob, req, settings.GRPC, c.logger, "GetHyperparameterTuningJob")
  1211  		return err
  1212  	}, opts...)
  1213  	if err != nil {
  1214  		return nil, err
  1215  	}
  1216  	return resp, nil
  1217  }
  1218  
  1219  func (c *jobGRPCClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator {
  1220  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1221  
  1222  	hds = append(c.xGoogHeaders, hds...)
  1223  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1224  	opts = append((*c.CallOptions).ListHyperparameterTuningJobs[0:len((*c.CallOptions).ListHyperparameterTuningJobs):len((*c.CallOptions).ListHyperparameterTuningJobs)], opts...)
  1225  	it := &HyperparameterTuningJobIterator{}
  1226  	req = proto.Clone(req).(*aiplatformpb.ListHyperparameterTuningJobsRequest)
  1227  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.HyperparameterTuningJob, string, error) {
  1228  		resp := &aiplatformpb.ListHyperparameterTuningJobsResponse{}
  1229  		if pageToken != "" {
  1230  			req.PageToken = pageToken
  1231  		}
  1232  		if pageSize > math.MaxInt32 {
  1233  			req.PageSize = math.MaxInt32
  1234  		} else if pageSize != 0 {
  1235  			req.PageSize = int32(pageSize)
  1236  		}
  1237  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1238  			var err error
  1239  			resp, err = executeRPC(ctx, c.jobClient.ListHyperparameterTuningJobs, req, settings.GRPC, c.logger, "ListHyperparameterTuningJobs")
  1240  			return err
  1241  		}, opts...)
  1242  		if err != nil {
  1243  			return nil, "", err
  1244  		}
  1245  
  1246  		it.Response = resp
  1247  		return resp.GetHyperparameterTuningJobs(), resp.GetNextPageToken(), nil
  1248  	}
  1249  	fetch := func(pageSize int, pageToken string) (string, error) {
  1250  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1251  		if err != nil {
  1252  			return "", err
  1253  		}
  1254  		it.items = append(it.items, items...)
  1255  		return nextPageToken, nil
  1256  	}
  1257  
  1258  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1259  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1260  	it.pageInfo.Token = req.GetPageToken()
  1261  
  1262  	return it
  1263  }
  1264  
  1265  func (c *jobGRPCClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) {
  1266  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1267  
  1268  	hds = append(c.xGoogHeaders, hds...)
  1269  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1270  	opts = append((*c.CallOptions).DeleteHyperparameterTuningJob[0:len((*c.CallOptions).DeleteHyperparameterTuningJob):len((*c.CallOptions).DeleteHyperparameterTuningJob)], opts...)
  1271  	var resp *longrunningpb.Operation
  1272  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1273  		var err error
  1274  		resp, err = executeRPC(ctx, c.jobClient.DeleteHyperparameterTuningJob, req, settings.GRPC, c.logger, "DeleteHyperparameterTuningJob")
  1275  		return err
  1276  	}, opts...)
  1277  	if err != nil {
  1278  		return nil, err
  1279  	}
  1280  	return &DeleteHyperparameterTuningJobOperation{
  1281  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1282  	}, nil
  1283  }
  1284  
  1285  func (c *jobGRPCClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error {
  1286  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1287  
  1288  	hds = append(c.xGoogHeaders, hds...)
  1289  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1290  	opts = append((*c.CallOptions).CancelHyperparameterTuningJob[0:len((*c.CallOptions).CancelHyperparameterTuningJob):len((*c.CallOptions).CancelHyperparameterTuningJob)], opts...)
  1291  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1292  		var err error
  1293  		_, err = executeRPC(ctx, c.jobClient.CancelHyperparameterTuningJob, req, settings.GRPC, c.logger, "CancelHyperparameterTuningJob")
  1294  		return err
  1295  	}, opts...)
  1296  	return err
  1297  }
  1298  
  1299  func (c *jobGRPCClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
  1300  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1301  
  1302  	hds = append(c.xGoogHeaders, hds...)
  1303  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1304  	opts = append((*c.CallOptions).CreateNasJob[0:len((*c.CallOptions).CreateNasJob):len((*c.CallOptions).CreateNasJob)], opts...)
  1305  	var resp *aiplatformpb.NasJob
  1306  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1307  		var err error
  1308  		resp, err = executeRPC(ctx, c.jobClient.CreateNasJob, req, settings.GRPC, c.logger, "CreateNasJob")
  1309  		return err
  1310  	}, opts...)
  1311  	if err != nil {
  1312  		return nil, err
  1313  	}
  1314  	return resp, nil
  1315  }
  1316  
  1317  func (c *jobGRPCClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
  1318  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1319  
  1320  	hds = append(c.xGoogHeaders, hds...)
  1321  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1322  	opts = append((*c.CallOptions).GetNasJob[0:len((*c.CallOptions).GetNasJob):len((*c.CallOptions).GetNasJob)], opts...)
  1323  	var resp *aiplatformpb.NasJob
  1324  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1325  		var err error
  1326  		resp, err = executeRPC(ctx, c.jobClient.GetNasJob, req, settings.GRPC, c.logger, "GetNasJob")
  1327  		return err
  1328  	}, opts...)
  1329  	if err != nil {
  1330  		return nil, err
  1331  	}
  1332  	return resp, nil
  1333  }
  1334  
  1335  func (c *jobGRPCClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator {
  1336  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1337  
  1338  	hds = append(c.xGoogHeaders, hds...)
  1339  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1340  	opts = append((*c.CallOptions).ListNasJobs[0:len((*c.CallOptions).ListNasJobs):len((*c.CallOptions).ListNasJobs)], opts...)
  1341  	it := &NasJobIterator{}
  1342  	req = proto.Clone(req).(*aiplatformpb.ListNasJobsRequest)
  1343  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasJob, string, error) {
  1344  		resp := &aiplatformpb.ListNasJobsResponse{}
  1345  		if pageToken != "" {
  1346  			req.PageToken = pageToken
  1347  		}
  1348  		if pageSize > math.MaxInt32 {
  1349  			req.PageSize = math.MaxInt32
  1350  		} else if pageSize != 0 {
  1351  			req.PageSize = int32(pageSize)
  1352  		}
  1353  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1354  			var err error
  1355  			resp, err = executeRPC(ctx, c.jobClient.ListNasJobs, req, settings.GRPC, c.logger, "ListNasJobs")
  1356  			return err
  1357  		}, opts...)
  1358  		if err != nil {
  1359  			return nil, "", err
  1360  		}
  1361  
  1362  		it.Response = resp
  1363  		return resp.GetNasJobs(), resp.GetNextPageToken(), nil
  1364  	}
  1365  	fetch := func(pageSize int, pageToken string) (string, error) {
  1366  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1367  		if err != nil {
  1368  			return "", err
  1369  		}
  1370  		it.items = append(it.items, items...)
  1371  		return nextPageToken, nil
  1372  	}
  1373  
  1374  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1375  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1376  	it.pageInfo.Token = req.GetPageToken()
  1377  
  1378  	return it
  1379  }
  1380  
  1381  func (c *jobGRPCClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) {
  1382  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1383  
  1384  	hds = append(c.xGoogHeaders, hds...)
  1385  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1386  	opts = append((*c.CallOptions).DeleteNasJob[0:len((*c.CallOptions).DeleteNasJob):len((*c.CallOptions).DeleteNasJob)], opts...)
  1387  	var resp *longrunningpb.Operation
  1388  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1389  		var err error
  1390  		resp, err = executeRPC(ctx, c.jobClient.DeleteNasJob, req, settings.GRPC, c.logger, "DeleteNasJob")
  1391  		return err
  1392  	}, opts...)
  1393  	if err != nil {
  1394  		return nil, err
  1395  	}
  1396  	return &DeleteNasJobOperation{
  1397  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1398  	}, nil
  1399  }
  1400  
  1401  func (c *jobGRPCClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) 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).CancelNasJob[0:len((*c.CallOptions).CancelNasJob):len((*c.CallOptions).CancelNasJob)], opts...)
  1407  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1408  		var err error
  1409  		_, err = executeRPC(ctx, c.jobClient.CancelNasJob, req, settings.GRPC, c.logger, "CancelNasJob")
  1410  		return err
  1411  	}, opts...)
  1412  	return err
  1413  }
  1414  
  1415  func (c *jobGRPCClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) {
  1416  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1417  
  1418  	hds = append(c.xGoogHeaders, hds...)
  1419  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1420  	opts = append((*c.CallOptions).GetNasTrialDetail[0:len((*c.CallOptions).GetNasTrialDetail):len((*c.CallOptions).GetNasTrialDetail)], opts...)
  1421  	var resp *aiplatformpb.NasTrialDetail
  1422  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1423  		var err error
  1424  		resp, err = executeRPC(ctx, c.jobClient.GetNasTrialDetail, req, settings.GRPC, c.logger, "GetNasTrialDetail")
  1425  		return err
  1426  	}, opts...)
  1427  	if err != nil {
  1428  		return nil, err
  1429  	}
  1430  	return resp, nil
  1431  }
  1432  
  1433  func (c *jobGRPCClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator {
  1434  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1435  
  1436  	hds = append(c.xGoogHeaders, hds...)
  1437  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1438  	opts = append((*c.CallOptions).ListNasTrialDetails[0:len((*c.CallOptions).ListNasTrialDetails):len((*c.CallOptions).ListNasTrialDetails)], opts...)
  1439  	it := &NasTrialDetailIterator{}
  1440  	req = proto.Clone(req).(*aiplatformpb.ListNasTrialDetailsRequest)
  1441  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasTrialDetail, string, error) {
  1442  		resp := &aiplatformpb.ListNasTrialDetailsResponse{}
  1443  		if pageToken != "" {
  1444  			req.PageToken = pageToken
  1445  		}
  1446  		if pageSize > math.MaxInt32 {
  1447  			req.PageSize = math.MaxInt32
  1448  		} else if pageSize != 0 {
  1449  			req.PageSize = int32(pageSize)
  1450  		}
  1451  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1452  			var err error
  1453  			resp, err = executeRPC(ctx, c.jobClient.ListNasTrialDetails, req, settings.GRPC, c.logger, "ListNasTrialDetails")
  1454  			return err
  1455  		}, opts...)
  1456  		if err != nil {
  1457  			return nil, "", err
  1458  		}
  1459  
  1460  		it.Response = resp
  1461  		return resp.GetNasTrialDetails(), resp.GetNextPageToken(), nil
  1462  	}
  1463  	fetch := func(pageSize int, pageToken string) (string, error) {
  1464  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1465  		if err != nil {
  1466  			return "", err
  1467  		}
  1468  		it.items = append(it.items, items...)
  1469  		return nextPageToken, nil
  1470  	}
  1471  
  1472  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1473  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1474  	it.pageInfo.Token = req.GetPageToken()
  1475  
  1476  	return it
  1477  }
  1478  
  1479  func (c *jobGRPCClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
  1480  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1481  
  1482  	hds = append(c.xGoogHeaders, hds...)
  1483  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1484  	opts = append((*c.CallOptions).CreateBatchPredictionJob[0:len((*c.CallOptions).CreateBatchPredictionJob):len((*c.CallOptions).CreateBatchPredictionJob)], opts...)
  1485  	var resp *aiplatformpb.BatchPredictionJob
  1486  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1487  		var err error
  1488  		resp, err = executeRPC(ctx, c.jobClient.CreateBatchPredictionJob, req, settings.GRPC, c.logger, "CreateBatchPredictionJob")
  1489  		return err
  1490  	}, opts...)
  1491  	if err != nil {
  1492  		return nil, err
  1493  	}
  1494  	return resp, nil
  1495  }
  1496  
  1497  func (c *jobGRPCClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
  1498  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1499  
  1500  	hds = append(c.xGoogHeaders, hds...)
  1501  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1502  	opts = append((*c.CallOptions).GetBatchPredictionJob[0:len((*c.CallOptions).GetBatchPredictionJob):len((*c.CallOptions).GetBatchPredictionJob)], opts...)
  1503  	var resp *aiplatformpb.BatchPredictionJob
  1504  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1505  		var err error
  1506  		resp, err = executeRPC(ctx, c.jobClient.GetBatchPredictionJob, req, settings.GRPC, c.logger, "GetBatchPredictionJob")
  1507  		return err
  1508  	}, opts...)
  1509  	if err != nil {
  1510  		return nil, err
  1511  	}
  1512  	return resp, nil
  1513  }
  1514  
  1515  func (c *jobGRPCClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator {
  1516  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1517  
  1518  	hds = append(c.xGoogHeaders, hds...)
  1519  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1520  	opts = append((*c.CallOptions).ListBatchPredictionJobs[0:len((*c.CallOptions).ListBatchPredictionJobs):len((*c.CallOptions).ListBatchPredictionJobs)], opts...)
  1521  	it := &BatchPredictionJobIterator{}
  1522  	req = proto.Clone(req).(*aiplatformpb.ListBatchPredictionJobsRequest)
  1523  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.BatchPredictionJob, string, error) {
  1524  		resp := &aiplatformpb.ListBatchPredictionJobsResponse{}
  1525  		if pageToken != "" {
  1526  			req.PageToken = pageToken
  1527  		}
  1528  		if pageSize > math.MaxInt32 {
  1529  			req.PageSize = math.MaxInt32
  1530  		} else if pageSize != 0 {
  1531  			req.PageSize = int32(pageSize)
  1532  		}
  1533  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1534  			var err error
  1535  			resp, err = executeRPC(ctx, c.jobClient.ListBatchPredictionJobs, req, settings.GRPC, c.logger, "ListBatchPredictionJobs")
  1536  			return err
  1537  		}, opts...)
  1538  		if err != nil {
  1539  			return nil, "", err
  1540  		}
  1541  
  1542  		it.Response = resp
  1543  		return resp.GetBatchPredictionJobs(), resp.GetNextPageToken(), nil
  1544  	}
  1545  	fetch := func(pageSize int, pageToken string) (string, error) {
  1546  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1547  		if err != nil {
  1548  			return "", err
  1549  		}
  1550  		it.items = append(it.items, items...)
  1551  		return nextPageToken, nil
  1552  	}
  1553  
  1554  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1555  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1556  	it.pageInfo.Token = req.GetPageToken()
  1557  
  1558  	return it
  1559  }
  1560  
  1561  func (c *jobGRPCClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) {
  1562  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1563  
  1564  	hds = append(c.xGoogHeaders, hds...)
  1565  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1566  	opts = append((*c.CallOptions).DeleteBatchPredictionJob[0:len((*c.CallOptions).DeleteBatchPredictionJob):len((*c.CallOptions).DeleteBatchPredictionJob)], opts...)
  1567  	var resp *longrunningpb.Operation
  1568  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1569  		var err error
  1570  		resp, err = executeRPC(ctx, c.jobClient.DeleteBatchPredictionJob, req, settings.GRPC, c.logger, "DeleteBatchPredictionJob")
  1571  		return err
  1572  	}, opts...)
  1573  	if err != nil {
  1574  		return nil, err
  1575  	}
  1576  	return &DeleteBatchPredictionJobOperation{
  1577  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1578  	}, nil
  1579  }
  1580  
  1581  func (c *jobGRPCClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error {
  1582  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1583  
  1584  	hds = append(c.xGoogHeaders, hds...)
  1585  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1586  	opts = append((*c.CallOptions).CancelBatchPredictionJob[0:len((*c.CallOptions).CancelBatchPredictionJob):len((*c.CallOptions).CancelBatchPredictionJob)], opts...)
  1587  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1588  		var err error
  1589  		_, err = executeRPC(ctx, c.jobClient.CancelBatchPredictionJob, req, settings.GRPC, c.logger, "CancelBatchPredictionJob")
  1590  		return err
  1591  	}, opts...)
  1592  	return err
  1593  }
  1594  
  1595  func (c *jobGRPCClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
  1596  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1597  
  1598  	hds = append(c.xGoogHeaders, hds...)
  1599  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1600  	opts = append((*c.CallOptions).CreateModelDeploymentMonitoringJob[0:len((*c.CallOptions).CreateModelDeploymentMonitoringJob):len((*c.CallOptions).CreateModelDeploymentMonitoringJob)], opts...)
  1601  	var resp *aiplatformpb.ModelDeploymentMonitoringJob
  1602  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1603  		var err error
  1604  		resp, err = executeRPC(ctx, c.jobClient.CreateModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "CreateModelDeploymentMonitoringJob")
  1605  		return err
  1606  	}, opts...)
  1607  	if err != nil {
  1608  		return nil, err
  1609  	}
  1610  	return resp, nil
  1611  }
  1612  
  1613  func (c *jobGRPCClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator {
  1614  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model_deployment_monitoring_job", url.QueryEscape(req.GetModelDeploymentMonitoringJob()))}
  1615  
  1616  	hds = append(c.xGoogHeaders, hds...)
  1617  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1618  	opts = append((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies[0:len((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies):len((*c.CallOptions).SearchModelDeploymentMonitoringStatsAnomalies)], opts...)
  1619  	it := &ModelMonitoringStatsAnomaliesIterator{}
  1620  	req = proto.Clone(req).(*aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest)
  1621  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelMonitoringStatsAnomalies, string, error) {
  1622  		resp := &aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesResponse{}
  1623  		if pageToken != "" {
  1624  			req.PageToken = pageToken
  1625  		}
  1626  		if pageSize > math.MaxInt32 {
  1627  			req.PageSize = math.MaxInt32
  1628  		} else if pageSize != 0 {
  1629  			req.PageSize = int32(pageSize)
  1630  		}
  1631  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1632  			var err error
  1633  			resp, err = executeRPC(ctx, c.jobClient.SearchModelDeploymentMonitoringStatsAnomalies, req, settings.GRPC, c.logger, "SearchModelDeploymentMonitoringStatsAnomalies")
  1634  			return err
  1635  		}, opts...)
  1636  		if err != nil {
  1637  			return nil, "", err
  1638  		}
  1639  
  1640  		it.Response = resp
  1641  		return resp.GetMonitoringStats(), resp.GetNextPageToken(), nil
  1642  	}
  1643  	fetch := func(pageSize int, pageToken string) (string, error) {
  1644  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1645  		if err != nil {
  1646  			return "", err
  1647  		}
  1648  		it.items = append(it.items, items...)
  1649  		return nextPageToken, nil
  1650  	}
  1651  
  1652  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1653  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1654  	it.pageInfo.Token = req.GetPageToken()
  1655  
  1656  	return it
  1657  }
  1658  
  1659  func (c *jobGRPCClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
  1660  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1661  
  1662  	hds = append(c.xGoogHeaders, hds...)
  1663  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1664  	opts = append((*c.CallOptions).GetModelDeploymentMonitoringJob[0:len((*c.CallOptions).GetModelDeploymentMonitoringJob):len((*c.CallOptions).GetModelDeploymentMonitoringJob)], opts...)
  1665  	var resp *aiplatformpb.ModelDeploymentMonitoringJob
  1666  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1667  		var err error
  1668  		resp, err = executeRPC(ctx, c.jobClient.GetModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "GetModelDeploymentMonitoringJob")
  1669  		return err
  1670  	}, opts...)
  1671  	if err != nil {
  1672  		return nil, err
  1673  	}
  1674  	return resp, nil
  1675  }
  1676  
  1677  func (c *jobGRPCClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator {
  1678  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1679  
  1680  	hds = append(c.xGoogHeaders, hds...)
  1681  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1682  	opts = append((*c.CallOptions).ListModelDeploymentMonitoringJobs[0:len((*c.CallOptions).ListModelDeploymentMonitoringJobs):len((*c.CallOptions).ListModelDeploymentMonitoringJobs)], opts...)
  1683  	it := &ModelDeploymentMonitoringJobIterator{}
  1684  	req = proto.Clone(req).(*aiplatformpb.ListModelDeploymentMonitoringJobsRequest)
  1685  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelDeploymentMonitoringJob, string, error) {
  1686  		resp := &aiplatformpb.ListModelDeploymentMonitoringJobsResponse{}
  1687  		if pageToken != "" {
  1688  			req.PageToken = pageToken
  1689  		}
  1690  		if pageSize > math.MaxInt32 {
  1691  			req.PageSize = math.MaxInt32
  1692  		} else if pageSize != 0 {
  1693  			req.PageSize = int32(pageSize)
  1694  		}
  1695  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1696  			var err error
  1697  			resp, err = executeRPC(ctx, c.jobClient.ListModelDeploymentMonitoringJobs, req, settings.GRPC, c.logger, "ListModelDeploymentMonitoringJobs")
  1698  			return err
  1699  		}, opts...)
  1700  		if err != nil {
  1701  			return nil, "", err
  1702  		}
  1703  
  1704  		it.Response = resp
  1705  		return resp.GetModelDeploymentMonitoringJobs(), resp.GetNextPageToken(), nil
  1706  	}
  1707  	fetch := func(pageSize int, pageToken string) (string, error) {
  1708  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1709  		if err != nil {
  1710  			return "", err
  1711  		}
  1712  		it.items = append(it.items, items...)
  1713  		return nextPageToken, nil
  1714  	}
  1715  
  1716  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1717  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1718  	it.pageInfo.Token = req.GetPageToken()
  1719  
  1720  	return it
  1721  }
  1722  
  1723  func (c *jobGRPCClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) {
  1724  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model_deployment_monitoring_job.name", url.QueryEscape(req.GetModelDeploymentMonitoringJob().GetName()))}
  1725  
  1726  	hds = append(c.xGoogHeaders, hds...)
  1727  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1728  	opts = append((*c.CallOptions).UpdateModelDeploymentMonitoringJob[0:len((*c.CallOptions).UpdateModelDeploymentMonitoringJob):len((*c.CallOptions).UpdateModelDeploymentMonitoringJob)], opts...)
  1729  	var resp *longrunningpb.Operation
  1730  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1731  		var err error
  1732  		resp, err = executeRPC(ctx, c.jobClient.UpdateModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "UpdateModelDeploymentMonitoringJob")
  1733  		return err
  1734  	}, opts...)
  1735  	if err != nil {
  1736  		return nil, err
  1737  	}
  1738  	return &UpdateModelDeploymentMonitoringJobOperation{
  1739  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1740  	}, nil
  1741  }
  1742  
  1743  func (c *jobGRPCClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, 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).DeleteModelDeploymentMonitoringJob[0:len((*c.CallOptions).DeleteModelDeploymentMonitoringJob):len((*c.CallOptions).DeleteModelDeploymentMonitoringJob)], 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.jobClient.DeleteModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "DeleteModelDeploymentMonitoringJob")
  1753  		return err
  1754  	}, opts...)
  1755  	if err != nil {
  1756  		return nil, err
  1757  	}
  1758  	return &DeleteModelDeploymentMonitoringJobOperation{
  1759  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1760  	}, nil
  1761  }
  1762  
  1763  func (c *jobGRPCClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
  1764  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1765  
  1766  	hds = append(c.xGoogHeaders, hds...)
  1767  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1768  	opts = append((*c.CallOptions).PauseModelDeploymentMonitoringJob[0:len((*c.CallOptions).PauseModelDeploymentMonitoringJob):len((*c.CallOptions).PauseModelDeploymentMonitoringJob)], opts...)
  1769  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1770  		var err error
  1771  		_, err = executeRPC(ctx, c.jobClient.PauseModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "PauseModelDeploymentMonitoringJob")
  1772  		return err
  1773  	}, opts...)
  1774  	return err
  1775  }
  1776  
  1777  func (c *jobGRPCClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
  1778  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1779  
  1780  	hds = append(c.xGoogHeaders, hds...)
  1781  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1782  	opts = append((*c.CallOptions).ResumeModelDeploymentMonitoringJob[0:len((*c.CallOptions).ResumeModelDeploymentMonitoringJob):len((*c.CallOptions).ResumeModelDeploymentMonitoringJob)], opts...)
  1783  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1784  		var err error
  1785  		_, err = executeRPC(ctx, c.jobClient.ResumeModelDeploymentMonitoringJob, req, settings.GRPC, c.logger, "ResumeModelDeploymentMonitoringJob")
  1786  		return err
  1787  	}, opts...)
  1788  	return err
  1789  }
  1790  
  1791  func (c *jobGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1792  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1793  
  1794  	hds = append(c.xGoogHeaders, hds...)
  1795  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1796  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1797  	var resp *locationpb.Location
  1798  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1799  		var err error
  1800  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1801  		return err
  1802  	}, opts...)
  1803  	if err != nil {
  1804  		return nil, err
  1805  	}
  1806  	return resp, nil
  1807  }
  1808  
  1809  func (c *jobGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1810  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1811  
  1812  	hds = append(c.xGoogHeaders, hds...)
  1813  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1814  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1815  	it := &LocationIterator{}
  1816  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1817  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1818  		resp := &locationpb.ListLocationsResponse{}
  1819  		if pageToken != "" {
  1820  			req.PageToken = pageToken
  1821  		}
  1822  		if pageSize > math.MaxInt32 {
  1823  			req.PageSize = math.MaxInt32
  1824  		} else if pageSize != 0 {
  1825  			req.PageSize = int32(pageSize)
  1826  		}
  1827  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1828  			var err error
  1829  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1830  			return err
  1831  		}, opts...)
  1832  		if err != nil {
  1833  			return nil, "", err
  1834  		}
  1835  
  1836  		it.Response = resp
  1837  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1838  	}
  1839  	fetch := func(pageSize int, pageToken string) (string, error) {
  1840  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1841  		if err != nil {
  1842  			return "", err
  1843  		}
  1844  		it.items = append(it.items, items...)
  1845  		return nextPageToken, nil
  1846  	}
  1847  
  1848  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1849  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1850  	it.pageInfo.Token = req.GetPageToken()
  1851  
  1852  	return it
  1853  }
  1854  
  1855  func (c *jobGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1856  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1857  
  1858  	hds = append(c.xGoogHeaders, hds...)
  1859  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1860  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1861  	var resp *iampb.Policy
  1862  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1863  		var err error
  1864  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1865  		return err
  1866  	}, opts...)
  1867  	if err != nil {
  1868  		return nil, err
  1869  	}
  1870  	return resp, nil
  1871  }
  1872  
  1873  func (c *jobGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1874  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1875  
  1876  	hds = append(c.xGoogHeaders, hds...)
  1877  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1878  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1879  	var resp *iampb.Policy
  1880  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1881  		var err error
  1882  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1883  		return err
  1884  	}, opts...)
  1885  	if err != nil {
  1886  		return nil, err
  1887  	}
  1888  	return resp, nil
  1889  }
  1890  
  1891  func (c *jobGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1892  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1893  
  1894  	hds = append(c.xGoogHeaders, hds...)
  1895  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1896  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1897  	var resp *iampb.TestIamPermissionsResponse
  1898  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1899  		var err error
  1900  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1901  		return err
  1902  	}, opts...)
  1903  	if err != nil {
  1904  		return nil, err
  1905  	}
  1906  	return resp, nil
  1907  }
  1908  
  1909  func (c *jobGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1910  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1911  
  1912  	hds = append(c.xGoogHeaders, hds...)
  1913  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1914  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1915  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1916  		var err error
  1917  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1918  		return err
  1919  	}, opts...)
  1920  	return err
  1921  }
  1922  
  1923  func (c *jobGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1924  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1925  
  1926  	hds = append(c.xGoogHeaders, hds...)
  1927  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1928  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1929  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1930  		var err error
  1931  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1932  		return err
  1933  	}, opts...)
  1934  	return err
  1935  }
  1936  
  1937  func (c *jobGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1938  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1939  
  1940  	hds = append(c.xGoogHeaders, hds...)
  1941  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1942  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1943  	var resp *longrunningpb.Operation
  1944  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1945  		var err error
  1946  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1947  		return err
  1948  	}, opts...)
  1949  	if err != nil {
  1950  		return nil, err
  1951  	}
  1952  	return resp, nil
  1953  }
  1954  
  1955  func (c *jobGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1956  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1957  
  1958  	hds = append(c.xGoogHeaders, hds...)
  1959  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1960  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1961  	it := &OperationIterator{}
  1962  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1963  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1964  		resp := &longrunningpb.ListOperationsResponse{}
  1965  		if pageToken != "" {
  1966  			req.PageToken = pageToken
  1967  		}
  1968  		if pageSize > math.MaxInt32 {
  1969  			req.PageSize = math.MaxInt32
  1970  		} else if pageSize != 0 {
  1971  			req.PageSize = int32(pageSize)
  1972  		}
  1973  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1974  			var err error
  1975  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1976  			return err
  1977  		}, opts...)
  1978  		if err != nil {
  1979  			return nil, "", err
  1980  		}
  1981  
  1982  		it.Response = resp
  1983  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1984  	}
  1985  	fetch := func(pageSize int, pageToken string) (string, error) {
  1986  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1987  		if err != nil {
  1988  			return "", err
  1989  		}
  1990  		it.items = append(it.items, items...)
  1991  		return nextPageToken, nil
  1992  	}
  1993  
  1994  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1995  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1996  	it.pageInfo.Token = req.GetPageToken()
  1997  
  1998  	return it
  1999  }
  2000  
  2001  func (c *jobGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  2002  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2003  
  2004  	hds = append(c.xGoogHeaders, hds...)
  2005  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  2006  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  2007  	var resp *longrunningpb.Operation
  2008  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2009  		var err error
  2010  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  2011  		return err
  2012  	}, opts...)
  2013  	if err != nil {
  2014  		return nil, err
  2015  	}
  2016  	return resp, nil
  2017  }
  2018  
  2019  // CreateCustomJob creates a CustomJob. A created CustomJob right away
  2020  // will be attempted to be run.
  2021  func (c *jobRESTClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
  2022  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2023  	body := req.GetCustomJob()
  2024  	jsonReq, err := m.Marshal(body)
  2025  	if err != nil {
  2026  		return nil, err
  2027  	}
  2028  
  2029  	baseUrl, err := url.Parse(c.endpoint)
  2030  	if err != nil {
  2031  		return nil, err
  2032  	}
  2033  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/customJobs", req.GetParent())
  2034  
  2035  	params := url.Values{}
  2036  	params.Add("$alt", "json;enum-encoding=int")
  2037  
  2038  	baseUrl.RawQuery = params.Encode()
  2039  
  2040  	// Build HTTP headers from client and context metadata.
  2041  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2042  
  2043  	hds = append(c.xGoogHeaders, hds...)
  2044  	hds = append(hds, "Content-Type", "application/json")
  2045  	headers := gax.BuildHeaders(ctx, hds...)
  2046  	opts = append((*c.CallOptions).CreateCustomJob[0:len((*c.CallOptions).CreateCustomJob):len((*c.CallOptions).CreateCustomJob)], opts...)
  2047  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2048  	resp := &aiplatformpb.CustomJob{}
  2049  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2050  		if settings.Path != "" {
  2051  			baseUrl.Path = settings.Path
  2052  		}
  2053  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2054  		if err != nil {
  2055  			return err
  2056  		}
  2057  		httpReq = httpReq.WithContext(ctx)
  2058  		httpReq.Header = headers
  2059  
  2060  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCustomJob")
  2061  		if err != nil {
  2062  			return err
  2063  		}
  2064  
  2065  		if err := unm.Unmarshal(buf, resp); err != nil {
  2066  			return err
  2067  		}
  2068  
  2069  		return nil
  2070  	}, opts...)
  2071  	if e != nil {
  2072  		return nil, e
  2073  	}
  2074  	return resp, nil
  2075  }
  2076  
  2077  // GetCustomJob gets a CustomJob.
  2078  func (c *jobRESTClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
  2079  	baseUrl, err := url.Parse(c.endpoint)
  2080  	if err != nil {
  2081  		return nil, err
  2082  	}
  2083  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2084  
  2085  	params := url.Values{}
  2086  	params.Add("$alt", "json;enum-encoding=int")
  2087  
  2088  	baseUrl.RawQuery = params.Encode()
  2089  
  2090  	// Build HTTP headers from client and context metadata.
  2091  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2092  
  2093  	hds = append(c.xGoogHeaders, hds...)
  2094  	hds = append(hds, "Content-Type", "application/json")
  2095  	headers := gax.BuildHeaders(ctx, hds...)
  2096  	opts = append((*c.CallOptions).GetCustomJob[0:len((*c.CallOptions).GetCustomJob):len((*c.CallOptions).GetCustomJob)], opts...)
  2097  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2098  	resp := &aiplatformpb.CustomJob{}
  2099  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2100  		if settings.Path != "" {
  2101  			baseUrl.Path = settings.Path
  2102  		}
  2103  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2104  		if err != nil {
  2105  			return err
  2106  		}
  2107  		httpReq = httpReq.WithContext(ctx)
  2108  		httpReq.Header = headers
  2109  
  2110  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCustomJob")
  2111  		if err != nil {
  2112  			return err
  2113  		}
  2114  
  2115  		if err := unm.Unmarshal(buf, resp); err != nil {
  2116  			return err
  2117  		}
  2118  
  2119  		return nil
  2120  	}, opts...)
  2121  	if e != nil {
  2122  		return nil, e
  2123  	}
  2124  	return resp, nil
  2125  }
  2126  
  2127  // ListCustomJobs lists CustomJobs in a Location.
  2128  func (c *jobRESTClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator {
  2129  	it := &CustomJobIterator{}
  2130  	req = proto.Clone(req).(*aiplatformpb.ListCustomJobsRequest)
  2131  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2132  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.CustomJob, string, error) {
  2133  		resp := &aiplatformpb.ListCustomJobsResponse{}
  2134  		if pageToken != "" {
  2135  			req.PageToken = pageToken
  2136  		}
  2137  		if pageSize > math.MaxInt32 {
  2138  			req.PageSize = math.MaxInt32
  2139  		} else if pageSize != 0 {
  2140  			req.PageSize = int32(pageSize)
  2141  		}
  2142  		baseUrl, err := url.Parse(c.endpoint)
  2143  		if err != nil {
  2144  			return nil, "", err
  2145  		}
  2146  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/customJobs", req.GetParent())
  2147  
  2148  		params := url.Values{}
  2149  		params.Add("$alt", "json;enum-encoding=int")
  2150  		if req.GetFilter() != "" {
  2151  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2152  		}
  2153  		if req.GetPageSize() != 0 {
  2154  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2155  		}
  2156  		if req.GetPageToken() != "" {
  2157  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2158  		}
  2159  		if req.GetReadMask() != nil {
  2160  			field, err := protojson.Marshal(req.GetReadMask())
  2161  			if err != nil {
  2162  				return nil, "", err
  2163  			}
  2164  			params.Add("readMask", string(field[1:len(field)-1]))
  2165  		}
  2166  
  2167  		baseUrl.RawQuery = params.Encode()
  2168  
  2169  		// Build HTTP headers from client and context metadata.
  2170  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2171  		headers := gax.BuildHeaders(ctx, hds...)
  2172  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2173  			if settings.Path != "" {
  2174  				baseUrl.Path = settings.Path
  2175  			}
  2176  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2177  			if err != nil {
  2178  				return err
  2179  			}
  2180  			httpReq.Header = headers
  2181  
  2182  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListCustomJobs")
  2183  			if err != nil {
  2184  				return err
  2185  			}
  2186  			if err := unm.Unmarshal(buf, resp); err != nil {
  2187  				return err
  2188  			}
  2189  
  2190  			return nil
  2191  		}, opts...)
  2192  		if e != nil {
  2193  			return nil, "", e
  2194  		}
  2195  		it.Response = resp
  2196  		return resp.GetCustomJobs(), resp.GetNextPageToken(), nil
  2197  	}
  2198  
  2199  	fetch := func(pageSize int, pageToken string) (string, error) {
  2200  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2201  		if err != nil {
  2202  			return "", err
  2203  		}
  2204  		it.items = append(it.items, items...)
  2205  		return nextPageToken, nil
  2206  	}
  2207  
  2208  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2209  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2210  	it.pageInfo.Token = req.GetPageToken()
  2211  
  2212  	return it
  2213  }
  2214  
  2215  // DeleteCustomJob deletes a CustomJob.
  2216  func (c *jobRESTClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) {
  2217  	baseUrl, err := url.Parse(c.endpoint)
  2218  	if err != nil {
  2219  		return nil, err
  2220  	}
  2221  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2222  
  2223  	params := url.Values{}
  2224  	params.Add("$alt", "json;enum-encoding=int")
  2225  
  2226  	baseUrl.RawQuery = params.Encode()
  2227  
  2228  	// Build HTTP headers from client and context metadata.
  2229  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2230  
  2231  	hds = append(c.xGoogHeaders, hds...)
  2232  	hds = append(hds, "Content-Type", "application/json")
  2233  	headers := gax.BuildHeaders(ctx, hds...)
  2234  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2235  	resp := &longrunningpb.Operation{}
  2236  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2237  		if settings.Path != "" {
  2238  			baseUrl.Path = settings.Path
  2239  		}
  2240  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2241  		if err != nil {
  2242  			return err
  2243  		}
  2244  		httpReq = httpReq.WithContext(ctx)
  2245  		httpReq.Header = headers
  2246  
  2247  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCustomJob")
  2248  		if err != nil {
  2249  			return err
  2250  		}
  2251  		if err := unm.Unmarshal(buf, resp); err != nil {
  2252  			return err
  2253  		}
  2254  
  2255  		return nil
  2256  	}, opts...)
  2257  	if e != nil {
  2258  		return nil, e
  2259  	}
  2260  
  2261  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2262  	return &DeleteCustomJobOperation{
  2263  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2264  		pollPath: override,
  2265  	}, nil
  2266  }
  2267  
  2268  // CancelCustomJob cancels a CustomJob.
  2269  // Starts asynchronous cancellation on the CustomJob. The server
  2270  // makes a best effort to cancel the job, but success is not
  2271  // guaranteed. Clients can use
  2272  // JobService.GetCustomJob
  2273  // or other methods to check whether the cancellation succeeded or whether the
  2274  // job completed despite cancellation. On successful cancellation,
  2275  // the CustomJob is not deleted; instead it becomes a job with
  2276  // a CustomJob.error value
  2277  // with a google.rpc.Status.code of 1, corresponding
  2278  // to Code.CANCELLED, and
  2279  // CustomJob.state is set
  2280  // to CANCELLED.
  2281  func (c *jobRESTClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error {
  2282  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2283  	jsonReq, err := m.Marshal(req)
  2284  	if err != nil {
  2285  		return err
  2286  	}
  2287  
  2288  	baseUrl, err := url.Parse(c.endpoint)
  2289  	if err != nil {
  2290  		return err
  2291  	}
  2292  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:cancel", req.GetName())
  2293  
  2294  	params := url.Values{}
  2295  	params.Add("$alt", "json;enum-encoding=int")
  2296  
  2297  	baseUrl.RawQuery = params.Encode()
  2298  
  2299  	// Build HTTP headers from client and context metadata.
  2300  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2301  
  2302  	hds = append(c.xGoogHeaders, hds...)
  2303  	hds = append(hds, "Content-Type", "application/json")
  2304  	headers := gax.BuildHeaders(ctx, hds...)
  2305  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2306  		if settings.Path != "" {
  2307  			baseUrl.Path = settings.Path
  2308  		}
  2309  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2310  		if err != nil {
  2311  			return err
  2312  		}
  2313  		httpReq = httpReq.WithContext(ctx)
  2314  		httpReq.Header = headers
  2315  
  2316  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelCustomJob")
  2317  		return err
  2318  	}, opts...)
  2319  }
  2320  
  2321  // CreateDataLabelingJob creates a DataLabelingJob.
  2322  func (c *jobRESTClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
  2323  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2324  	body := req.GetDataLabelingJob()
  2325  	jsonReq, err := m.Marshal(body)
  2326  	if err != nil {
  2327  		return nil, err
  2328  	}
  2329  
  2330  	baseUrl, err := url.Parse(c.endpoint)
  2331  	if err != nil {
  2332  		return nil, err
  2333  	}
  2334  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/dataLabelingJobs", req.GetParent())
  2335  
  2336  	params := url.Values{}
  2337  	params.Add("$alt", "json;enum-encoding=int")
  2338  
  2339  	baseUrl.RawQuery = params.Encode()
  2340  
  2341  	// Build HTTP headers from client and context metadata.
  2342  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2343  
  2344  	hds = append(c.xGoogHeaders, hds...)
  2345  	hds = append(hds, "Content-Type", "application/json")
  2346  	headers := gax.BuildHeaders(ctx, hds...)
  2347  	opts = append((*c.CallOptions).CreateDataLabelingJob[0:len((*c.CallOptions).CreateDataLabelingJob):len((*c.CallOptions).CreateDataLabelingJob)], opts...)
  2348  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2349  	resp := &aiplatformpb.DataLabelingJob{}
  2350  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2351  		if settings.Path != "" {
  2352  			baseUrl.Path = settings.Path
  2353  		}
  2354  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2355  		if err != nil {
  2356  			return err
  2357  		}
  2358  		httpReq = httpReq.WithContext(ctx)
  2359  		httpReq.Header = headers
  2360  
  2361  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDataLabelingJob")
  2362  		if err != nil {
  2363  			return err
  2364  		}
  2365  
  2366  		if err := unm.Unmarshal(buf, resp); err != nil {
  2367  			return err
  2368  		}
  2369  
  2370  		return nil
  2371  	}, opts...)
  2372  	if e != nil {
  2373  		return nil, e
  2374  	}
  2375  	return resp, nil
  2376  }
  2377  
  2378  // GetDataLabelingJob gets a DataLabelingJob.
  2379  func (c *jobRESTClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
  2380  	baseUrl, err := url.Parse(c.endpoint)
  2381  	if err != nil {
  2382  		return nil, err
  2383  	}
  2384  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2385  
  2386  	params := url.Values{}
  2387  	params.Add("$alt", "json;enum-encoding=int")
  2388  
  2389  	baseUrl.RawQuery = params.Encode()
  2390  
  2391  	// Build HTTP headers from client and context metadata.
  2392  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2393  
  2394  	hds = append(c.xGoogHeaders, hds...)
  2395  	hds = append(hds, "Content-Type", "application/json")
  2396  	headers := gax.BuildHeaders(ctx, hds...)
  2397  	opts = append((*c.CallOptions).GetDataLabelingJob[0:len((*c.CallOptions).GetDataLabelingJob):len((*c.CallOptions).GetDataLabelingJob)], opts...)
  2398  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2399  	resp := &aiplatformpb.DataLabelingJob{}
  2400  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2401  		if settings.Path != "" {
  2402  			baseUrl.Path = settings.Path
  2403  		}
  2404  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2405  		if err != nil {
  2406  			return err
  2407  		}
  2408  		httpReq = httpReq.WithContext(ctx)
  2409  		httpReq.Header = headers
  2410  
  2411  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDataLabelingJob")
  2412  		if err != nil {
  2413  			return err
  2414  		}
  2415  
  2416  		if err := unm.Unmarshal(buf, resp); err != nil {
  2417  			return err
  2418  		}
  2419  
  2420  		return nil
  2421  	}, opts...)
  2422  	if e != nil {
  2423  		return nil, e
  2424  	}
  2425  	return resp, nil
  2426  }
  2427  
  2428  // ListDataLabelingJobs lists DataLabelingJobs in a Location.
  2429  func (c *jobRESTClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator {
  2430  	it := &DataLabelingJobIterator{}
  2431  	req = proto.Clone(req).(*aiplatformpb.ListDataLabelingJobsRequest)
  2432  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2433  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.DataLabelingJob, string, error) {
  2434  		resp := &aiplatformpb.ListDataLabelingJobsResponse{}
  2435  		if pageToken != "" {
  2436  			req.PageToken = pageToken
  2437  		}
  2438  		if pageSize > math.MaxInt32 {
  2439  			req.PageSize = math.MaxInt32
  2440  		} else if pageSize != 0 {
  2441  			req.PageSize = int32(pageSize)
  2442  		}
  2443  		baseUrl, err := url.Parse(c.endpoint)
  2444  		if err != nil {
  2445  			return nil, "", err
  2446  		}
  2447  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/dataLabelingJobs", req.GetParent())
  2448  
  2449  		params := url.Values{}
  2450  		params.Add("$alt", "json;enum-encoding=int")
  2451  		if req.GetFilter() != "" {
  2452  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2453  		}
  2454  		if req.GetOrderBy() != "" {
  2455  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2456  		}
  2457  		if req.GetPageSize() != 0 {
  2458  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2459  		}
  2460  		if req.GetPageToken() != "" {
  2461  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2462  		}
  2463  		if req.GetReadMask() != nil {
  2464  			field, err := protojson.Marshal(req.GetReadMask())
  2465  			if err != nil {
  2466  				return nil, "", err
  2467  			}
  2468  			params.Add("readMask", string(field[1:len(field)-1]))
  2469  		}
  2470  
  2471  		baseUrl.RawQuery = params.Encode()
  2472  
  2473  		// Build HTTP headers from client and context metadata.
  2474  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2475  		headers := gax.BuildHeaders(ctx, hds...)
  2476  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2477  			if settings.Path != "" {
  2478  				baseUrl.Path = settings.Path
  2479  			}
  2480  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2481  			if err != nil {
  2482  				return err
  2483  			}
  2484  			httpReq.Header = headers
  2485  
  2486  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDataLabelingJobs")
  2487  			if err != nil {
  2488  				return err
  2489  			}
  2490  			if err := unm.Unmarshal(buf, resp); err != nil {
  2491  				return err
  2492  			}
  2493  
  2494  			return nil
  2495  		}, opts...)
  2496  		if e != nil {
  2497  			return nil, "", e
  2498  		}
  2499  		it.Response = resp
  2500  		return resp.GetDataLabelingJobs(), resp.GetNextPageToken(), nil
  2501  	}
  2502  
  2503  	fetch := func(pageSize int, pageToken string) (string, error) {
  2504  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2505  		if err != nil {
  2506  			return "", err
  2507  		}
  2508  		it.items = append(it.items, items...)
  2509  		return nextPageToken, nil
  2510  	}
  2511  
  2512  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2513  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2514  	it.pageInfo.Token = req.GetPageToken()
  2515  
  2516  	return it
  2517  }
  2518  
  2519  // DeleteDataLabelingJob deletes a DataLabelingJob.
  2520  func (c *jobRESTClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) {
  2521  	baseUrl, err := url.Parse(c.endpoint)
  2522  	if err != nil {
  2523  		return nil, err
  2524  	}
  2525  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2526  
  2527  	params := url.Values{}
  2528  	params.Add("$alt", "json;enum-encoding=int")
  2529  
  2530  	baseUrl.RawQuery = params.Encode()
  2531  
  2532  	// Build HTTP headers from client and context metadata.
  2533  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2534  
  2535  	hds = append(c.xGoogHeaders, hds...)
  2536  	hds = append(hds, "Content-Type", "application/json")
  2537  	headers := gax.BuildHeaders(ctx, hds...)
  2538  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2539  	resp := &longrunningpb.Operation{}
  2540  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2541  		if settings.Path != "" {
  2542  			baseUrl.Path = settings.Path
  2543  		}
  2544  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2545  		if err != nil {
  2546  			return err
  2547  		}
  2548  		httpReq = httpReq.WithContext(ctx)
  2549  		httpReq.Header = headers
  2550  
  2551  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDataLabelingJob")
  2552  		if err != nil {
  2553  			return err
  2554  		}
  2555  		if err := unm.Unmarshal(buf, resp); err != nil {
  2556  			return err
  2557  		}
  2558  
  2559  		return nil
  2560  	}, opts...)
  2561  	if e != nil {
  2562  		return nil, e
  2563  	}
  2564  
  2565  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2566  	return &DeleteDataLabelingJobOperation{
  2567  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2568  		pollPath: override,
  2569  	}, nil
  2570  }
  2571  
  2572  // CancelDataLabelingJob cancels a DataLabelingJob. Success of cancellation is not guaranteed.
  2573  func (c *jobRESTClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error {
  2574  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2575  	jsonReq, err := m.Marshal(req)
  2576  	if err != nil {
  2577  		return err
  2578  	}
  2579  
  2580  	baseUrl, err := url.Parse(c.endpoint)
  2581  	if err != nil {
  2582  		return err
  2583  	}
  2584  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:cancel", req.GetName())
  2585  
  2586  	params := url.Values{}
  2587  	params.Add("$alt", "json;enum-encoding=int")
  2588  
  2589  	baseUrl.RawQuery = params.Encode()
  2590  
  2591  	// Build HTTP headers from client and context metadata.
  2592  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2593  
  2594  	hds = append(c.xGoogHeaders, hds...)
  2595  	hds = append(hds, "Content-Type", "application/json")
  2596  	headers := gax.BuildHeaders(ctx, hds...)
  2597  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2598  		if settings.Path != "" {
  2599  			baseUrl.Path = settings.Path
  2600  		}
  2601  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2602  		if err != nil {
  2603  			return err
  2604  		}
  2605  		httpReq = httpReq.WithContext(ctx)
  2606  		httpReq.Header = headers
  2607  
  2608  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelDataLabelingJob")
  2609  		return err
  2610  	}, opts...)
  2611  }
  2612  
  2613  // CreateHyperparameterTuningJob creates a HyperparameterTuningJob
  2614  func (c *jobRESTClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
  2615  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2616  	body := req.GetHyperparameterTuningJob()
  2617  	jsonReq, err := m.Marshal(body)
  2618  	if err != nil {
  2619  		return nil, err
  2620  	}
  2621  
  2622  	baseUrl, err := url.Parse(c.endpoint)
  2623  	if err != nil {
  2624  		return nil, err
  2625  	}
  2626  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/hyperparameterTuningJobs", req.GetParent())
  2627  
  2628  	params := url.Values{}
  2629  	params.Add("$alt", "json;enum-encoding=int")
  2630  
  2631  	baseUrl.RawQuery = params.Encode()
  2632  
  2633  	// Build HTTP headers from client and context metadata.
  2634  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2635  
  2636  	hds = append(c.xGoogHeaders, hds...)
  2637  	hds = append(hds, "Content-Type", "application/json")
  2638  	headers := gax.BuildHeaders(ctx, hds...)
  2639  	opts = append((*c.CallOptions).CreateHyperparameterTuningJob[0:len((*c.CallOptions).CreateHyperparameterTuningJob):len((*c.CallOptions).CreateHyperparameterTuningJob)], opts...)
  2640  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2641  	resp := &aiplatformpb.HyperparameterTuningJob{}
  2642  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2643  		if settings.Path != "" {
  2644  			baseUrl.Path = settings.Path
  2645  		}
  2646  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2647  		if err != nil {
  2648  			return err
  2649  		}
  2650  		httpReq = httpReq.WithContext(ctx)
  2651  		httpReq.Header = headers
  2652  
  2653  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateHyperparameterTuningJob")
  2654  		if err != nil {
  2655  			return err
  2656  		}
  2657  
  2658  		if err := unm.Unmarshal(buf, resp); err != nil {
  2659  			return err
  2660  		}
  2661  
  2662  		return nil
  2663  	}, opts...)
  2664  	if e != nil {
  2665  		return nil, e
  2666  	}
  2667  	return resp, nil
  2668  }
  2669  
  2670  // GetHyperparameterTuningJob gets a HyperparameterTuningJob
  2671  func (c *jobRESTClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
  2672  	baseUrl, err := url.Parse(c.endpoint)
  2673  	if err != nil {
  2674  		return nil, err
  2675  	}
  2676  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2677  
  2678  	params := url.Values{}
  2679  	params.Add("$alt", "json;enum-encoding=int")
  2680  
  2681  	baseUrl.RawQuery = params.Encode()
  2682  
  2683  	// Build HTTP headers from client and context metadata.
  2684  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2685  
  2686  	hds = append(c.xGoogHeaders, hds...)
  2687  	hds = append(hds, "Content-Type", "application/json")
  2688  	headers := gax.BuildHeaders(ctx, hds...)
  2689  	opts = append((*c.CallOptions).GetHyperparameterTuningJob[0:len((*c.CallOptions).GetHyperparameterTuningJob):len((*c.CallOptions).GetHyperparameterTuningJob)], opts...)
  2690  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2691  	resp := &aiplatformpb.HyperparameterTuningJob{}
  2692  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2693  		if settings.Path != "" {
  2694  			baseUrl.Path = settings.Path
  2695  		}
  2696  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2697  		if err != nil {
  2698  			return err
  2699  		}
  2700  		httpReq = httpReq.WithContext(ctx)
  2701  		httpReq.Header = headers
  2702  
  2703  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetHyperparameterTuningJob")
  2704  		if err != nil {
  2705  			return err
  2706  		}
  2707  
  2708  		if err := unm.Unmarshal(buf, resp); err != nil {
  2709  			return err
  2710  		}
  2711  
  2712  		return nil
  2713  	}, opts...)
  2714  	if e != nil {
  2715  		return nil, e
  2716  	}
  2717  	return resp, nil
  2718  }
  2719  
  2720  // ListHyperparameterTuningJobs lists HyperparameterTuningJobs in a Location.
  2721  func (c *jobRESTClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator {
  2722  	it := &HyperparameterTuningJobIterator{}
  2723  	req = proto.Clone(req).(*aiplatformpb.ListHyperparameterTuningJobsRequest)
  2724  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2725  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.HyperparameterTuningJob, string, error) {
  2726  		resp := &aiplatformpb.ListHyperparameterTuningJobsResponse{}
  2727  		if pageToken != "" {
  2728  			req.PageToken = pageToken
  2729  		}
  2730  		if pageSize > math.MaxInt32 {
  2731  			req.PageSize = math.MaxInt32
  2732  		} else if pageSize != 0 {
  2733  			req.PageSize = int32(pageSize)
  2734  		}
  2735  		baseUrl, err := url.Parse(c.endpoint)
  2736  		if err != nil {
  2737  			return nil, "", err
  2738  		}
  2739  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/hyperparameterTuningJobs", req.GetParent())
  2740  
  2741  		params := url.Values{}
  2742  		params.Add("$alt", "json;enum-encoding=int")
  2743  		if req.GetFilter() != "" {
  2744  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2745  		}
  2746  		if req.GetPageSize() != 0 {
  2747  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2748  		}
  2749  		if req.GetPageToken() != "" {
  2750  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2751  		}
  2752  		if req.GetReadMask() != nil {
  2753  			field, err := protojson.Marshal(req.GetReadMask())
  2754  			if err != nil {
  2755  				return nil, "", err
  2756  			}
  2757  			params.Add("readMask", string(field[1:len(field)-1]))
  2758  		}
  2759  
  2760  		baseUrl.RawQuery = params.Encode()
  2761  
  2762  		// Build HTTP headers from client and context metadata.
  2763  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2764  		headers := gax.BuildHeaders(ctx, hds...)
  2765  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2766  			if settings.Path != "" {
  2767  				baseUrl.Path = settings.Path
  2768  			}
  2769  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2770  			if err != nil {
  2771  				return err
  2772  			}
  2773  			httpReq.Header = headers
  2774  
  2775  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListHyperparameterTuningJobs")
  2776  			if err != nil {
  2777  				return err
  2778  			}
  2779  			if err := unm.Unmarshal(buf, resp); err != nil {
  2780  				return err
  2781  			}
  2782  
  2783  			return nil
  2784  		}, opts...)
  2785  		if e != nil {
  2786  			return nil, "", e
  2787  		}
  2788  		it.Response = resp
  2789  		return resp.GetHyperparameterTuningJobs(), resp.GetNextPageToken(), nil
  2790  	}
  2791  
  2792  	fetch := func(pageSize int, pageToken string) (string, error) {
  2793  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2794  		if err != nil {
  2795  			return "", err
  2796  		}
  2797  		it.items = append(it.items, items...)
  2798  		return nextPageToken, nil
  2799  	}
  2800  
  2801  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2802  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2803  	it.pageInfo.Token = req.GetPageToken()
  2804  
  2805  	return it
  2806  }
  2807  
  2808  // DeleteHyperparameterTuningJob deletes a HyperparameterTuningJob.
  2809  func (c *jobRESTClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) {
  2810  	baseUrl, err := url.Parse(c.endpoint)
  2811  	if err != nil {
  2812  		return nil, err
  2813  	}
  2814  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2815  
  2816  	params := url.Values{}
  2817  	params.Add("$alt", "json;enum-encoding=int")
  2818  
  2819  	baseUrl.RawQuery = params.Encode()
  2820  
  2821  	// Build HTTP headers from client and context metadata.
  2822  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2823  
  2824  	hds = append(c.xGoogHeaders, hds...)
  2825  	hds = append(hds, "Content-Type", "application/json")
  2826  	headers := gax.BuildHeaders(ctx, hds...)
  2827  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2828  	resp := &longrunningpb.Operation{}
  2829  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2830  		if settings.Path != "" {
  2831  			baseUrl.Path = settings.Path
  2832  		}
  2833  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2834  		if err != nil {
  2835  			return err
  2836  		}
  2837  		httpReq = httpReq.WithContext(ctx)
  2838  		httpReq.Header = headers
  2839  
  2840  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteHyperparameterTuningJob")
  2841  		if err != nil {
  2842  			return err
  2843  		}
  2844  		if err := unm.Unmarshal(buf, resp); err != nil {
  2845  			return err
  2846  		}
  2847  
  2848  		return nil
  2849  	}, opts...)
  2850  	if e != nil {
  2851  		return nil, e
  2852  	}
  2853  
  2854  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2855  	return &DeleteHyperparameterTuningJobOperation{
  2856  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2857  		pollPath: override,
  2858  	}, nil
  2859  }
  2860  
  2861  // CancelHyperparameterTuningJob cancels a HyperparameterTuningJob.
  2862  // Starts asynchronous cancellation on the HyperparameterTuningJob. The server
  2863  // makes a best effort to cancel the job, but success is not
  2864  // guaranteed. Clients can use
  2865  // JobService.GetHyperparameterTuningJob
  2866  // or other methods to check whether the cancellation succeeded or whether the
  2867  // job completed despite cancellation. On successful cancellation,
  2868  // the HyperparameterTuningJob is not deleted; instead it becomes a job with
  2869  // a
  2870  // HyperparameterTuningJob.error
  2871  // value with a google.rpc.Status.code of 1,
  2872  // corresponding to Code.CANCELLED, and
  2873  // HyperparameterTuningJob.state
  2874  // is set to CANCELLED.
  2875  func (c *jobRESTClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error {
  2876  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2877  	jsonReq, err := m.Marshal(req)
  2878  	if err != nil {
  2879  		return err
  2880  	}
  2881  
  2882  	baseUrl, err := url.Parse(c.endpoint)
  2883  	if err != nil {
  2884  		return err
  2885  	}
  2886  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:cancel", req.GetName())
  2887  
  2888  	params := url.Values{}
  2889  	params.Add("$alt", "json;enum-encoding=int")
  2890  
  2891  	baseUrl.RawQuery = params.Encode()
  2892  
  2893  	// Build HTTP headers from client and context metadata.
  2894  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2895  
  2896  	hds = append(c.xGoogHeaders, hds...)
  2897  	hds = append(hds, "Content-Type", "application/json")
  2898  	headers := gax.BuildHeaders(ctx, hds...)
  2899  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2900  		if settings.Path != "" {
  2901  			baseUrl.Path = settings.Path
  2902  		}
  2903  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2904  		if err != nil {
  2905  			return err
  2906  		}
  2907  		httpReq = httpReq.WithContext(ctx)
  2908  		httpReq.Header = headers
  2909  
  2910  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelHyperparameterTuningJob")
  2911  		return err
  2912  	}, opts...)
  2913  }
  2914  
  2915  // CreateNasJob creates a NasJob
  2916  func (c *jobRESTClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
  2917  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2918  	body := req.GetNasJob()
  2919  	jsonReq, err := m.Marshal(body)
  2920  	if err != nil {
  2921  		return nil, err
  2922  	}
  2923  
  2924  	baseUrl, err := url.Parse(c.endpoint)
  2925  	if err != nil {
  2926  		return nil, err
  2927  	}
  2928  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/nasJobs", req.GetParent())
  2929  
  2930  	params := url.Values{}
  2931  	params.Add("$alt", "json;enum-encoding=int")
  2932  
  2933  	baseUrl.RawQuery = params.Encode()
  2934  
  2935  	// Build HTTP headers from client and context metadata.
  2936  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2937  
  2938  	hds = append(c.xGoogHeaders, hds...)
  2939  	hds = append(hds, "Content-Type", "application/json")
  2940  	headers := gax.BuildHeaders(ctx, hds...)
  2941  	opts = append((*c.CallOptions).CreateNasJob[0:len((*c.CallOptions).CreateNasJob):len((*c.CallOptions).CreateNasJob)], opts...)
  2942  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2943  	resp := &aiplatformpb.NasJob{}
  2944  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2945  		if settings.Path != "" {
  2946  			baseUrl.Path = settings.Path
  2947  		}
  2948  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2949  		if err != nil {
  2950  			return err
  2951  		}
  2952  		httpReq = httpReq.WithContext(ctx)
  2953  		httpReq.Header = headers
  2954  
  2955  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateNasJob")
  2956  		if err != nil {
  2957  			return err
  2958  		}
  2959  
  2960  		if err := unm.Unmarshal(buf, resp); err != nil {
  2961  			return err
  2962  		}
  2963  
  2964  		return nil
  2965  	}, opts...)
  2966  	if e != nil {
  2967  		return nil, e
  2968  	}
  2969  	return resp, nil
  2970  }
  2971  
  2972  // GetNasJob gets a NasJob
  2973  func (c *jobRESTClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
  2974  	baseUrl, err := url.Parse(c.endpoint)
  2975  	if err != nil {
  2976  		return nil, err
  2977  	}
  2978  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2979  
  2980  	params := url.Values{}
  2981  	params.Add("$alt", "json;enum-encoding=int")
  2982  
  2983  	baseUrl.RawQuery = params.Encode()
  2984  
  2985  	// Build HTTP headers from client and context metadata.
  2986  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2987  
  2988  	hds = append(c.xGoogHeaders, hds...)
  2989  	hds = append(hds, "Content-Type", "application/json")
  2990  	headers := gax.BuildHeaders(ctx, hds...)
  2991  	opts = append((*c.CallOptions).GetNasJob[0:len((*c.CallOptions).GetNasJob):len((*c.CallOptions).GetNasJob)], opts...)
  2992  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2993  	resp := &aiplatformpb.NasJob{}
  2994  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2995  		if settings.Path != "" {
  2996  			baseUrl.Path = settings.Path
  2997  		}
  2998  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2999  		if err != nil {
  3000  			return err
  3001  		}
  3002  		httpReq = httpReq.WithContext(ctx)
  3003  		httpReq.Header = headers
  3004  
  3005  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNasJob")
  3006  		if err != nil {
  3007  			return err
  3008  		}
  3009  
  3010  		if err := unm.Unmarshal(buf, resp); err != nil {
  3011  			return err
  3012  		}
  3013  
  3014  		return nil
  3015  	}, opts...)
  3016  	if e != nil {
  3017  		return nil, e
  3018  	}
  3019  	return resp, nil
  3020  }
  3021  
  3022  // ListNasJobs lists NasJobs in a Location.
  3023  func (c *jobRESTClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator {
  3024  	it := &NasJobIterator{}
  3025  	req = proto.Clone(req).(*aiplatformpb.ListNasJobsRequest)
  3026  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3027  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasJob, string, error) {
  3028  		resp := &aiplatformpb.ListNasJobsResponse{}
  3029  		if pageToken != "" {
  3030  			req.PageToken = pageToken
  3031  		}
  3032  		if pageSize > math.MaxInt32 {
  3033  			req.PageSize = math.MaxInt32
  3034  		} else if pageSize != 0 {
  3035  			req.PageSize = int32(pageSize)
  3036  		}
  3037  		baseUrl, err := url.Parse(c.endpoint)
  3038  		if err != nil {
  3039  			return nil, "", err
  3040  		}
  3041  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/nasJobs", req.GetParent())
  3042  
  3043  		params := url.Values{}
  3044  		params.Add("$alt", "json;enum-encoding=int")
  3045  		if req.GetFilter() != "" {
  3046  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3047  		}
  3048  		if req.GetPageSize() != 0 {
  3049  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3050  		}
  3051  		if req.GetPageToken() != "" {
  3052  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3053  		}
  3054  		if req.GetReadMask() != nil {
  3055  			field, err := protojson.Marshal(req.GetReadMask())
  3056  			if err != nil {
  3057  				return nil, "", err
  3058  			}
  3059  			params.Add("readMask", string(field[1:len(field)-1]))
  3060  		}
  3061  
  3062  		baseUrl.RawQuery = params.Encode()
  3063  
  3064  		// Build HTTP headers from client and context metadata.
  3065  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3066  		headers := gax.BuildHeaders(ctx, hds...)
  3067  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3068  			if settings.Path != "" {
  3069  				baseUrl.Path = settings.Path
  3070  			}
  3071  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3072  			if err != nil {
  3073  				return err
  3074  			}
  3075  			httpReq.Header = headers
  3076  
  3077  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNasJobs")
  3078  			if err != nil {
  3079  				return err
  3080  			}
  3081  			if err := unm.Unmarshal(buf, resp); err != nil {
  3082  				return err
  3083  			}
  3084  
  3085  			return nil
  3086  		}, opts...)
  3087  		if e != nil {
  3088  			return nil, "", e
  3089  		}
  3090  		it.Response = resp
  3091  		return resp.GetNasJobs(), resp.GetNextPageToken(), nil
  3092  	}
  3093  
  3094  	fetch := func(pageSize int, pageToken string) (string, error) {
  3095  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3096  		if err != nil {
  3097  			return "", err
  3098  		}
  3099  		it.items = append(it.items, items...)
  3100  		return nextPageToken, nil
  3101  	}
  3102  
  3103  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3104  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3105  	it.pageInfo.Token = req.GetPageToken()
  3106  
  3107  	return it
  3108  }
  3109  
  3110  // DeleteNasJob deletes a NasJob.
  3111  func (c *jobRESTClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) {
  3112  	baseUrl, err := url.Parse(c.endpoint)
  3113  	if err != nil {
  3114  		return nil, err
  3115  	}
  3116  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3117  
  3118  	params := url.Values{}
  3119  	params.Add("$alt", "json;enum-encoding=int")
  3120  
  3121  	baseUrl.RawQuery = params.Encode()
  3122  
  3123  	// Build HTTP headers from client and context metadata.
  3124  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3125  
  3126  	hds = append(c.xGoogHeaders, hds...)
  3127  	hds = append(hds, "Content-Type", "application/json")
  3128  	headers := gax.BuildHeaders(ctx, hds...)
  3129  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3130  	resp := &longrunningpb.Operation{}
  3131  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3132  		if settings.Path != "" {
  3133  			baseUrl.Path = settings.Path
  3134  		}
  3135  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3136  		if err != nil {
  3137  			return err
  3138  		}
  3139  		httpReq = httpReq.WithContext(ctx)
  3140  		httpReq.Header = headers
  3141  
  3142  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteNasJob")
  3143  		if err != nil {
  3144  			return err
  3145  		}
  3146  		if err := unm.Unmarshal(buf, resp); err != nil {
  3147  			return err
  3148  		}
  3149  
  3150  		return nil
  3151  	}, opts...)
  3152  	if e != nil {
  3153  		return nil, e
  3154  	}
  3155  
  3156  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3157  	return &DeleteNasJobOperation{
  3158  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3159  		pollPath: override,
  3160  	}, nil
  3161  }
  3162  
  3163  // CancelNasJob cancels a NasJob.
  3164  // Starts asynchronous cancellation on the NasJob. The server
  3165  // makes a best effort to cancel the job, but success is not
  3166  // guaranteed. Clients can use
  3167  // JobService.GetNasJob
  3168  // or other methods to check whether the cancellation succeeded or whether the
  3169  // job completed despite cancellation. On successful cancellation,
  3170  // the NasJob is not deleted; instead it becomes a job with
  3171  // a NasJob.error value with a
  3172  // google.rpc.Status.code of 1, corresponding to
  3173  // Code.CANCELLED, and
  3174  // NasJob.state is set to
  3175  // CANCELLED.
  3176  func (c *jobRESTClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) error {
  3177  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3178  	jsonReq, err := m.Marshal(req)
  3179  	if err != nil {
  3180  		return err
  3181  	}
  3182  
  3183  	baseUrl, err := url.Parse(c.endpoint)
  3184  	if err != nil {
  3185  		return err
  3186  	}
  3187  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:cancel", req.GetName())
  3188  
  3189  	params := url.Values{}
  3190  	params.Add("$alt", "json;enum-encoding=int")
  3191  
  3192  	baseUrl.RawQuery = params.Encode()
  3193  
  3194  	// Build HTTP headers from client and context metadata.
  3195  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3196  
  3197  	hds = append(c.xGoogHeaders, hds...)
  3198  	hds = append(hds, "Content-Type", "application/json")
  3199  	headers := gax.BuildHeaders(ctx, hds...)
  3200  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3201  		if settings.Path != "" {
  3202  			baseUrl.Path = settings.Path
  3203  		}
  3204  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3205  		if err != nil {
  3206  			return err
  3207  		}
  3208  		httpReq = httpReq.WithContext(ctx)
  3209  		httpReq.Header = headers
  3210  
  3211  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelNasJob")
  3212  		return err
  3213  	}, opts...)
  3214  }
  3215  
  3216  // GetNasTrialDetail gets a NasTrialDetail.
  3217  func (c *jobRESTClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) {
  3218  	baseUrl, err := url.Parse(c.endpoint)
  3219  	if err != nil {
  3220  		return nil, err
  3221  	}
  3222  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3223  
  3224  	params := url.Values{}
  3225  	params.Add("$alt", "json;enum-encoding=int")
  3226  
  3227  	baseUrl.RawQuery = params.Encode()
  3228  
  3229  	// Build HTTP headers from client and context metadata.
  3230  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3231  
  3232  	hds = append(c.xGoogHeaders, hds...)
  3233  	hds = append(hds, "Content-Type", "application/json")
  3234  	headers := gax.BuildHeaders(ctx, hds...)
  3235  	opts = append((*c.CallOptions).GetNasTrialDetail[0:len((*c.CallOptions).GetNasTrialDetail):len((*c.CallOptions).GetNasTrialDetail)], opts...)
  3236  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3237  	resp := &aiplatformpb.NasTrialDetail{}
  3238  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3239  		if settings.Path != "" {
  3240  			baseUrl.Path = settings.Path
  3241  		}
  3242  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3243  		if err != nil {
  3244  			return err
  3245  		}
  3246  		httpReq = httpReq.WithContext(ctx)
  3247  		httpReq.Header = headers
  3248  
  3249  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNasTrialDetail")
  3250  		if err != nil {
  3251  			return err
  3252  		}
  3253  
  3254  		if err := unm.Unmarshal(buf, resp); err != nil {
  3255  			return err
  3256  		}
  3257  
  3258  		return nil
  3259  	}, opts...)
  3260  	if e != nil {
  3261  		return nil, e
  3262  	}
  3263  	return resp, nil
  3264  }
  3265  
  3266  // ListNasTrialDetails list top NasTrialDetails of a NasJob.
  3267  func (c *jobRESTClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator {
  3268  	it := &NasTrialDetailIterator{}
  3269  	req = proto.Clone(req).(*aiplatformpb.ListNasTrialDetailsRequest)
  3270  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3271  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NasTrialDetail, string, error) {
  3272  		resp := &aiplatformpb.ListNasTrialDetailsResponse{}
  3273  		if pageToken != "" {
  3274  			req.PageToken = pageToken
  3275  		}
  3276  		if pageSize > math.MaxInt32 {
  3277  			req.PageSize = math.MaxInt32
  3278  		} else if pageSize != 0 {
  3279  			req.PageSize = int32(pageSize)
  3280  		}
  3281  		baseUrl, err := url.Parse(c.endpoint)
  3282  		if err != nil {
  3283  			return nil, "", err
  3284  		}
  3285  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/nasTrialDetails", req.GetParent())
  3286  
  3287  		params := url.Values{}
  3288  		params.Add("$alt", "json;enum-encoding=int")
  3289  		if req.GetPageSize() != 0 {
  3290  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3291  		}
  3292  		if req.GetPageToken() != "" {
  3293  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3294  		}
  3295  
  3296  		baseUrl.RawQuery = params.Encode()
  3297  
  3298  		// Build HTTP headers from client and context metadata.
  3299  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3300  		headers := gax.BuildHeaders(ctx, hds...)
  3301  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3302  			if settings.Path != "" {
  3303  				baseUrl.Path = settings.Path
  3304  			}
  3305  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3306  			if err != nil {
  3307  				return err
  3308  			}
  3309  			httpReq.Header = headers
  3310  
  3311  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNasTrialDetails")
  3312  			if err != nil {
  3313  				return err
  3314  			}
  3315  			if err := unm.Unmarshal(buf, resp); err != nil {
  3316  				return err
  3317  			}
  3318  
  3319  			return nil
  3320  		}, opts...)
  3321  		if e != nil {
  3322  			return nil, "", e
  3323  		}
  3324  		it.Response = resp
  3325  		return resp.GetNasTrialDetails(), resp.GetNextPageToken(), nil
  3326  	}
  3327  
  3328  	fetch := func(pageSize int, pageToken string) (string, error) {
  3329  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3330  		if err != nil {
  3331  			return "", err
  3332  		}
  3333  		it.items = append(it.items, items...)
  3334  		return nextPageToken, nil
  3335  	}
  3336  
  3337  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3338  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3339  	it.pageInfo.Token = req.GetPageToken()
  3340  
  3341  	return it
  3342  }
  3343  
  3344  // CreateBatchPredictionJob creates a BatchPredictionJob. A BatchPredictionJob once created will
  3345  // right away be attempted to start.
  3346  func (c *jobRESTClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
  3347  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3348  	body := req.GetBatchPredictionJob()
  3349  	jsonReq, err := m.Marshal(body)
  3350  	if err != nil {
  3351  		return nil, err
  3352  	}
  3353  
  3354  	baseUrl, err := url.Parse(c.endpoint)
  3355  	if err != nil {
  3356  		return nil, err
  3357  	}
  3358  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/batchPredictionJobs", req.GetParent())
  3359  
  3360  	params := url.Values{}
  3361  	params.Add("$alt", "json;enum-encoding=int")
  3362  
  3363  	baseUrl.RawQuery = params.Encode()
  3364  
  3365  	// Build HTTP headers from client and context metadata.
  3366  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  3367  
  3368  	hds = append(c.xGoogHeaders, hds...)
  3369  	hds = append(hds, "Content-Type", "application/json")
  3370  	headers := gax.BuildHeaders(ctx, hds...)
  3371  	opts = append((*c.CallOptions).CreateBatchPredictionJob[0:len((*c.CallOptions).CreateBatchPredictionJob):len((*c.CallOptions).CreateBatchPredictionJob)], opts...)
  3372  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3373  	resp := &aiplatformpb.BatchPredictionJob{}
  3374  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3375  		if settings.Path != "" {
  3376  			baseUrl.Path = settings.Path
  3377  		}
  3378  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3379  		if err != nil {
  3380  			return err
  3381  		}
  3382  		httpReq = httpReq.WithContext(ctx)
  3383  		httpReq.Header = headers
  3384  
  3385  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateBatchPredictionJob")
  3386  		if err != nil {
  3387  			return err
  3388  		}
  3389  
  3390  		if err := unm.Unmarshal(buf, resp); err != nil {
  3391  			return err
  3392  		}
  3393  
  3394  		return nil
  3395  	}, opts...)
  3396  	if e != nil {
  3397  		return nil, e
  3398  	}
  3399  	return resp, nil
  3400  }
  3401  
  3402  // GetBatchPredictionJob gets a BatchPredictionJob
  3403  func (c *jobRESTClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
  3404  	baseUrl, err := url.Parse(c.endpoint)
  3405  	if err != nil {
  3406  		return nil, err
  3407  	}
  3408  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3409  
  3410  	params := url.Values{}
  3411  	params.Add("$alt", "json;enum-encoding=int")
  3412  
  3413  	baseUrl.RawQuery = params.Encode()
  3414  
  3415  	// Build HTTP headers from client and context metadata.
  3416  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3417  
  3418  	hds = append(c.xGoogHeaders, hds...)
  3419  	hds = append(hds, "Content-Type", "application/json")
  3420  	headers := gax.BuildHeaders(ctx, hds...)
  3421  	opts = append((*c.CallOptions).GetBatchPredictionJob[0:len((*c.CallOptions).GetBatchPredictionJob):len((*c.CallOptions).GetBatchPredictionJob)], opts...)
  3422  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3423  	resp := &aiplatformpb.BatchPredictionJob{}
  3424  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3425  		if settings.Path != "" {
  3426  			baseUrl.Path = settings.Path
  3427  		}
  3428  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3429  		if err != nil {
  3430  			return err
  3431  		}
  3432  		httpReq = httpReq.WithContext(ctx)
  3433  		httpReq.Header = headers
  3434  
  3435  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetBatchPredictionJob")
  3436  		if err != nil {
  3437  			return err
  3438  		}
  3439  
  3440  		if err := unm.Unmarshal(buf, resp); err != nil {
  3441  			return err
  3442  		}
  3443  
  3444  		return nil
  3445  	}, opts...)
  3446  	if e != nil {
  3447  		return nil, e
  3448  	}
  3449  	return resp, nil
  3450  }
  3451  
  3452  // ListBatchPredictionJobs lists BatchPredictionJobs in a Location.
  3453  func (c *jobRESTClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator {
  3454  	it := &BatchPredictionJobIterator{}
  3455  	req = proto.Clone(req).(*aiplatformpb.ListBatchPredictionJobsRequest)
  3456  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3457  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.BatchPredictionJob, string, error) {
  3458  		resp := &aiplatformpb.ListBatchPredictionJobsResponse{}
  3459  		if pageToken != "" {
  3460  			req.PageToken = pageToken
  3461  		}
  3462  		if pageSize > math.MaxInt32 {
  3463  			req.PageSize = math.MaxInt32
  3464  		} else if pageSize != 0 {
  3465  			req.PageSize = int32(pageSize)
  3466  		}
  3467  		baseUrl, err := url.Parse(c.endpoint)
  3468  		if err != nil {
  3469  			return nil, "", err
  3470  		}
  3471  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/batchPredictionJobs", req.GetParent())
  3472  
  3473  		params := url.Values{}
  3474  		params.Add("$alt", "json;enum-encoding=int")
  3475  		if req.GetFilter() != "" {
  3476  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3477  		}
  3478  		if req.GetPageSize() != 0 {
  3479  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3480  		}
  3481  		if req.GetPageToken() != "" {
  3482  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3483  		}
  3484  		if req.GetReadMask() != nil {
  3485  			field, err := protojson.Marshal(req.GetReadMask())
  3486  			if err != nil {
  3487  				return nil, "", err
  3488  			}
  3489  			params.Add("readMask", string(field[1:len(field)-1]))
  3490  		}
  3491  
  3492  		baseUrl.RawQuery = params.Encode()
  3493  
  3494  		// Build HTTP headers from client and context metadata.
  3495  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3496  		headers := gax.BuildHeaders(ctx, hds...)
  3497  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3498  			if settings.Path != "" {
  3499  				baseUrl.Path = settings.Path
  3500  			}
  3501  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3502  			if err != nil {
  3503  				return err
  3504  			}
  3505  			httpReq.Header = headers
  3506  
  3507  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListBatchPredictionJobs")
  3508  			if err != nil {
  3509  				return err
  3510  			}
  3511  			if err := unm.Unmarshal(buf, resp); err != nil {
  3512  				return err
  3513  			}
  3514  
  3515  			return nil
  3516  		}, opts...)
  3517  		if e != nil {
  3518  			return nil, "", e
  3519  		}
  3520  		it.Response = resp
  3521  		return resp.GetBatchPredictionJobs(), resp.GetNextPageToken(), nil
  3522  	}
  3523  
  3524  	fetch := func(pageSize int, pageToken string) (string, error) {
  3525  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3526  		if err != nil {
  3527  			return "", err
  3528  		}
  3529  		it.items = append(it.items, items...)
  3530  		return nextPageToken, nil
  3531  	}
  3532  
  3533  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3534  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3535  	it.pageInfo.Token = req.GetPageToken()
  3536  
  3537  	return it
  3538  }
  3539  
  3540  // DeleteBatchPredictionJob deletes a BatchPredictionJob. Can only be called on jobs that already
  3541  // finished.
  3542  func (c *jobRESTClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) {
  3543  	baseUrl, err := url.Parse(c.endpoint)
  3544  	if err != nil {
  3545  		return nil, err
  3546  	}
  3547  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3548  
  3549  	params := url.Values{}
  3550  	params.Add("$alt", "json;enum-encoding=int")
  3551  
  3552  	baseUrl.RawQuery = params.Encode()
  3553  
  3554  	// Build HTTP headers from client and context metadata.
  3555  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3556  
  3557  	hds = append(c.xGoogHeaders, hds...)
  3558  	hds = append(hds, "Content-Type", "application/json")
  3559  	headers := gax.BuildHeaders(ctx, hds...)
  3560  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3561  	resp := &longrunningpb.Operation{}
  3562  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3563  		if settings.Path != "" {
  3564  			baseUrl.Path = settings.Path
  3565  		}
  3566  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3567  		if err != nil {
  3568  			return err
  3569  		}
  3570  		httpReq = httpReq.WithContext(ctx)
  3571  		httpReq.Header = headers
  3572  
  3573  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteBatchPredictionJob")
  3574  		if err != nil {
  3575  			return err
  3576  		}
  3577  		if err := unm.Unmarshal(buf, resp); err != nil {
  3578  			return err
  3579  		}
  3580  
  3581  		return nil
  3582  	}, opts...)
  3583  	if e != nil {
  3584  		return nil, e
  3585  	}
  3586  
  3587  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3588  	return &DeleteBatchPredictionJobOperation{
  3589  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3590  		pollPath: override,
  3591  	}, nil
  3592  }
  3593  
  3594  // CancelBatchPredictionJob cancels a BatchPredictionJob.
  3595  //
  3596  // Starts asynchronous cancellation on the BatchPredictionJob. The server
  3597  // makes the best effort to cancel the job, but success is not
  3598  // guaranteed. Clients can use
  3599  // JobService.GetBatchPredictionJob
  3600  // or other methods to check whether the cancellation succeeded or whether the
  3601  // job completed despite cancellation. On a successful cancellation,
  3602  // the BatchPredictionJob is not deleted;instead its
  3603  // BatchPredictionJob.state
  3604  // is set to CANCELLED. Any files already outputted by the job are not
  3605  // deleted.
  3606  func (c *jobRESTClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error {
  3607  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3608  	jsonReq, err := m.Marshal(req)
  3609  	if err != nil {
  3610  		return err
  3611  	}
  3612  
  3613  	baseUrl, err := url.Parse(c.endpoint)
  3614  	if err != nil {
  3615  		return err
  3616  	}
  3617  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:cancel", req.GetName())
  3618  
  3619  	params := url.Values{}
  3620  	params.Add("$alt", "json;enum-encoding=int")
  3621  
  3622  	baseUrl.RawQuery = params.Encode()
  3623  
  3624  	// Build HTTP headers from client and context metadata.
  3625  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3626  
  3627  	hds = append(c.xGoogHeaders, hds...)
  3628  	hds = append(hds, "Content-Type", "application/json")
  3629  	headers := gax.BuildHeaders(ctx, hds...)
  3630  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3631  		if settings.Path != "" {
  3632  			baseUrl.Path = settings.Path
  3633  		}
  3634  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3635  		if err != nil {
  3636  			return err
  3637  		}
  3638  		httpReq = httpReq.WithContext(ctx)
  3639  		httpReq.Header = headers
  3640  
  3641  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelBatchPredictionJob")
  3642  		return err
  3643  	}, opts...)
  3644  }
  3645  
  3646  // CreateModelDeploymentMonitoringJob creates a ModelDeploymentMonitoringJob. It will run periodically on a
  3647  // configured interval.
  3648  func (c *jobRESTClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
  3649  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3650  	body := req.GetModelDeploymentMonitoringJob()
  3651  	jsonReq, err := m.Marshal(body)
  3652  	if err != nil {
  3653  		return nil, err
  3654  	}
  3655  
  3656  	baseUrl, err := url.Parse(c.endpoint)
  3657  	if err != nil {
  3658  		return nil, err
  3659  	}
  3660  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/modelDeploymentMonitoringJobs", req.GetParent())
  3661  
  3662  	params := url.Values{}
  3663  	params.Add("$alt", "json;enum-encoding=int")
  3664  
  3665  	baseUrl.RawQuery = params.Encode()
  3666  
  3667  	// Build HTTP headers from client and context metadata.
  3668  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  3669  
  3670  	hds = append(c.xGoogHeaders, hds...)
  3671  	hds = append(hds, "Content-Type", "application/json")
  3672  	headers := gax.BuildHeaders(ctx, hds...)
  3673  	opts = append((*c.CallOptions).CreateModelDeploymentMonitoringJob[0:len((*c.CallOptions).CreateModelDeploymentMonitoringJob):len((*c.CallOptions).CreateModelDeploymentMonitoringJob)], opts...)
  3674  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3675  	resp := &aiplatformpb.ModelDeploymentMonitoringJob{}
  3676  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3677  		if settings.Path != "" {
  3678  			baseUrl.Path = settings.Path
  3679  		}
  3680  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3681  		if err != nil {
  3682  			return err
  3683  		}
  3684  		httpReq = httpReq.WithContext(ctx)
  3685  		httpReq.Header = headers
  3686  
  3687  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateModelDeploymentMonitoringJob")
  3688  		if err != nil {
  3689  			return err
  3690  		}
  3691  
  3692  		if err := unm.Unmarshal(buf, resp); err != nil {
  3693  			return err
  3694  		}
  3695  
  3696  		return nil
  3697  	}, opts...)
  3698  	if e != nil {
  3699  		return nil, e
  3700  	}
  3701  	return resp, nil
  3702  }
  3703  
  3704  // SearchModelDeploymentMonitoringStatsAnomalies searches Model Monitoring Statistics generated within a given time window.
  3705  func (c *jobRESTClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator {
  3706  	it := &ModelMonitoringStatsAnomaliesIterator{}
  3707  	req = proto.Clone(req).(*aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest)
  3708  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3709  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3710  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelMonitoringStatsAnomalies, string, error) {
  3711  		resp := &aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesResponse{}
  3712  		if pageToken != "" {
  3713  			req.PageToken = pageToken
  3714  		}
  3715  		if pageSize > math.MaxInt32 {
  3716  			req.PageSize = math.MaxInt32
  3717  		} else if pageSize != 0 {
  3718  			req.PageSize = int32(pageSize)
  3719  		}
  3720  		jsonReq, err := m.Marshal(req)
  3721  		if err != nil {
  3722  			return nil, "", err
  3723  		}
  3724  
  3725  		baseUrl, err := url.Parse(c.endpoint)
  3726  		if err != nil {
  3727  			return nil, "", err
  3728  		}
  3729  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v:searchModelDeploymentMonitoringStatsAnomalies", req.GetModelDeploymentMonitoringJob())
  3730  
  3731  		params := url.Values{}
  3732  		params.Add("$alt", "json;enum-encoding=int")
  3733  
  3734  		baseUrl.RawQuery = params.Encode()
  3735  
  3736  		// Build HTTP headers from client and context metadata.
  3737  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3738  		headers := gax.BuildHeaders(ctx, hds...)
  3739  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3740  			if settings.Path != "" {
  3741  				baseUrl.Path = settings.Path
  3742  			}
  3743  			httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3744  			if err != nil {
  3745  				return err
  3746  			}
  3747  			httpReq.Header = headers
  3748  
  3749  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SearchModelDeploymentMonitoringStatsAnomalies")
  3750  			if err != nil {
  3751  				return err
  3752  			}
  3753  			if err := unm.Unmarshal(buf, resp); err != nil {
  3754  				return err
  3755  			}
  3756  
  3757  			return nil
  3758  		}, opts...)
  3759  		if e != nil {
  3760  			return nil, "", e
  3761  		}
  3762  		it.Response = resp
  3763  		return resp.GetMonitoringStats(), resp.GetNextPageToken(), nil
  3764  	}
  3765  
  3766  	fetch := func(pageSize int, pageToken string) (string, error) {
  3767  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3768  		if err != nil {
  3769  			return "", err
  3770  		}
  3771  		it.items = append(it.items, items...)
  3772  		return nextPageToken, nil
  3773  	}
  3774  
  3775  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3776  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3777  	it.pageInfo.Token = req.GetPageToken()
  3778  
  3779  	return it
  3780  }
  3781  
  3782  // GetModelDeploymentMonitoringJob gets a ModelDeploymentMonitoringJob.
  3783  func (c *jobRESTClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
  3784  	baseUrl, err := url.Parse(c.endpoint)
  3785  	if err != nil {
  3786  		return nil, err
  3787  	}
  3788  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3789  
  3790  	params := url.Values{}
  3791  	params.Add("$alt", "json;enum-encoding=int")
  3792  
  3793  	baseUrl.RawQuery = params.Encode()
  3794  
  3795  	// Build HTTP headers from client and context metadata.
  3796  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3797  
  3798  	hds = append(c.xGoogHeaders, hds...)
  3799  	hds = append(hds, "Content-Type", "application/json")
  3800  	headers := gax.BuildHeaders(ctx, hds...)
  3801  	opts = append((*c.CallOptions).GetModelDeploymentMonitoringJob[0:len((*c.CallOptions).GetModelDeploymentMonitoringJob):len((*c.CallOptions).GetModelDeploymentMonitoringJob)], opts...)
  3802  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3803  	resp := &aiplatformpb.ModelDeploymentMonitoringJob{}
  3804  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3805  		if settings.Path != "" {
  3806  			baseUrl.Path = settings.Path
  3807  		}
  3808  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3809  		if err != nil {
  3810  			return err
  3811  		}
  3812  		httpReq = httpReq.WithContext(ctx)
  3813  		httpReq.Header = headers
  3814  
  3815  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModelDeploymentMonitoringJob")
  3816  		if err != nil {
  3817  			return err
  3818  		}
  3819  
  3820  		if err := unm.Unmarshal(buf, resp); err != nil {
  3821  			return err
  3822  		}
  3823  
  3824  		return nil
  3825  	}, opts...)
  3826  	if e != nil {
  3827  		return nil, e
  3828  	}
  3829  	return resp, nil
  3830  }
  3831  
  3832  // ListModelDeploymentMonitoringJobs lists ModelDeploymentMonitoringJobs in a Location.
  3833  func (c *jobRESTClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator {
  3834  	it := &ModelDeploymentMonitoringJobIterator{}
  3835  	req = proto.Clone(req).(*aiplatformpb.ListModelDeploymentMonitoringJobsRequest)
  3836  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3837  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelDeploymentMonitoringJob, string, error) {
  3838  		resp := &aiplatformpb.ListModelDeploymentMonitoringJobsResponse{}
  3839  		if pageToken != "" {
  3840  			req.PageToken = pageToken
  3841  		}
  3842  		if pageSize > math.MaxInt32 {
  3843  			req.PageSize = math.MaxInt32
  3844  		} else if pageSize != 0 {
  3845  			req.PageSize = int32(pageSize)
  3846  		}
  3847  		baseUrl, err := url.Parse(c.endpoint)
  3848  		if err != nil {
  3849  			return nil, "", err
  3850  		}
  3851  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/modelDeploymentMonitoringJobs", req.GetParent())
  3852  
  3853  		params := url.Values{}
  3854  		params.Add("$alt", "json;enum-encoding=int")
  3855  		if req.GetFilter() != "" {
  3856  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3857  		}
  3858  		if req.GetPageSize() != 0 {
  3859  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3860  		}
  3861  		if req.GetPageToken() != "" {
  3862  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3863  		}
  3864  		if req.GetReadMask() != nil {
  3865  			field, err := protojson.Marshal(req.GetReadMask())
  3866  			if err != nil {
  3867  				return nil, "", err
  3868  			}
  3869  			params.Add("readMask", string(field[1:len(field)-1]))
  3870  		}
  3871  
  3872  		baseUrl.RawQuery = params.Encode()
  3873  
  3874  		// Build HTTP headers from client and context metadata.
  3875  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3876  		headers := gax.BuildHeaders(ctx, hds...)
  3877  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3878  			if settings.Path != "" {
  3879  				baseUrl.Path = settings.Path
  3880  			}
  3881  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3882  			if err != nil {
  3883  				return err
  3884  			}
  3885  			httpReq.Header = headers
  3886  
  3887  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelDeploymentMonitoringJobs")
  3888  			if err != nil {
  3889  				return err
  3890  			}
  3891  			if err := unm.Unmarshal(buf, resp); err != nil {
  3892  				return err
  3893  			}
  3894  
  3895  			return nil
  3896  		}, opts...)
  3897  		if e != nil {
  3898  			return nil, "", e
  3899  		}
  3900  		it.Response = resp
  3901  		return resp.GetModelDeploymentMonitoringJobs(), resp.GetNextPageToken(), nil
  3902  	}
  3903  
  3904  	fetch := func(pageSize int, pageToken string) (string, error) {
  3905  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3906  		if err != nil {
  3907  			return "", err
  3908  		}
  3909  		it.items = append(it.items, items...)
  3910  		return nextPageToken, nil
  3911  	}
  3912  
  3913  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3914  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3915  	it.pageInfo.Token = req.GetPageToken()
  3916  
  3917  	return it
  3918  }
  3919  
  3920  // UpdateModelDeploymentMonitoringJob updates a ModelDeploymentMonitoringJob.
  3921  func (c *jobRESTClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) {
  3922  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3923  	body := req.GetModelDeploymentMonitoringJob()
  3924  	jsonReq, err := m.Marshal(body)
  3925  	if err != nil {
  3926  		return nil, err
  3927  	}
  3928  
  3929  	baseUrl, err := url.Parse(c.endpoint)
  3930  	if err != nil {
  3931  		return nil, err
  3932  	}
  3933  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetModelDeploymentMonitoringJob().GetName())
  3934  
  3935  	params := url.Values{}
  3936  	params.Add("$alt", "json;enum-encoding=int")
  3937  	if req.GetUpdateMask() != nil {
  3938  		field, err := protojson.Marshal(req.GetUpdateMask())
  3939  		if err != nil {
  3940  			return nil, err
  3941  		}
  3942  		params.Add("updateMask", string(field[1:len(field)-1]))
  3943  	}
  3944  
  3945  	baseUrl.RawQuery = params.Encode()
  3946  
  3947  	// Build HTTP headers from client and context metadata.
  3948  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model_deployment_monitoring_job.name", url.QueryEscape(req.GetModelDeploymentMonitoringJob().GetName()))}
  3949  
  3950  	hds = append(c.xGoogHeaders, hds...)
  3951  	hds = append(hds, "Content-Type", "application/json")
  3952  	headers := gax.BuildHeaders(ctx, hds...)
  3953  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3954  	resp := &longrunningpb.Operation{}
  3955  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3956  		if settings.Path != "" {
  3957  			baseUrl.Path = settings.Path
  3958  		}
  3959  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  3960  		if err != nil {
  3961  			return err
  3962  		}
  3963  		httpReq = httpReq.WithContext(ctx)
  3964  		httpReq.Header = headers
  3965  
  3966  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateModelDeploymentMonitoringJob")
  3967  		if err != nil {
  3968  			return err
  3969  		}
  3970  		if err := unm.Unmarshal(buf, resp); err != nil {
  3971  			return err
  3972  		}
  3973  
  3974  		return nil
  3975  	}, opts...)
  3976  	if e != nil {
  3977  		return nil, e
  3978  	}
  3979  
  3980  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3981  	return &UpdateModelDeploymentMonitoringJobOperation{
  3982  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3983  		pollPath: override,
  3984  	}, nil
  3985  }
  3986  
  3987  // DeleteModelDeploymentMonitoringJob deletes a ModelDeploymentMonitoringJob.
  3988  func (c *jobRESTClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) {
  3989  	baseUrl, err := url.Parse(c.endpoint)
  3990  	if err != nil {
  3991  		return nil, err
  3992  	}
  3993  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3994  
  3995  	params := url.Values{}
  3996  	params.Add("$alt", "json;enum-encoding=int")
  3997  
  3998  	baseUrl.RawQuery = params.Encode()
  3999  
  4000  	// Build HTTP headers from client and context metadata.
  4001  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4002  
  4003  	hds = append(c.xGoogHeaders, hds...)
  4004  	hds = append(hds, "Content-Type", "application/json")
  4005  	headers := gax.BuildHeaders(ctx, hds...)
  4006  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4007  	resp := &longrunningpb.Operation{}
  4008  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4009  		if settings.Path != "" {
  4010  			baseUrl.Path = settings.Path
  4011  		}
  4012  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  4013  		if err != nil {
  4014  			return err
  4015  		}
  4016  		httpReq = httpReq.WithContext(ctx)
  4017  		httpReq.Header = headers
  4018  
  4019  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteModelDeploymentMonitoringJob")
  4020  		if err != nil {
  4021  			return err
  4022  		}
  4023  		if err := unm.Unmarshal(buf, resp); err != nil {
  4024  			return err
  4025  		}
  4026  
  4027  		return nil
  4028  	}, opts...)
  4029  	if e != nil {
  4030  		return nil, e
  4031  	}
  4032  
  4033  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  4034  	return &DeleteModelDeploymentMonitoringJobOperation{
  4035  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  4036  		pollPath: override,
  4037  	}, nil
  4038  }
  4039  
  4040  // PauseModelDeploymentMonitoringJob pauses a ModelDeploymentMonitoringJob. If the job is running, the server
  4041  // makes a best effort to cancel the job. Will mark
  4042  // ModelDeploymentMonitoringJob.state
  4043  // to ‘PAUSED’.
  4044  func (c *jobRESTClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
  4045  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4046  	jsonReq, err := m.Marshal(req)
  4047  	if err != nil {
  4048  		return err
  4049  	}
  4050  
  4051  	baseUrl, err := url.Parse(c.endpoint)
  4052  	if err != nil {
  4053  		return err
  4054  	}
  4055  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:pause", req.GetName())
  4056  
  4057  	params := url.Values{}
  4058  	params.Add("$alt", "json;enum-encoding=int")
  4059  
  4060  	baseUrl.RawQuery = params.Encode()
  4061  
  4062  	// Build HTTP headers from client and context metadata.
  4063  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4064  
  4065  	hds = append(c.xGoogHeaders, hds...)
  4066  	hds = append(hds, "Content-Type", "application/json")
  4067  	headers := gax.BuildHeaders(ctx, hds...)
  4068  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4069  		if settings.Path != "" {
  4070  			baseUrl.Path = settings.Path
  4071  		}
  4072  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4073  		if err != nil {
  4074  			return err
  4075  		}
  4076  		httpReq = httpReq.WithContext(ctx)
  4077  		httpReq.Header = headers
  4078  
  4079  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PauseModelDeploymentMonitoringJob")
  4080  		return err
  4081  	}, opts...)
  4082  }
  4083  
  4084  // ResumeModelDeploymentMonitoringJob resumes a paused ModelDeploymentMonitoringJob. It will start to run from
  4085  // next scheduled time. A deleted ModelDeploymentMonitoringJob can’t be
  4086  // resumed.
  4087  func (c *jobRESTClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
  4088  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4089  	jsonReq, err := m.Marshal(req)
  4090  	if err != nil {
  4091  		return err
  4092  	}
  4093  
  4094  	baseUrl, err := url.Parse(c.endpoint)
  4095  	if err != nil {
  4096  		return err
  4097  	}
  4098  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:resume", req.GetName())
  4099  
  4100  	params := url.Values{}
  4101  	params.Add("$alt", "json;enum-encoding=int")
  4102  
  4103  	baseUrl.RawQuery = params.Encode()
  4104  
  4105  	// Build HTTP headers from client and context metadata.
  4106  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4107  
  4108  	hds = append(c.xGoogHeaders, hds...)
  4109  	hds = append(hds, "Content-Type", "application/json")
  4110  	headers := gax.BuildHeaders(ctx, hds...)
  4111  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4112  		if settings.Path != "" {
  4113  			baseUrl.Path = settings.Path
  4114  		}
  4115  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4116  		if err != nil {
  4117  			return err
  4118  		}
  4119  		httpReq = httpReq.WithContext(ctx)
  4120  		httpReq.Header = headers
  4121  
  4122  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ResumeModelDeploymentMonitoringJob")
  4123  		return err
  4124  	}, opts...)
  4125  }
  4126  
  4127  // GetLocation gets information about a location.
  4128  func (c *jobRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  4129  	baseUrl, err := url.Parse(c.endpoint)
  4130  	if err != nil {
  4131  		return nil, err
  4132  	}
  4133  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  4134  
  4135  	params := url.Values{}
  4136  	params.Add("$alt", "json;enum-encoding=int")
  4137  
  4138  	baseUrl.RawQuery = params.Encode()
  4139  
  4140  	// Build HTTP headers from client and context metadata.
  4141  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4142  
  4143  	hds = append(c.xGoogHeaders, hds...)
  4144  	hds = append(hds, "Content-Type", "application/json")
  4145  	headers := gax.BuildHeaders(ctx, hds...)
  4146  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  4147  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4148  	resp := &locationpb.Location{}
  4149  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4150  		if settings.Path != "" {
  4151  			baseUrl.Path = settings.Path
  4152  		}
  4153  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4154  		if err != nil {
  4155  			return err
  4156  		}
  4157  		httpReq = httpReq.WithContext(ctx)
  4158  		httpReq.Header = headers
  4159  
  4160  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  4161  		if err != nil {
  4162  			return err
  4163  		}
  4164  
  4165  		if err := unm.Unmarshal(buf, resp); err != nil {
  4166  			return err
  4167  		}
  4168  
  4169  		return nil
  4170  	}, opts...)
  4171  	if e != nil {
  4172  		return nil, e
  4173  	}
  4174  	return resp, nil
  4175  }
  4176  
  4177  // ListLocations lists information about the supported locations for this service.
  4178  func (c *jobRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  4179  	it := &LocationIterator{}
  4180  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  4181  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4182  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  4183  		resp := &locationpb.ListLocationsResponse{}
  4184  		if pageToken != "" {
  4185  			req.PageToken = pageToken
  4186  		}
  4187  		if pageSize > math.MaxInt32 {
  4188  			req.PageSize = math.MaxInt32
  4189  		} else if pageSize != 0 {
  4190  			req.PageSize = int32(pageSize)
  4191  		}
  4192  		baseUrl, err := url.Parse(c.endpoint)
  4193  		if err != nil {
  4194  			return nil, "", err
  4195  		}
  4196  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  4197  
  4198  		params := url.Values{}
  4199  		params.Add("$alt", "json;enum-encoding=int")
  4200  		if req.GetFilter() != "" {
  4201  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  4202  		}
  4203  		if req.GetPageSize() != 0 {
  4204  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  4205  		}
  4206  		if req.GetPageToken() != "" {
  4207  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  4208  		}
  4209  
  4210  		baseUrl.RawQuery = params.Encode()
  4211  
  4212  		// Build HTTP headers from client and context metadata.
  4213  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  4214  		headers := gax.BuildHeaders(ctx, hds...)
  4215  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4216  			if settings.Path != "" {
  4217  				baseUrl.Path = settings.Path
  4218  			}
  4219  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4220  			if err != nil {
  4221  				return err
  4222  			}
  4223  			httpReq.Header = headers
  4224  
  4225  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  4226  			if err != nil {
  4227  				return err
  4228  			}
  4229  			if err := unm.Unmarshal(buf, resp); err != nil {
  4230  				return err
  4231  			}
  4232  
  4233  			return nil
  4234  		}, opts...)
  4235  		if e != nil {
  4236  			return nil, "", e
  4237  		}
  4238  		it.Response = resp
  4239  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  4240  	}
  4241  
  4242  	fetch := func(pageSize int, pageToken string) (string, error) {
  4243  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  4244  		if err != nil {
  4245  			return "", err
  4246  		}
  4247  		it.items = append(it.items, items...)
  4248  		return nextPageToken, nil
  4249  	}
  4250  
  4251  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  4252  	it.pageInfo.MaxSize = int(req.GetPageSize())
  4253  	it.pageInfo.Token = req.GetPageToken()
  4254  
  4255  	return it
  4256  }
  4257  
  4258  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  4259  // if the resource exists and does not have a policy set.
  4260  func (c *jobRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  4261  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4262  	jsonReq, err := m.Marshal(req)
  4263  	if err != nil {
  4264  		return nil, err
  4265  	}
  4266  
  4267  	baseUrl, err := url.Parse(c.endpoint)
  4268  	if err != nil {
  4269  		return nil, err
  4270  	}
  4271  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  4272  
  4273  	params := url.Values{}
  4274  	params.Add("$alt", "json;enum-encoding=int")
  4275  
  4276  	baseUrl.RawQuery = params.Encode()
  4277  
  4278  	// Build HTTP headers from client and context metadata.
  4279  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  4280  
  4281  	hds = append(c.xGoogHeaders, hds...)
  4282  	hds = append(hds, "Content-Type", "application/json")
  4283  	headers := gax.BuildHeaders(ctx, hds...)
  4284  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  4285  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4286  	resp := &iampb.Policy{}
  4287  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4288  		if settings.Path != "" {
  4289  			baseUrl.Path = settings.Path
  4290  		}
  4291  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4292  		if err != nil {
  4293  			return err
  4294  		}
  4295  		httpReq = httpReq.WithContext(ctx)
  4296  		httpReq.Header = headers
  4297  
  4298  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  4299  		if err != nil {
  4300  			return err
  4301  		}
  4302  
  4303  		if err := unm.Unmarshal(buf, resp); err != nil {
  4304  			return err
  4305  		}
  4306  
  4307  		return nil
  4308  	}, opts...)
  4309  	if e != nil {
  4310  		return nil, e
  4311  	}
  4312  	return resp, nil
  4313  }
  4314  
  4315  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  4316  // any existing policy.
  4317  //
  4318  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  4319  // errors.
  4320  func (c *jobRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  4321  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4322  	jsonReq, err := m.Marshal(req)
  4323  	if err != nil {
  4324  		return nil, err
  4325  	}
  4326  
  4327  	baseUrl, err := url.Parse(c.endpoint)
  4328  	if err != nil {
  4329  		return nil, err
  4330  	}
  4331  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  4332  
  4333  	params := url.Values{}
  4334  	params.Add("$alt", "json;enum-encoding=int")
  4335  
  4336  	baseUrl.RawQuery = params.Encode()
  4337  
  4338  	// Build HTTP headers from client and context metadata.
  4339  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  4340  
  4341  	hds = append(c.xGoogHeaders, hds...)
  4342  	hds = append(hds, "Content-Type", "application/json")
  4343  	headers := gax.BuildHeaders(ctx, hds...)
  4344  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  4345  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4346  	resp := &iampb.Policy{}
  4347  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4348  		if settings.Path != "" {
  4349  			baseUrl.Path = settings.Path
  4350  		}
  4351  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4352  		if err != nil {
  4353  			return err
  4354  		}
  4355  		httpReq = httpReq.WithContext(ctx)
  4356  		httpReq.Header = headers
  4357  
  4358  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  4359  		if err != nil {
  4360  			return err
  4361  		}
  4362  
  4363  		if err := unm.Unmarshal(buf, resp); err != nil {
  4364  			return err
  4365  		}
  4366  
  4367  		return nil
  4368  	}, opts...)
  4369  	if e != nil {
  4370  		return nil, e
  4371  	}
  4372  	return resp, nil
  4373  }
  4374  
  4375  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  4376  // resource does not exist, this will return an empty set of
  4377  // permissions, not a NOT_FOUND error.
  4378  //
  4379  // Note: This operation is designed to be used for building
  4380  // permission-aware UIs and command-line tools, not for authorization
  4381  // checking. This operation may “fail open” without warning.
  4382  func (c *jobRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  4383  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4384  	jsonReq, err := m.Marshal(req)
  4385  	if err != nil {
  4386  		return nil, err
  4387  	}
  4388  
  4389  	baseUrl, err := url.Parse(c.endpoint)
  4390  	if err != nil {
  4391  		return nil, err
  4392  	}
  4393  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  4394  
  4395  	params := url.Values{}
  4396  	params.Add("$alt", "json;enum-encoding=int")
  4397  
  4398  	baseUrl.RawQuery = params.Encode()
  4399  
  4400  	// Build HTTP headers from client and context metadata.
  4401  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  4402  
  4403  	hds = append(c.xGoogHeaders, hds...)
  4404  	hds = append(hds, "Content-Type", "application/json")
  4405  	headers := gax.BuildHeaders(ctx, hds...)
  4406  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  4407  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4408  	resp := &iampb.TestIamPermissionsResponse{}
  4409  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4410  		if settings.Path != "" {
  4411  			baseUrl.Path = settings.Path
  4412  		}
  4413  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4414  		if err != nil {
  4415  			return err
  4416  		}
  4417  		httpReq = httpReq.WithContext(ctx)
  4418  		httpReq.Header = headers
  4419  
  4420  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  4421  		if err != nil {
  4422  			return err
  4423  		}
  4424  
  4425  		if err := unm.Unmarshal(buf, resp); err != nil {
  4426  			return err
  4427  		}
  4428  
  4429  		return nil
  4430  	}, opts...)
  4431  	if e != nil {
  4432  		return nil, e
  4433  	}
  4434  	return resp, nil
  4435  }
  4436  
  4437  // CancelOperation is a utility method from google.longrunning.Operations.
  4438  func (c *jobRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  4439  	baseUrl, err := url.Parse(c.endpoint)
  4440  	if err != nil {
  4441  		return err
  4442  	}
  4443  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  4444  
  4445  	params := url.Values{}
  4446  	params.Add("$alt", "json;enum-encoding=int")
  4447  
  4448  	baseUrl.RawQuery = params.Encode()
  4449  
  4450  	// Build HTTP headers from client and context metadata.
  4451  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4452  
  4453  	hds = append(c.xGoogHeaders, hds...)
  4454  	hds = append(hds, "Content-Type", "application/json")
  4455  	headers := gax.BuildHeaders(ctx, hds...)
  4456  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4457  		if settings.Path != "" {
  4458  			baseUrl.Path = settings.Path
  4459  		}
  4460  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  4461  		if err != nil {
  4462  			return err
  4463  		}
  4464  		httpReq = httpReq.WithContext(ctx)
  4465  		httpReq.Header = headers
  4466  
  4467  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  4468  		return err
  4469  	}, opts...)
  4470  }
  4471  
  4472  // DeleteOperation is a utility method from google.longrunning.Operations.
  4473  func (c *jobRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  4474  	baseUrl, err := url.Parse(c.endpoint)
  4475  	if err != nil {
  4476  		return err
  4477  	}
  4478  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  4479  
  4480  	params := url.Values{}
  4481  	params.Add("$alt", "json;enum-encoding=int")
  4482  
  4483  	baseUrl.RawQuery = params.Encode()
  4484  
  4485  	// Build HTTP headers from client and context metadata.
  4486  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4487  
  4488  	hds = append(c.xGoogHeaders, hds...)
  4489  	hds = append(hds, "Content-Type", "application/json")
  4490  	headers := gax.BuildHeaders(ctx, hds...)
  4491  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4492  		if settings.Path != "" {
  4493  			baseUrl.Path = settings.Path
  4494  		}
  4495  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  4496  		if err != nil {
  4497  			return err
  4498  		}
  4499  		httpReq = httpReq.WithContext(ctx)
  4500  		httpReq.Header = headers
  4501  
  4502  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  4503  		return err
  4504  	}, opts...)
  4505  }
  4506  
  4507  // GetOperation is a utility method from google.longrunning.Operations.
  4508  func (c *jobRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  4509  	baseUrl, err := url.Parse(c.endpoint)
  4510  	if err != nil {
  4511  		return nil, err
  4512  	}
  4513  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  4514  
  4515  	params := url.Values{}
  4516  	params.Add("$alt", "json;enum-encoding=int")
  4517  
  4518  	baseUrl.RawQuery = params.Encode()
  4519  
  4520  	// Build HTTP headers from client and context metadata.
  4521  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4522  
  4523  	hds = append(c.xGoogHeaders, hds...)
  4524  	hds = append(hds, "Content-Type", "application/json")
  4525  	headers := gax.BuildHeaders(ctx, hds...)
  4526  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  4527  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4528  	resp := &longrunningpb.Operation{}
  4529  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4530  		if settings.Path != "" {
  4531  			baseUrl.Path = settings.Path
  4532  		}
  4533  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4534  		if err != nil {
  4535  			return err
  4536  		}
  4537  		httpReq = httpReq.WithContext(ctx)
  4538  		httpReq.Header = headers
  4539  
  4540  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  4541  		if err != nil {
  4542  			return err
  4543  		}
  4544  
  4545  		if err := unm.Unmarshal(buf, resp); err != nil {
  4546  			return err
  4547  		}
  4548  
  4549  		return nil
  4550  	}, opts...)
  4551  	if e != nil {
  4552  		return nil, e
  4553  	}
  4554  	return resp, nil
  4555  }
  4556  
  4557  // ListOperations is a utility method from google.longrunning.Operations.
  4558  func (c *jobRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  4559  	it := &OperationIterator{}
  4560  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  4561  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4562  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  4563  		resp := &longrunningpb.ListOperationsResponse{}
  4564  		if pageToken != "" {
  4565  			req.PageToken = pageToken
  4566  		}
  4567  		if pageSize > math.MaxInt32 {
  4568  			req.PageSize = math.MaxInt32
  4569  		} else if pageSize != 0 {
  4570  			req.PageSize = int32(pageSize)
  4571  		}
  4572  		baseUrl, err := url.Parse(c.endpoint)
  4573  		if err != nil {
  4574  			return nil, "", err
  4575  		}
  4576  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  4577  
  4578  		params := url.Values{}
  4579  		params.Add("$alt", "json;enum-encoding=int")
  4580  		if req.GetFilter() != "" {
  4581  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  4582  		}
  4583  		if req.GetPageSize() != 0 {
  4584  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  4585  		}
  4586  		if req.GetPageToken() != "" {
  4587  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  4588  		}
  4589  
  4590  		baseUrl.RawQuery = params.Encode()
  4591  
  4592  		// Build HTTP headers from client and context metadata.
  4593  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  4594  		headers := gax.BuildHeaders(ctx, hds...)
  4595  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4596  			if settings.Path != "" {
  4597  				baseUrl.Path = settings.Path
  4598  			}
  4599  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4600  			if err != nil {
  4601  				return err
  4602  			}
  4603  			httpReq.Header = headers
  4604  
  4605  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  4606  			if err != nil {
  4607  				return err
  4608  			}
  4609  			if err := unm.Unmarshal(buf, resp); err != nil {
  4610  				return err
  4611  			}
  4612  
  4613  			return nil
  4614  		}, opts...)
  4615  		if e != nil {
  4616  			return nil, "", e
  4617  		}
  4618  		it.Response = resp
  4619  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  4620  	}
  4621  
  4622  	fetch := func(pageSize int, pageToken string) (string, error) {
  4623  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  4624  		if err != nil {
  4625  			return "", err
  4626  		}
  4627  		it.items = append(it.items, items...)
  4628  		return nextPageToken, nil
  4629  	}
  4630  
  4631  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  4632  	it.pageInfo.MaxSize = int(req.GetPageSize())
  4633  	it.pageInfo.Token = req.GetPageToken()
  4634  
  4635  	return it
  4636  }
  4637  
  4638  // WaitOperation is a utility method from google.longrunning.Operations.
  4639  func (c *jobRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  4640  	baseUrl, err := url.Parse(c.endpoint)
  4641  	if err != nil {
  4642  		return nil, err
  4643  	}
  4644  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  4645  
  4646  	params := url.Values{}
  4647  	params.Add("$alt", "json;enum-encoding=int")
  4648  	if req.GetTimeout() != nil {
  4649  		field, err := protojson.Marshal(req.GetTimeout())
  4650  		if err != nil {
  4651  			return nil, err
  4652  		}
  4653  		params.Add("timeout", string(field[1:len(field)-1]))
  4654  	}
  4655  
  4656  	baseUrl.RawQuery = params.Encode()
  4657  
  4658  	// Build HTTP headers from client and context metadata.
  4659  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4660  
  4661  	hds = append(c.xGoogHeaders, hds...)
  4662  	hds = append(hds, "Content-Type", "application/json")
  4663  	headers := gax.BuildHeaders(ctx, hds...)
  4664  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  4665  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4666  	resp := &longrunningpb.Operation{}
  4667  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4668  		if settings.Path != "" {
  4669  			baseUrl.Path = settings.Path
  4670  		}
  4671  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  4672  		if err != nil {
  4673  			return err
  4674  		}
  4675  		httpReq = httpReq.WithContext(ctx)
  4676  		httpReq.Header = headers
  4677  
  4678  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  4679  		if err != nil {
  4680  			return err
  4681  		}
  4682  
  4683  		if err := unm.Unmarshal(buf, resp); err != nil {
  4684  			return err
  4685  		}
  4686  
  4687  		return nil
  4688  	}, opts...)
  4689  	if e != nil {
  4690  		return nil, e
  4691  	}
  4692  	return resp, nil
  4693  }
  4694  
  4695  // DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name.
  4696  // The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process.
  4697  func (c *jobGRPCClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation {
  4698  	return &DeleteBatchPredictionJobOperation{
  4699  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4700  	}
  4701  }
  4702  
  4703  // DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name.
  4704  // The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process.
  4705  func (c *jobRESTClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation {
  4706  	override := fmt.Sprintf("/ui/%s", name)
  4707  	return &DeleteBatchPredictionJobOperation{
  4708  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4709  		pollPath: override,
  4710  	}
  4711  }
  4712  
  4713  // DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name.
  4714  // The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process.
  4715  func (c *jobGRPCClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation {
  4716  	return &DeleteCustomJobOperation{
  4717  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4718  	}
  4719  }
  4720  
  4721  // DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name.
  4722  // The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process.
  4723  func (c *jobRESTClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation {
  4724  	override := fmt.Sprintf("/ui/%s", name)
  4725  	return &DeleteCustomJobOperation{
  4726  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4727  		pollPath: override,
  4728  	}
  4729  }
  4730  
  4731  // DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name.
  4732  // The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process.
  4733  func (c *jobGRPCClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation {
  4734  	return &DeleteDataLabelingJobOperation{
  4735  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4736  	}
  4737  }
  4738  
  4739  // DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name.
  4740  // The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process.
  4741  func (c *jobRESTClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation {
  4742  	override := fmt.Sprintf("/ui/%s", name)
  4743  	return &DeleteDataLabelingJobOperation{
  4744  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4745  		pollPath: override,
  4746  	}
  4747  }
  4748  
  4749  // DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name.
  4750  // The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process.
  4751  func (c *jobGRPCClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation {
  4752  	return &DeleteHyperparameterTuningJobOperation{
  4753  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4754  	}
  4755  }
  4756  
  4757  // DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name.
  4758  // The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process.
  4759  func (c *jobRESTClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation {
  4760  	override := fmt.Sprintf("/ui/%s", name)
  4761  	return &DeleteHyperparameterTuningJobOperation{
  4762  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4763  		pollPath: override,
  4764  	}
  4765  }
  4766  
  4767  // DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name.
  4768  // The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process.
  4769  func (c *jobGRPCClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation {
  4770  	return &DeleteModelDeploymentMonitoringJobOperation{
  4771  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4772  	}
  4773  }
  4774  
  4775  // DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name.
  4776  // The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process.
  4777  func (c *jobRESTClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation {
  4778  	override := fmt.Sprintf("/ui/%s", name)
  4779  	return &DeleteModelDeploymentMonitoringJobOperation{
  4780  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4781  		pollPath: override,
  4782  	}
  4783  }
  4784  
  4785  // DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name.
  4786  // The name must be that of a previously created DeleteNasJobOperation, possibly from a different process.
  4787  func (c *jobGRPCClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation {
  4788  	return &DeleteNasJobOperation{
  4789  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4790  	}
  4791  }
  4792  
  4793  // DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name.
  4794  // The name must be that of a previously created DeleteNasJobOperation, possibly from a different process.
  4795  func (c *jobRESTClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation {
  4796  	override := fmt.Sprintf("/ui/%s", name)
  4797  	return &DeleteNasJobOperation{
  4798  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4799  		pollPath: override,
  4800  	}
  4801  }
  4802  
  4803  // UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name.
  4804  // The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process.
  4805  func (c *jobGRPCClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation {
  4806  	return &UpdateModelDeploymentMonitoringJobOperation{
  4807  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4808  	}
  4809  }
  4810  
  4811  // UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name.
  4812  // The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process.
  4813  func (c *jobRESTClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation {
  4814  	override := fmt.Sprintf("/ui/%s", name)
  4815  	return &UpdateModelDeploymentMonitoringJobOperation{
  4816  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4817  		pollPath: override,
  4818  	}
  4819  }