-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
job_client.go
executable file
·5067 lines (4436 loc) · 185 KB
/
job_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package aiplatform
import (
"bytes"
"context"
"fmt"
"io"
"math"
"net/http"
"net/url"
"time"
aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
iampb "cloud.google.com/go/iam/apiv1/iampb"
"cloud.google.com/go/longrunning"
lroauto "cloud.google.com/go/longrunning/autogen"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/googleapi"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
gtransport "google.golang.org/api/transport/grpc"
httptransport "google.golang.org/api/transport/http"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newJobClientHook clientHook
// JobCallOptions contains the retry settings for each method of JobClient.
type JobCallOptions struct {
CreateCustomJob []gax.CallOption
GetCustomJob []gax.CallOption
ListCustomJobs []gax.CallOption
DeleteCustomJob []gax.CallOption
CancelCustomJob []gax.CallOption
CreateDataLabelingJob []gax.CallOption
GetDataLabelingJob []gax.CallOption
ListDataLabelingJobs []gax.CallOption
DeleteDataLabelingJob []gax.CallOption
CancelDataLabelingJob []gax.CallOption
CreateHyperparameterTuningJob []gax.CallOption
GetHyperparameterTuningJob []gax.CallOption
ListHyperparameterTuningJobs []gax.CallOption
DeleteHyperparameterTuningJob []gax.CallOption
CancelHyperparameterTuningJob []gax.CallOption
CreateNasJob []gax.CallOption
GetNasJob []gax.CallOption
ListNasJobs []gax.CallOption
DeleteNasJob []gax.CallOption
CancelNasJob []gax.CallOption
GetNasTrialDetail []gax.CallOption
ListNasTrialDetails []gax.CallOption
CreateBatchPredictionJob []gax.CallOption
GetBatchPredictionJob []gax.CallOption
ListBatchPredictionJobs []gax.CallOption
DeleteBatchPredictionJob []gax.CallOption
CancelBatchPredictionJob []gax.CallOption
CreateModelDeploymentMonitoringJob []gax.CallOption
SearchModelDeploymentMonitoringStatsAnomalies []gax.CallOption
GetModelDeploymentMonitoringJob []gax.CallOption
ListModelDeploymentMonitoringJobs []gax.CallOption
UpdateModelDeploymentMonitoringJob []gax.CallOption
DeleteModelDeploymentMonitoringJob []gax.CallOption
PauseModelDeploymentMonitoringJob []gax.CallOption
ResumeModelDeploymentMonitoringJob []gax.CallOption
GetLocation []gax.CallOption
ListLocations []gax.CallOption
GetIamPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
CancelOperation []gax.CallOption
DeleteOperation []gax.CallOption
GetOperation []gax.CallOption
ListOperations []gax.CallOption
WaitOperation []gax.CallOption
}
func defaultJobGRPCClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
}
}
func defaultJobCallOptions() *JobCallOptions {
return &JobCallOptions{
CreateCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListCustomJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListDataLabelingJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListHyperparameterTuningJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateNasJob: []gax.CallOption{},
GetNasJob: []gax.CallOption{},
ListNasJobs: []gax.CallOption{},
DeleteNasJob: []gax.CallOption{},
CancelNasJob: []gax.CallOption{},
GetNasTrialDetail: []gax.CallOption{},
ListNasTrialDetails: []gax.CallOption{},
CreateBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListBatchPredictionJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
SearchModelDeploymentMonitoringStatsAnomalies: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListModelDeploymentMonitoringJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
UpdateModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
PauseModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ResumeModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetLocation: []gax.CallOption{},
ListLocations: []gax.CallOption{},
GetIamPolicy: []gax.CallOption{},
SetIamPolicy: []gax.CallOption{},
TestIamPermissions: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
DeleteOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
ListOperations: []gax.CallOption{},
WaitOperation: []gax.CallOption{},
}
}
func defaultJobRESTCallOptions() *JobCallOptions {
return &JobCallOptions{
CreateCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListCustomJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelCustomJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListDataLabelingJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelDataLabelingJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListHyperparameterTuningJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelHyperparameterTuningJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateNasJob: []gax.CallOption{},
GetNasJob: []gax.CallOption{},
ListNasJobs: []gax.CallOption{},
DeleteNasJob: []gax.CallOption{},
CancelNasJob: []gax.CallOption{},
GetNasTrialDetail: []gax.CallOption{},
ListNasTrialDetails: []gax.CallOption{},
CreateBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListBatchPredictionJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CancelBatchPredictionJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
CreateModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
SearchModelDeploymentMonitoringStatsAnomalies: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ListModelDeploymentMonitoringJobs: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
UpdateModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
DeleteModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
PauseModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
ResumeModelDeploymentMonitoringJob: []gax.CallOption{
gax.WithTimeout(5000 * time.Millisecond),
},
GetLocation: []gax.CallOption{},
ListLocations: []gax.CallOption{},
GetIamPolicy: []gax.CallOption{},
SetIamPolicy: []gax.CallOption{},
TestIamPermissions: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
DeleteOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
ListOperations: []gax.CallOption{},
WaitOperation: []gax.CallOption{},
}
}
// internalJobClient is an interface that defines the methods available from Vertex AI API.
type internalJobClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
CreateCustomJob(context.Context, *aiplatformpb.CreateCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error)
GetCustomJob(context.Context, *aiplatformpb.GetCustomJobRequest, ...gax.CallOption) (*aiplatformpb.CustomJob, error)
ListCustomJobs(context.Context, *aiplatformpb.ListCustomJobsRequest, ...gax.CallOption) *CustomJobIterator
DeleteCustomJob(context.Context, *aiplatformpb.DeleteCustomJobRequest, ...gax.CallOption) (*DeleteCustomJobOperation, error)
DeleteCustomJobOperation(name string) *DeleteCustomJobOperation
CancelCustomJob(context.Context, *aiplatformpb.CancelCustomJobRequest, ...gax.CallOption) error
CreateDataLabelingJob(context.Context, *aiplatformpb.CreateDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error)
GetDataLabelingJob(context.Context, *aiplatformpb.GetDataLabelingJobRequest, ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error)
ListDataLabelingJobs(context.Context, *aiplatformpb.ListDataLabelingJobsRequest, ...gax.CallOption) *DataLabelingJobIterator
DeleteDataLabelingJob(context.Context, *aiplatformpb.DeleteDataLabelingJobRequest, ...gax.CallOption) (*DeleteDataLabelingJobOperation, error)
DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation
CancelDataLabelingJob(context.Context, *aiplatformpb.CancelDataLabelingJobRequest, ...gax.CallOption) error
CreateHyperparameterTuningJob(context.Context, *aiplatformpb.CreateHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error)
GetHyperparameterTuningJob(context.Context, *aiplatformpb.GetHyperparameterTuningJobRequest, ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error)
ListHyperparameterTuningJobs(context.Context, *aiplatformpb.ListHyperparameterTuningJobsRequest, ...gax.CallOption) *HyperparameterTuningJobIterator
DeleteHyperparameterTuningJob(context.Context, *aiplatformpb.DeleteHyperparameterTuningJobRequest, ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error)
DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation
CancelHyperparameterTuningJob(context.Context, *aiplatformpb.CancelHyperparameterTuningJobRequest, ...gax.CallOption) error
CreateNasJob(context.Context, *aiplatformpb.CreateNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error)
GetNasJob(context.Context, *aiplatformpb.GetNasJobRequest, ...gax.CallOption) (*aiplatformpb.NasJob, error)
ListNasJobs(context.Context, *aiplatformpb.ListNasJobsRequest, ...gax.CallOption) *NasJobIterator
DeleteNasJob(context.Context, *aiplatformpb.DeleteNasJobRequest, ...gax.CallOption) (*DeleteNasJobOperation, error)
DeleteNasJobOperation(name string) *DeleteNasJobOperation
CancelNasJob(context.Context, *aiplatformpb.CancelNasJobRequest, ...gax.CallOption) error
GetNasTrialDetail(context.Context, *aiplatformpb.GetNasTrialDetailRequest, ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error)
ListNasTrialDetails(context.Context, *aiplatformpb.ListNasTrialDetailsRequest, ...gax.CallOption) *NasTrialDetailIterator
CreateBatchPredictionJob(context.Context, *aiplatformpb.CreateBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error)
GetBatchPredictionJob(context.Context, *aiplatformpb.GetBatchPredictionJobRequest, ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error)
ListBatchPredictionJobs(context.Context, *aiplatformpb.ListBatchPredictionJobsRequest, ...gax.CallOption) *BatchPredictionJobIterator
DeleteBatchPredictionJob(context.Context, *aiplatformpb.DeleteBatchPredictionJobRequest, ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error)
DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation
CancelBatchPredictionJob(context.Context, *aiplatformpb.CancelBatchPredictionJobRequest, ...gax.CallOption) error
CreateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error)
SearchModelDeploymentMonitoringStatsAnomalies(context.Context, *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator
GetModelDeploymentMonitoringJob(context.Context, *aiplatformpb.GetModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error)
ListModelDeploymentMonitoringJobs(context.Context, *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, ...gax.CallOption) *ModelDeploymentMonitoringJobIterator
UpdateModelDeploymentMonitoringJob(context.Context, *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error)
UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation
DeleteModelDeploymentMonitoringJob(context.Context, *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error)
DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation
PauseModelDeploymentMonitoringJob(context.Context, *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, ...gax.CallOption) error
ResumeModelDeploymentMonitoringJob(context.Context, *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, ...gax.CallOption) error
GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
}
// JobClient is a client for interacting with Vertex AI API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// A service for creating and managing Vertex AI’s jobs.
type JobClient struct {
// The internal transport-dependent client.
internalClient internalJobClient
// The call options for this service.
CallOptions *JobCallOptions
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient *lroauto.OperationsClient
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *JobClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *JobClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *JobClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// CreateCustomJob creates a CustomJob. A created CustomJob right away
// will be attempted to be run.
func (c *JobClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
return c.internalClient.CreateCustomJob(ctx, req, opts...)
}
// GetCustomJob gets a CustomJob.
func (c *JobClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
return c.internalClient.GetCustomJob(ctx, req, opts...)
}
// ListCustomJobs lists CustomJobs in a Location.
func (c *JobClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator {
return c.internalClient.ListCustomJobs(ctx, req, opts...)
}
// DeleteCustomJob deletes a CustomJob.
func (c *JobClient) DeleteCustomJob(ctx context.Context, req *aiplatformpb.DeleteCustomJobRequest, opts ...gax.CallOption) (*DeleteCustomJobOperation, error) {
return c.internalClient.DeleteCustomJob(ctx, req, opts...)
}
// DeleteCustomJobOperation returns a new DeleteCustomJobOperation from a given name.
// The name must be that of a previously created DeleteCustomJobOperation, possibly from a different process.
func (c *JobClient) DeleteCustomJobOperation(name string) *DeleteCustomJobOperation {
return c.internalClient.DeleteCustomJobOperation(name)
}
// CancelCustomJob cancels a CustomJob.
// Starts asynchronous cancellation on the CustomJob. The server
// makes a best effort to cancel the job, but success is not
// guaranteed. Clients can use
// JobService.GetCustomJob
// or other methods to check whether the cancellation succeeded or whether the
// job completed despite cancellation. On successful cancellation,
// the CustomJob is not deleted; instead it becomes a job with
// a CustomJob.error value
// with a google.rpc.Status.code of 1, corresponding
// to Code.CANCELLED, and
// CustomJob.state is set
// to CANCELLED.
func (c *JobClient) CancelCustomJob(ctx context.Context, req *aiplatformpb.CancelCustomJobRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelCustomJob(ctx, req, opts...)
}
// CreateDataLabelingJob creates a DataLabelingJob.
func (c *JobClient) CreateDataLabelingJob(ctx context.Context, req *aiplatformpb.CreateDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
return c.internalClient.CreateDataLabelingJob(ctx, req, opts...)
}
// GetDataLabelingJob gets a DataLabelingJob.
func (c *JobClient) GetDataLabelingJob(ctx context.Context, req *aiplatformpb.GetDataLabelingJobRequest, opts ...gax.CallOption) (*aiplatformpb.DataLabelingJob, error) {
return c.internalClient.GetDataLabelingJob(ctx, req, opts...)
}
// ListDataLabelingJobs lists DataLabelingJobs in a Location.
func (c *JobClient) ListDataLabelingJobs(ctx context.Context, req *aiplatformpb.ListDataLabelingJobsRequest, opts ...gax.CallOption) *DataLabelingJobIterator {
return c.internalClient.ListDataLabelingJobs(ctx, req, opts...)
}
// DeleteDataLabelingJob deletes a DataLabelingJob.
func (c *JobClient) DeleteDataLabelingJob(ctx context.Context, req *aiplatformpb.DeleteDataLabelingJobRequest, opts ...gax.CallOption) (*DeleteDataLabelingJobOperation, error) {
return c.internalClient.DeleteDataLabelingJob(ctx, req, opts...)
}
// DeleteDataLabelingJobOperation returns a new DeleteDataLabelingJobOperation from a given name.
// The name must be that of a previously created DeleteDataLabelingJobOperation, possibly from a different process.
func (c *JobClient) DeleteDataLabelingJobOperation(name string) *DeleteDataLabelingJobOperation {
return c.internalClient.DeleteDataLabelingJobOperation(name)
}
// CancelDataLabelingJob cancels a DataLabelingJob. Success of cancellation is not guaranteed.
func (c *JobClient) CancelDataLabelingJob(ctx context.Context, req *aiplatformpb.CancelDataLabelingJobRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelDataLabelingJob(ctx, req, opts...)
}
// CreateHyperparameterTuningJob creates a HyperparameterTuningJob
func (c *JobClient) CreateHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CreateHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
return c.internalClient.CreateHyperparameterTuningJob(ctx, req, opts...)
}
// GetHyperparameterTuningJob gets a HyperparameterTuningJob
func (c *JobClient) GetHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.GetHyperparameterTuningJobRequest, opts ...gax.CallOption) (*aiplatformpb.HyperparameterTuningJob, error) {
return c.internalClient.GetHyperparameterTuningJob(ctx, req, opts...)
}
// ListHyperparameterTuningJobs lists HyperparameterTuningJobs in a Location.
func (c *JobClient) ListHyperparameterTuningJobs(ctx context.Context, req *aiplatformpb.ListHyperparameterTuningJobsRequest, opts ...gax.CallOption) *HyperparameterTuningJobIterator {
return c.internalClient.ListHyperparameterTuningJobs(ctx, req, opts...)
}
// DeleteHyperparameterTuningJob deletes a HyperparameterTuningJob.
func (c *JobClient) DeleteHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.DeleteHyperparameterTuningJobRequest, opts ...gax.CallOption) (*DeleteHyperparameterTuningJobOperation, error) {
return c.internalClient.DeleteHyperparameterTuningJob(ctx, req, opts...)
}
// DeleteHyperparameterTuningJobOperation returns a new DeleteHyperparameterTuningJobOperation from a given name.
// The name must be that of a previously created DeleteHyperparameterTuningJobOperation, possibly from a different process.
func (c *JobClient) DeleteHyperparameterTuningJobOperation(name string) *DeleteHyperparameterTuningJobOperation {
return c.internalClient.DeleteHyperparameterTuningJobOperation(name)
}
// CancelHyperparameterTuningJob cancels a HyperparameterTuningJob.
// Starts asynchronous cancellation on the HyperparameterTuningJob. The server
// makes a best effort to cancel the job, but success is not
// guaranteed. Clients can use
// JobService.GetHyperparameterTuningJob
// or other methods to check whether the cancellation succeeded or whether the
// job completed despite cancellation. On successful cancellation,
// the HyperparameterTuningJob is not deleted; instead it becomes a job with
// a
// HyperparameterTuningJob.error
// value with a google.rpc.Status.code of 1,
// corresponding to Code.CANCELLED, and
// HyperparameterTuningJob.state
// is set to CANCELLED.
func (c *JobClient) CancelHyperparameterTuningJob(ctx context.Context, req *aiplatformpb.CancelHyperparameterTuningJobRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelHyperparameterTuningJob(ctx, req, opts...)
}
// CreateNasJob creates a NasJob
func (c *JobClient) CreateNasJob(ctx context.Context, req *aiplatformpb.CreateNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
return c.internalClient.CreateNasJob(ctx, req, opts...)
}
// GetNasJob gets a NasJob
func (c *JobClient) GetNasJob(ctx context.Context, req *aiplatformpb.GetNasJobRequest, opts ...gax.CallOption) (*aiplatformpb.NasJob, error) {
return c.internalClient.GetNasJob(ctx, req, opts...)
}
// ListNasJobs lists NasJobs in a Location.
func (c *JobClient) ListNasJobs(ctx context.Context, req *aiplatformpb.ListNasJobsRequest, opts ...gax.CallOption) *NasJobIterator {
return c.internalClient.ListNasJobs(ctx, req, opts...)
}
// DeleteNasJob deletes a NasJob.
func (c *JobClient) DeleteNasJob(ctx context.Context, req *aiplatformpb.DeleteNasJobRequest, opts ...gax.CallOption) (*DeleteNasJobOperation, error) {
return c.internalClient.DeleteNasJob(ctx, req, opts...)
}
// DeleteNasJobOperation returns a new DeleteNasJobOperation from a given name.
// The name must be that of a previously created DeleteNasJobOperation, possibly from a different process.
func (c *JobClient) DeleteNasJobOperation(name string) *DeleteNasJobOperation {
return c.internalClient.DeleteNasJobOperation(name)
}
// CancelNasJob cancels a NasJob.
// Starts asynchronous cancellation on the NasJob. The server
// makes a best effort to cancel the job, but success is not
// guaranteed. Clients can use
// JobService.GetNasJob
// or other methods to check whether the cancellation succeeded or whether the
// job completed despite cancellation. On successful cancellation,
// the NasJob is not deleted; instead it becomes a job with
// a NasJob.error value with a
// google.rpc.Status.code of 1, corresponding to
// Code.CANCELLED, and
// NasJob.state is set to
// CANCELLED.
func (c *JobClient) CancelNasJob(ctx context.Context, req *aiplatformpb.CancelNasJobRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelNasJob(ctx, req, opts...)
}
// GetNasTrialDetail gets a NasTrialDetail.
func (c *JobClient) GetNasTrialDetail(ctx context.Context, req *aiplatformpb.GetNasTrialDetailRequest, opts ...gax.CallOption) (*aiplatformpb.NasTrialDetail, error) {
return c.internalClient.GetNasTrialDetail(ctx, req, opts...)
}
// ListNasTrialDetails list top NasTrialDetails of a NasJob.
func (c *JobClient) ListNasTrialDetails(ctx context.Context, req *aiplatformpb.ListNasTrialDetailsRequest, opts ...gax.CallOption) *NasTrialDetailIterator {
return c.internalClient.ListNasTrialDetails(ctx, req, opts...)
}
// CreateBatchPredictionJob creates a BatchPredictionJob. A BatchPredictionJob once created will
// right away be attempted to start.
func (c *JobClient) CreateBatchPredictionJob(ctx context.Context, req *aiplatformpb.CreateBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
return c.internalClient.CreateBatchPredictionJob(ctx, req, opts...)
}
// GetBatchPredictionJob gets a BatchPredictionJob
func (c *JobClient) GetBatchPredictionJob(ctx context.Context, req *aiplatformpb.GetBatchPredictionJobRequest, opts ...gax.CallOption) (*aiplatformpb.BatchPredictionJob, error) {
return c.internalClient.GetBatchPredictionJob(ctx, req, opts...)
}
// ListBatchPredictionJobs lists BatchPredictionJobs in a Location.
func (c *JobClient) ListBatchPredictionJobs(ctx context.Context, req *aiplatformpb.ListBatchPredictionJobsRequest, opts ...gax.CallOption) *BatchPredictionJobIterator {
return c.internalClient.ListBatchPredictionJobs(ctx, req, opts...)
}
// DeleteBatchPredictionJob deletes a BatchPredictionJob. Can only be called on jobs that already
// finished.
func (c *JobClient) DeleteBatchPredictionJob(ctx context.Context, req *aiplatformpb.DeleteBatchPredictionJobRequest, opts ...gax.CallOption) (*DeleteBatchPredictionJobOperation, error) {
return c.internalClient.DeleteBatchPredictionJob(ctx, req, opts...)
}
// DeleteBatchPredictionJobOperation returns a new DeleteBatchPredictionJobOperation from a given name.
// The name must be that of a previously created DeleteBatchPredictionJobOperation, possibly from a different process.
func (c *JobClient) DeleteBatchPredictionJobOperation(name string) *DeleteBatchPredictionJobOperation {
return c.internalClient.DeleteBatchPredictionJobOperation(name)
}
// CancelBatchPredictionJob cancels a BatchPredictionJob.
//
// Starts asynchronous cancellation on the BatchPredictionJob. The server
// makes the best effort to cancel the job, but success is not
// guaranteed. Clients can use
// JobService.GetBatchPredictionJob
// or other methods to check whether the cancellation succeeded or whether the
// job completed despite cancellation. On a successful cancellation,
// the BatchPredictionJob is not deleted;instead its
// BatchPredictionJob.state
// is set to CANCELLED. Any files already outputted by the job are not
// deleted.
func (c *JobClient) CancelBatchPredictionJob(ctx context.Context, req *aiplatformpb.CancelBatchPredictionJobRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelBatchPredictionJob(ctx, req, opts...)
}
// CreateModelDeploymentMonitoringJob creates a ModelDeploymentMonitoringJob. It will run periodically on a
// configured interval.
func (c *JobClient) CreateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.CreateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
return c.internalClient.CreateModelDeploymentMonitoringJob(ctx, req, opts...)
}
// SearchModelDeploymentMonitoringStatsAnomalies searches Model Monitoring Statistics generated within a given time window.
func (c *JobClient) SearchModelDeploymentMonitoringStatsAnomalies(ctx context.Context, req *aiplatformpb.SearchModelDeploymentMonitoringStatsAnomaliesRequest, opts ...gax.CallOption) *ModelMonitoringStatsAnomaliesIterator {
return c.internalClient.SearchModelDeploymentMonitoringStatsAnomalies(ctx, req, opts...)
}
// GetModelDeploymentMonitoringJob gets a ModelDeploymentMonitoringJob.
func (c *JobClient) GetModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.GetModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*aiplatformpb.ModelDeploymentMonitoringJob, error) {
return c.internalClient.GetModelDeploymentMonitoringJob(ctx, req, opts...)
}
// ListModelDeploymentMonitoringJobs lists ModelDeploymentMonitoringJobs in a Location.
func (c *JobClient) ListModelDeploymentMonitoringJobs(ctx context.Context, req *aiplatformpb.ListModelDeploymentMonitoringJobsRequest, opts ...gax.CallOption) *ModelDeploymentMonitoringJobIterator {
return c.internalClient.ListModelDeploymentMonitoringJobs(ctx, req, opts...)
}
// UpdateModelDeploymentMonitoringJob updates a ModelDeploymentMonitoringJob.
func (c *JobClient) UpdateModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.UpdateModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*UpdateModelDeploymentMonitoringJobOperation, error) {
return c.internalClient.UpdateModelDeploymentMonitoringJob(ctx, req, opts...)
}
// UpdateModelDeploymentMonitoringJobOperation returns a new UpdateModelDeploymentMonitoringJobOperation from a given name.
// The name must be that of a previously created UpdateModelDeploymentMonitoringJobOperation, possibly from a different process.
func (c *JobClient) UpdateModelDeploymentMonitoringJobOperation(name string) *UpdateModelDeploymentMonitoringJobOperation {
return c.internalClient.UpdateModelDeploymentMonitoringJobOperation(name)
}
// DeleteModelDeploymentMonitoringJob deletes a ModelDeploymentMonitoringJob.
func (c *JobClient) DeleteModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.DeleteModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) (*DeleteModelDeploymentMonitoringJobOperation, error) {
return c.internalClient.DeleteModelDeploymentMonitoringJob(ctx, req, opts...)
}
// DeleteModelDeploymentMonitoringJobOperation returns a new DeleteModelDeploymentMonitoringJobOperation from a given name.
// The name must be that of a previously created DeleteModelDeploymentMonitoringJobOperation, possibly from a different process.
func (c *JobClient) DeleteModelDeploymentMonitoringJobOperation(name string) *DeleteModelDeploymentMonitoringJobOperation {
return c.internalClient.DeleteModelDeploymentMonitoringJobOperation(name)
}
// PauseModelDeploymentMonitoringJob pauses a ModelDeploymentMonitoringJob. If the job is running, the server
// makes a best effort to cancel the job. Will mark
// ModelDeploymentMonitoringJob.state
// to ‘PAUSED’.
func (c *JobClient) PauseModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.PauseModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
return c.internalClient.PauseModelDeploymentMonitoringJob(ctx, req, opts...)
}
// ResumeModelDeploymentMonitoringJob resumes a paused ModelDeploymentMonitoringJob. It will start to run from
// next scheduled time. A deleted ModelDeploymentMonitoringJob can’t be
// resumed.
func (c *JobClient) ResumeModelDeploymentMonitoringJob(ctx context.Context, req *aiplatformpb.ResumeModelDeploymentMonitoringJobRequest, opts ...gax.CallOption) error {
return c.internalClient.ResumeModelDeploymentMonitoringJob(ctx, req, opts...)
}
// GetLocation gets information about a location.
func (c *JobClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
return c.internalClient.GetLocation(ctx, req, opts...)
}
// ListLocations lists information about the supported locations for this service.
func (c *JobClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
return c.internalClient.ListLocations(ctx, req, opts...)
}
// GetIamPolicy gets the access control policy for a resource. Returns an empty policy
// if the resource exists and does not have a policy set.
func (c *JobClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.GetIamPolicy(ctx, req, opts...)
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces
// any existing policy.
//
// Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
// errors.
func (c *JobClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.SetIamPolicy(ctx, req, opts...)
}
// TestIamPermissions returns permissions that a caller has on the specified resource. If the
// resource does not exist, this will return an empty set of
// permissions, not a NOT_FOUND error.
//
// Note: This operation is designed to be used for building
// permission-aware UIs and command-line tools, not for authorization
// checking. This operation may “fail open” without warning.
func (c *JobClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// CancelOperation is a utility method from google.longrunning.Operations.
func (c *JobClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelOperation(ctx, req, opts...)
}
// DeleteOperation is a utility method from google.longrunning.Operations.
func (c *JobClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
return c.internalClient.DeleteOperation(ctx, req, opts...)
}
// GetOperation is a utility method from google.longrunning.Operations.
func (c *JobClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
return c.internalClient.GetOperation(ctx, req, opts...)
}
// ListOperations is a utility method from google.longrunning.Operations.
func (c *JobClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
return c.internalClient.ListOperations(ctx, req, opts...)
}
// WaitOperation is a utility method from google.longrunning.Operations.
func (c *JobClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
return c.internalClient.WaitOperation(ctx, req, opts...)
}
// jobGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
//
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type jobGRPCClient struct {
// Connection pool of gRPC connections to the service.
connPool gtransport.ConnPool
// Points back to the CallOptions field of the containing JobClient
CallOptions **JobCallOptions
// The gRPC API client.
jobClient aiplatformpb.JobServiceClient
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient **lroauto.OperationsClient
operationsClient longrunningpb.OperationsClient
iamPolicyClient iampb.IAMPolicyClient
locationsClient locationpb.LocationsClient
// The x-goog-* metadata to be sent with each request.
xGoogHeaders []string
}
// NewJobClient creates a new job service client based on gRPC.
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// A service for creating and managing Vertex AI’s jobs.
func NewJobClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) {
clientOpts := defaultJobGRPCClientOptions()
if newJobClientHook != nil {
hookOpts, err := newJobClientHook(ctx, clientHookParams{})
if err != nil {
return nil, err
}
clientOpts = append(clientOpts, hookOpts...)
}
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
if err != nil {
return nil, err
}
client := JobClient{CallOptions: defaultJobCallOptions()}
c := &jobGRPCClient{
connPool: connPool,
jobClient: aiplatformpb.NewJobServiceClient(connPool),
CallOptions: &client.CallOptions,
operationsClient: longrunningpb.NewOperationsClient(connPool),
iamPolicyClient: iampb.NewIAMPolicyClient(connPool),
locationsClient: locationpb.NewLocationsClient(connPool),
}
c.setGoogleClientInfo()
client.internalClient = c
client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
if err != nil {
// This error "should not happen", since we are just reusing old connection pool
// and never actually need to dial.
// If this does happen, we could leak connp. However, we cannot close conn:
// If the user invoked the constructor with option.WithGRPCConn,
// we would close a connection that's still in use.
// TODO: investigate error conditions.
return nil, err
}
c.LROClient = &client.LROClient
return &client, nil
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *jobGRPCClient) Connection() *grpc.ClientConn {
return c.connPool.Conn()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *jobGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *jobGRPCClient) Close() error {
return c.connPool.Close()
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type jobRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient **lroauto.OperationsClient
// The x-goog-* headers to be sent with each request.
xGoogHeaders []string
// Points back to the CallOptions field of the containing JobClient
CallOptions **JobCallOptions
}
// NewJobRESTClient creates a new job service rest client.
//
// A service for creating and managing Vertex AI’s jobs.
func NewJobRESTClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) {
clientOpts := append(defaultJobRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultJobRESTCallOptions()
c := &jobRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
}
c.setGoogleClientInfo()
lroOpts := []option.ClientOption{
option.WithHTTPClient(httpClient),
option.WithEndpoint(endpoint),
}
opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
if err != nil {
return nil, err
}
c.LROClient = &opClient
return &JobClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultJobRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *jobRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *jobRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *jobRESTClient) Connection() *grpc.ClientConn {
return nil
}
func (c *jobGRPCClient) CreateCustomJob(ctx context.Context, req *aiplatformpb.CreateCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).CreateCustomJob[0:len((*c.CallOptions).CreateCustomJob):len((*c.CallOptions).CreateCustomJob)], opts...)
var resp *aiplatformpb.CustomJob
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.jobClient.CreateCustomJob(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *jobGRPCClient) GetCustomJob(ctx context.Context, req *aiplatformpb.GetCustomJobRequest, opts ...gax.CallOption) (*aiplatformpb.CustomJob, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetCustomJob[0:len((*c.CallOptions).GetCustomJob):len((*c.CallOptions).GetCustomJob)], opts...)
var resp *aiplatformpb.CustomJob
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.jobClient.GetCustomJob(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *jobGRPCClient) ListCustomJobs(ctx context.Context, req *aiplatformpb.ListCustomJobsRequest, opts ...gax.CallOption) *CustomJobIterator {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).ListCustomJobs[0:len((*c.CallOptions).ListCustomJobs):len((*c.CallOptions).ListCustomJobs)], opts...)
it := &CustomJobIterator{}
req = proto.Clone(req).(*aiplatformpb.ListCustomJobsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.CustomJob, string, error) {
resp := &aiplatformpb.ListCustomJobsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.jobClient.ListCustomJobs(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err