| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package dataflow |
| 18 |
|
| 19 |
import ( |
| 20 |
"bytes" |
| 21 |
"context" |
| 22 |
"fmt" |
| 23 |
"log/slog" |
| 24 |
"math" |
| 25 |
"net/http" |
| 26 |
"net/url" |
| 27 |
"time" |
| 28 |
|
| 29 |
dataflowpb "cloud.google.com/go/dataflow/apiv1beta3/dataflowpb" |
| 30 |
gax "github.com/googleapis/gax-go/v2" |
| 31 |
"google.golang.org/api/iterator" |
| 32 |
"google.golang.org/api/option" |
| 33 |
"google.golang.org/api/option/internaloption" |
| 34 |
gtransport "google.golang.org/api/transport/grpc" |
| 35 |
httptransport "google.golang.org/api/transport/http" |
| 36 |
"google.golang.org/grpc" |
| 37 |
"google.golang.org/protobuf/encoding/protojson" |
| 38 |
"google.golang.org/protobuf/proto" |
| 39 |
) |
| 40 |
|
| 41 |
var newJobsV1Beta3ClientHook clientHook |
| 42 |
|
| 43 |
|
| 44 |
type JobsV1Beta3CallOptions struct { |
| 45 |
CreateJob []gax.CallOption |
| 46 |
GetJob []gax.CallOption |
| 47 |
UpdateJob []gax.CallOption |
| 48 |
ListJobs []gax.CallOption |
| 49 |
AggregatedListJobs []gax.CallOption |
| 50 |
CheckActiveJobs []gax.CallOption |
| 51 |
SnapshotJob []gax.CallOption |
| 52 |
} |
| 53 |
|
| 54 |
func defaultJobsV1Beta3GRPCClientOptions() []option.ClientOption { |
| 55 |
return []option.ClientOption{ |
| 56 |
internaloption.WithDefaultEndpoint("dataflow.googleapis.com:443"), |
| 57 |
internaloption.WithDefaultEndpointTemplate("dataflow.UNIVERSE_DOMAIN:443"), |
| 58 |
internaloption.WithDefaultMTLSEndpoint("dataflow.mtls.googleapis.com:443"), |
| 59 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 60 |
internaloption.WithDefaultAudience("https://dataflow.googleapis.com/"), |
| 61 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 62 |
internaloption.EnableJwtWithScope(), |
| 63 |
internaloption.EnableNewAuthLibrary(), |
| 64 |
option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| 65 |
grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
func defaultJobsV1Beta3CallOptions() *JobsV1Beta3CallOptions { |
| 70 |
return &JobsV1Beta3CallOptions{ |
| 71 |
CreateJob: []gax.CallOption{ |
| 72 |
gax.WithTimeout(60000 * time.Millisecond), |
| 73 |
}, |
| 74 |
GetJob: []gax.CallOption{ |
| 75 |
gax.WithTimeout(60000 * time.Millisecond), |
| 76 |
}, |
| 77 |
UpdateJob: []gax.CallOption{ |
| 78 |
gax.WithTimeout(60000 * time.Millisecond), |
| 79 |
}, |
| 80 |
ListJobs: []gax.CallOption{ |
| 81 |
gax.WithTimeout(60000 * time.Millisecond), |
| 82 |
}, |
| 83 |
AggregatedListJobs: []gax.CallOption{ |
| 84 |
gax.WithTimeout(60000 * time.Millisecond), |
| 85 |
}, |
| 86 |
CheckActiveJobs: []gax.CallOption{ |
| 87 |
gax.WithTimeout(60000 * time.Millisecond), |
| 88 |
}, |
| 89 |
SnapshotJob: []gax.CallOption{ |
| 90 |
gax.WithTimeout(60000 * time.Millisecond), |
| 91 |
}, |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
func defaultJobsV1Beta3RESTCallOptions() *JobsV1Beta3CallOptions { |
| 96 |
return &JobsV1Beta3CallOptions{ |
| 97 |
CreateJob: []gax.CallOption{ |
| 98 |
gax.WithTimeout(60000 * time.Millisecond), |
| 99 |
}, |
| 100 |
GetJob: []gax.CallOption{ |
| 101 |
gax.WithTimeout(60000 * time.Millisecond), |
| 102 |
}, |
| 103 |
UpdateJob: []gax.CallOption{ |
| 104 |
gax.WithTimeout(60000 * time.Millisecond), |
| 105 |
}, |
| 106 |
ListJobs: []gax.CallOption{ |
| 107 |
gax.WithTimeout(60000 * time.Millisecond), |
| 108 |
}, |
| 109 |
AggregatedListJobs: []gax.CallOption{ |
| 110 |
gax.WithTimeout(60000 * time.Millisecond), |
| 111 |
}, |
| 112 |
CheckActiveJobs: []gax.CallOption{ |
| 113 |
gax.WithTimeout(60000 * time.Millisecond), |
| 114 |
}, |
| 115 |
SnapshotJob: []gax.CallOption{ |
| 116 |
gax.WithTimeout(60000 * time.Millisecond), |
| 117 |
}, |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
type internalJobsV1Beta3Client interface { |
| 123 |
Close() error |
| 124 |
setGoogleClientInfo(...string) |
| 125 |
Connection() *grpc.ClientConn |
| 126 |
CreateJob(context.Context, *dataflowpb.CreateJobRequest, ...gax.CallOption) (*dataflowpb.Job, error) |
| 127 |
GetJob(context.Context, *dataflowpb.GetJobRequest, ...gax.CallOption) (*dataflowpb.Job, error) |
| 128 |
UpdateJob(context.Context, *dataflowpb.UpdateJobRequest, ...gax.CallOption) (*dataflowpb.Job, error) |
| 129 |
ListJobs(context.Context, *dataflowpb.ListJobsRequest, ...gax.CallOption) *JobIterator |
| 130 |
AggregatedListJobs(context.Context, *dataflowpb.ListJobsRequest, ...gax.CallOption) *JobIterator |
| 131 |
CheckActiveJobs(context.Context, *dataflowpb.CheckActiveJobsRequest, ...gax.CallOption) (*dataflowpb.CheckActiveJobsResponse, error) |
| 132 |
SnapshotJob(context.Context, *dataflowpb.SnapshotJobRequest, ...gax.CallOption) (*dataflowpb.Snapshot, error) |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
type JobsV1Beta3Client struct { |
| 141 |
|
| 142 |
internalClient internalJobsV1Beta3Client |
| 143 |
|
| 144 |
|
| 145 |
CallOptions *JobsV1Beta3CallOptions |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
func (c *JobsV1Beta3Client) Close() error { |
| 153 |
return c.internalClient.Close() |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
func (c *JobsV1Beta3Client) setGoogleClientInfo(keyval ...string) { |
| 160 |
c.internalClient.setGoogleClientInfo(keyval...) |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
func (c *JobsV1Beta3Client) Connection() *grpc.ClientConn { |
| 168 |
return c.internalClient.Connection() |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
func (c *JobsV1Beta3Client) CreateJob(ctx context.Context, req *dataflowpb.CreateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 182 |
return c.internalClient.CreateJob(ctx, req, opts...) |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
func (c *JobsV1Beta3Client) GetJob(ctx context.Context, req *dataflowpb.GetJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 193 |
return c.internalClient.GetJob(ctx, req, opts...) |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
func (c *JobsV1Beta3Client) UpdateJob(ctx context.Context, req *dataflowpb.UpdateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 204 |
return c.internalClient.UpdateJob(ctx, req, opts...) |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
by |
| 218 |
|
| 219 |
func (c *JobsV1Beta3Client) ListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 220 |
return c.internalClient.ListJobs(ctx, req, opts...) |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
of |
| 226 |
|
| 227 |
func (c *JobsV1Beta3Client) AggregatedListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 228 |
return c.internalClient.AggregatedListJobs(ctx, req, opts...) |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
func (c *JobsV1Beta3Client) CheckActiveJobs(ctx context.Context, req *dataflowpb.CheckActiveJobsRequest, opts ...gax.CallOption) (*dataflowpb.CheckActiveJobsResponse, error) { |
| 233 |
return c.internalClient.CheckActiveJobs(ctx, req, opts...) |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
func (c *JobsV1Beta3Client) SnapshotJob(ctx context.Context, req *dataflowpb.SnapshotJobRequest, opts ...gax.CallOption) (*dataflowpb.Snapshot, error) { |
| 238 |
return c.internalClient.SnapshotJob(ctx, req, opts...) |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
type jobsV1Beta3GRPCClient struct { |
| 245 |
|
| 246 |
connPool gtransport.ConnPool |
| 247 |
|
| 248 |
|
| 249 |
CallOptions **JobsV1Beta3CallOptions |
| 250 |
|
| 251 |
|
| 252 |
jobsV1Beta3Client dataflowpb.JobsV1Beta3Client |
| 253 |
|
| 254 |
|
| 255 |
xGoogHeaders []string |
| 256 |
|
| 257 |
logger *slog.Logger |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
func NewJobsV1Beta3Client(ctx context.Context, opts ...option.ClientOption) (*JobsV1Beta3Client, error) { |
| 266 |
clientOpts := defaultJobsV1Beta3GRPCClientOptions() |
| 267 |
if newJobsV1Beta3ClientHook != nil { |
| 268 |
hookOpts, err := newJobsV1Beta3ClientHook(ctx, clientHookParams{}) |
| 269 |
if err != nil { |
| 270 |
return nil, err |
| 271 |
} |
| 272 |
clientOpts = append(clientOpts, hookOpts...) |
| 273 |
} |
| 274 |
|
| 275 |
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| 276 |
if err != nil { |
| 277 |
return nil, err |
| 278 |
} |
| 279 |
client := JobsV1Beta3Client{CallOptions: defaultJobsV1Beta3CallOptions()} |
| 280 |
|
| 281 |
c := &jobsV1Beta3GRPCClient{ |
| 282 |
connPool: connPool, |
| 283 |
jobsV1Beta3Client: dataflowpb.NewJobsV1Beta3Client(connPool), |
| 284 |
CallOptions: &client.CallOptions, |
| 285 |
logger: internaloption.GetLogger(opts), |
| 286 |
} |
| 287 |
c.setGoogleClientInfo() |
| 288 |
|
| 289 |
client.internalClient = c |
| 290 |
|
| 291 |
return &client, nil |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
func (c *jobsV1Beta3GRPCClient) Connection() *grpc.ClientConn { |
| 299 |
return c.connPool.Conn() |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
func (c *jobsV1Beta3GRPCClient) setGoogleClientInfo(keyval ...string) { |
| 306 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 307 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) |
| 308 |
c.xGoogHeaders = []string{ |
| 309 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
func (c *jobsV1Beta3GRPCClient) Close() error { |
| 316 |
return c.connPool.Close() |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
type jobsV1Beta3RESTClient struct { |
| 321 |
|
| 322 |
endpoint string |
| 323 |
|
| 324 |
|
| 325 |
httpClient *http.Client |
| 326 |
|
| 327 |
|
| 328 |
xGoogHeaders []string |
| 329 |
|
| 330 |
|
| 331 |
CallOptions **JobsV1Beta3CallOptions |
| 332 |
|
| 333 |
logger *slog.Logger |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
func NewJobsV1Beta3RESTClient(ctx context.Context, opts ...option.ClientOption) (*JobsV1Beta3Client, error) { |
| 341 |
clientOpts := append(defaultJobsV1Beta3RESTClientOptions(), opts...) |
| 342 |
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) |
| 343 |
if err != nil { |
| 344 |
return nil, err |
| 345 |
} |
| 346 |
|
| 347 |
callOpts := defaultJobsV1Beta3RESTCallOptions() |
| 348 |
c := &jobsV1Beta3RESTClient{ |
| 349 |
endpoint: endpoint, |
| 350 |
httpClient: httpClient, |
| 351 |
CallOptions: &callOpts, |
| 352 |
logger: internaloption.GetLogger(opts), |
| 353 |
} |
| 354 |
c.setGoogleClientInfo() |
| 355 |
|
| 356 |
return &JobsV1Beta3Client{internalClient: c, CallOptions: callOpts}, nil |
| 357 |
} |
| 358 |
|
| 359 |
func defaultJobsV1Beta3RESTClientOptions() []option.ClientOption { |
| 360 |
return []option.ClientOption{ |
| 361 |
internaloption.WithDefaultEndpoint("https://dataflow.googleapis.com"), |
| 362 |
internaloption.WithDefaultEndpointTemplate("https://dataflow.UNIVERSE_DOMAIN"), |
| 363 |
internaloption.WithDefaultMTLSEndpoint("https://dataflow.mtls.googleapis.com"), |
| 364 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 365 |
internaloption.WithDefaultAudience("https://dataflow.googleapis.com/"), |
| 366 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 367 |
internaloption.EnableNewAuthLibrary(), |
| 368 |
} |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
func (c *jobsV1Beta3RESTClient) setGoogleClientInfo(keyval ...string) { |
| 375 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 376 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) |
| 377 |
c.xGoogHeaders = []string{ |
| 378 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
func (c *jobsV1Beta3RESTClient) Close() error { |
| 385 |
|
| 386 |
c.httpClient = nil |
| 387 |
return nil |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
func (c *jobsV1Beta3RESTClient) Connection() *grpc.ClientConn { |
| 394 |
return nil |
| 395 |
} |
| 396 |
func (c *jobsV1Beta3GRPCClient) CreateJob(ctx context.Context, req *dataflowpb.CreateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 397 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()))} |
| 398 |
|
| 399 |
hds = append(c.xGoogHeaders, hds...) |
| 400 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 401 |
opts = append((*c.CallOptions).CreateJob[0:len((*c.CallOptions).CreateJob):len((*c.CallOptions).CreateJob)], opts...) |
| 402 |
var resp *dataflowpb.Job |
| 403 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 404 |
var err error |
| 405 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.CreateJob, req, settings.GRPC, c.logger, "CreateJob") |
| 406 |
return err |
| 407 |
}, opts...) |
| 408 |
if err != nil { |
| 409 |
return nil, err |
| 410 |
} |
| 411 |
return resp, nil |
| 412 |
} |
| 413 |
|
| 414 |
func (c *jobsV1Beta3GRPCClient) GetJob(ctx context.Context, req *dataflowpb.GetJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 415 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 416 |
|
| 417 |
hds = append(c.xGoogHeaders, hds...) |
| 418 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 419 |
opts = append((*c.CallOptions).GetJob[0:len((*c.CallOptions).GetJob):len((*c.CallOptions).GetJob)], opts...) |
| 420 |
var resp *dataflowpb.Job |
| 421 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 422 |
var err error |
| 423 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.GetJob, req, settings.GRPC, c.logger, "GetJob") |
| 424 |
return err |
| 425 |
}, opts...) |
| 426 |
if err != nil { |
| 427 |
return nil, err |
| 428 |
} |
| 429 |
return resp, nil |
| 430 |
} |
| 431 |
|
| 432 |
func (c *jobsV1Beta3GRPCClient) UpdateJob(ctx context.Context, req *dataflowpb.UpdateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 433 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 434 |
|
| 435 |
hds = append(c.xGoogHeaders, hds...) |
| 436 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 437 |
opts = append((*c.CallOptions).UpdateJob[0:len((*c.CallOptions).UpdateJob):len((*c.CallOptions).UpdateJob)], opts...) |
| 438 |
var resp *dataflowpb.Job |
| 439 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 440 |
var err error |
| 441 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.UpdateJob, req, settings.GRPC, c.logger, "UpdateJob") |
| 442 |
return err |
| 443 |
}, opts...) |
| 444 |
if err != nil { |
| 445 |
return nil, err |
| 446 |
} |
| 447 |
return resp, nil |
| 448 |
} |
| 449 |
|
| 450 |
func (c *jobsV1Beta3GRPCClient) ListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 451 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()))} |
| 452 |
|
| 453 |
hds = append(c.xGoogHeaders, hds...) |
| 454 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 455 |
opts = append((*c.CallOptions).ListJobs[0:len((*c.CallOptions).ListJobs):len((*c.CallOptions).ListJobs)], opts...) |
| 456 |
it := &JobIterator{} |
| 457 |
req = proto.Clone(req).(*dataflowpb.ListJobsRequest) |
| 458 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*dataflowpb.Job, string, error) { |
| 459 |
resp := &dataflowpb.ListJobsResponse{} |
| 460 |
if pageToken != "" { |
| 461 |
req.PageToken = pageToken |
| 462 |
} |
| 463 |
if pageSize > math.MaxInt32 { |
| 464 |
req.PageSize = math.MaxInt32 |
| 465 |
} else if pageSize != 0 { |
| 466 |
req.PageSize = int32(pageSize) |
| 467 |
} |
| 468 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 469 |
var err error |
| 470 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.ListJobs, req, settings.GRPC, c.logger, "ListJobs") |
| 471 |
return err |
| 472 |
}, opts...) |
| 473 |
if err != nil { |
| 474 |
return nil, "", err |
| 475 |
} |
| 476 |
|
| 477 |
it.Response = resp |
| 478 |
return resp.GetJobs(), resp.GetNextPageToken(), nil |
| 479 |
} |
| 480 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 481 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 482 |
if err != nil { |
| 483 |
return "", err |
| 484 |
} |
| 485 |
it.items = append(it.items, items...) |
| 486 |
return nextPageToken, nil |
| 487 |
} |
| 488 |
|
| 489 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 490 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 491 |
it.pageInfo.Token = req.GetPageToken() |
| 492 |
|
| 493 |
return it |
| 494 |
} |
| 495 |
|
| 496 |
func (c *jobsV1Beta3GRPCClient) AggregatedListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 497 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project_id", url.QueryEscape(req.GetProjectId()))} |
| 498 |
|
| 499 |
hds = append(c.xGoogHeaders, hds...) |
| 500 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 501 |
opts = append((*c.CallOptions).AggregatedListJobs[0:len((*c.CallOptions).AggregatedListJobs):len((*c.CallOptions).AggregatedListJobs)], opts...) |
| 502 |
it := &JobIterator{} |
| 503 |
req = proto.Clone(req).(*dataflowpb.ListJobsRequest) |
| 504 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*dataflowpb.Job, string, error) { |
| 505 |
resp := &dataflowpb.ListJobsResponse{} |
| 506 |
if pageToken != "" { |
| 507 |
req.PageToken = pageToken |
| 508 |
} |
| 509 |
if pageSize > math.MaxInt32 { |
| 510 |
req.PageSize = math.MaxInt32 |
| 511 |
} else if pageSize != 0 { |
| 512 |
req.PageSize = int32(pageSize) |
| 513 |
} |
| 514 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 515 |
var err error |
| 516 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.AggregatedListJobs, req, settings.GRPC, c.logger, "AggregatedListJobs") |
| 517 |
return err |
| 518 |
}, opts...) |
| 519 |
if err != nil { |
| 520 |
return nil, "", err |
| 521 |
} |
| 522 |
|
| 523 |
it.Response = resp |
| 524 |
return resp.GetJobs(), resp.GetNextPageToken(), nil |
| 525 |
} |
| 526 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 527 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 528 |
if err != nil { |
| 529 |
return "", err |
| 530 |
} |
| 531 |
it.items = append(it.items, items...) |
| 532 |
return nextPageToken, nil |
| 533 |
} |
| 534 |
|
| 535 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 536 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 537 |
it.pageInfo.Token = req.GetPageToken() |
| 538 |
|
| 539 |
return it |
| 540 |
} |
| 541 |
|
| 542 |
func (c *jobsV1Beta3GRPCClient) CheckActiveJobs(ctx context.Context, req *dataflowpb.CheckActiveJobsRequest, opts ...gax.CallOption) (*dataflowpb.CheckActiveJobsResponse, error) { |
| 543 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...) |
| 544 |
opts = append((*c.CallOptions).CheckActiveJobs[0:len((*c.CallOptions).CheckActiveJobs):len((*c.CallOptions).CheckActiveJobs)], opts...) |
| 545 |
var resp *dataflowpb.CheckActiveJobsResponse |
| 546 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 547 |
var err error |
| 548 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.CheckActiveJobs, req, settings.GRPC, c.logger, "CheckActiveJobs") |
| 549 |
return err |
| 550 |
}, opts...) |
| 551 |
if err != nil { |
| 552 |
return nil, err |
| 553 |
} |
| 554 |
return resp, nil |
| 555 |
} |
| 556 |
|
| 557 |
func (c *jobsV1Beta3GRPCClient) SnapshotJob(ctx context.Context, req *dataflowpb.SnapshotJobRequest, opts ...gax.CallOption) (*dataflowpb.Snapshot, error) { |
| 558 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 559 |
|
| 560 |
hds = append(c.xGoogHeaders, hds...) |
| 561 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 562 |
opts = append((*c.CallOptions).SnapshotJob[0:len((*c.CallOptions).SnapshotJob):len((*c.CallOptions).SnapshotJob)], opts...) |
| 563 |
var resp *dataflowpb.Snapshot |
| 564 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 565 |
var err error |
| 566 |
resp, err = executeRPC(ctx, c.jobsV1Beta3Client.SnapshotJob, req, settings.GRPC, c.logger, "SnapshotJob") |
| 567 |
return err |
| 568 |
}, opts...) |
| 569 |
if err != nil { |
| 570 |
return nil, err |
| 571 |
} |
| 572 |
return resp, nil |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
func (c *jobsV1Beta3RESTClient) CreateJob(ctx context.Context, req *dataflowpb.CreateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 586 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 587 |
body := req.GetJob() |
| 588 |
jsonReq, err := m.Marshal(body) |
| 589 |
if err != nil { |
| 590 |
return nil, err |
| 591 |
} |
| 592 |
|
| 593 |
baseUrl, err := url.Parse(c.endpoint) |
| 594 |
if err != nil { |
| 595 |
return nil, err |
| 596 |
} |
| 597 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/locations/%v/jobs", req.GetProjectId(), req.GetLocation()) |
| 598 |
|
| 599 |
params := url.Values{} |
| 600 |
params.Add("$alt", "json;enum-encoding=int") |
| 601 |
if req.GetReplaceJobId() != "" { |
| 602 |
params.Add("replaceJobId", fmt.Sprintf("%v", req.GetReplaceJobId())) |
| 603 |
} |
| 604 |
if req.GetView() != 0 { |
| 605 |
params.Add("view", fmt.Sprintf("%v", req.GetView())) |
| 606 |
} |
| 607 |
|
| 608 |
baseUrl.RawQuery = params.Encode() |
| 609 |
|
| 610 |
|
| 611 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()))} |
| 612 |
|
| 613 |
hds = append(c.xGoogHeaders, hds...) |
| 614 |
hds = append(hds, "Content-Type", "application/json") |
| 615 |
headers := gax.BuildHeaders(ctx, hds...) |
| 616 |
opts = append((*c.CallOptions).CreateJob[0:len((*c.CallOptions).CreateJob):len((*c.CallOptions).CreateJob)], opts...) |
| 617 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 618 |
resp := &dataflowpb.Job{} |
| 619 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 620 |
if settings.Path != "" { |
| 621 |
baseUrl.Path = settings.Path |
| 622 |
} |
| 623 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 624 |
if err != nil { |
| 625 |
return err |
| 626 |
} |
| 627 |
httpReq = httpReq.WithContext(ctx) |
| 628 |
httpReq.Header = headers |
| 629 |
|
| 630 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateJob") |
| 631 |
if err != nil { |
| 632 |
return err |
| 633 |
} |
| 634 |
|
| 635 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 636 |
return err |
| 637 |
} |
| 638 |
|
| 639 |
return nil |
| 640 |
}, opts...) |
| 641 |
if e != nil { |
| 642 |
return nil, e |
| 643 |
} |
| 644 |
return resp, nil |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
func (c *jobsV1Beta3RESTClient) GetJob(ctx context.Context, req *dataflowpb.GetJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 655 |
baseUrl, err := url.Parse(c.endpoint) |
| 656 |
if err != nil { |
| 657 |
return nil, err |
| 658 |
} |
| 659 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/locations/%v/jobs/%v", req.GetProjectId(), req.GetLocation(), req.GetJobId()) |
| 660 |
|
| 661 |
params := url.Values{} |
| 662 |
params.Add("$alt", "json;enum-encoding=int") |
| 663 |
if req.GetView() != 0 { |
| 664 |
params.Add("view", fmt.Sprintf("%v", req.GetView())) |
| 665 |
} |
| 666 |
|
| 667 |
baseUrl.RawQuery = params.Encode() |
| 668 |
|
| 669 |
|
| 670 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 671 |
|
| 672 |
hds = append(c.xGoogHeaders, hds...) |
| 673 |
hds = append(hds, "Content-Type", "application/json") |
| 674 |
headers := gax.BuildHeaders(ctx, hds...) |
| 675 |
opts = append((*c.CallOptions).GetJob[0:len((*c.CallOptions).GetJob):len((*c.CallOptions).GetJob)], opts...) |
| 676 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 677 |
resp := &dataflowpb.Job{} |
| 678 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 679 |
if settings.Path != "" { |
| 680 |
baseUrl.Path = settings.Path |
| 681 |
} |
| 682 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 683 |
if err != nil { |
| 684 |
return err |
| 685 |
} |
| 686 |
httpReq = httpReq.WithContext(ctx) |
| 687 |
httpReq.Header = headers |
| 688 |
|
| 689 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetJob") |
| 690 |
if err != nil { |
| 691 |
return err |
| 692 |
} |
| 693 |
|
| 694 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 695 |
return err |
| 696 |
} |
| 697 |
|
| 698 |
return nil |
| 699 |
}, opts...) |
| 700 |
if e != nil { |
| 701 |
return nil, e |
| 702 |
} |
| 703 |
return resp, nil |
| 704 |
} |
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
func (c *jobsV1Beta3RESTClient) UpdateJob(ctx context.Context, req *dataflowpb.UpdateJobRequest, opts ...gax.CallOption) (*dataflowpb.Job, error) { |
| 714 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 715 |
body := req.GetJob() |
| 716 |
jsonReq, err := m.Marshal(body) |
| 717 |
if err != nil { |
| 718 |
return nil, err |
| 719 |
} |
| 720 |
|
| 721 |
baseUrl, err := url.Parse(c.endpoint) |
| 722 |
if err != nil { |
| 723 |
return nil, err |
| 724 |
} |
| 725 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/locations/%v/jobs/%v", req.GetProjectId(), req.GetLocation(), req.GetJobId()) |
| 726 |
|
| 727 |
params := url.Values{} |
| 728 |
params.Add("$alt", "json;enum-encoding=int") |
| 729 |
if req != nil && req.UpdateMask != nil { |
| 730 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 731 |
if err != nil { |
| 732 |
return nil, err |
| 733 |
} |
| 734 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 735 |
} |
| 736 |
|
| 737 |
baseUrl.RawQuery = params.Encode() |
| 738 |
|
| 739 |
|
| 740 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 741 |
|
| 742 |
hds = append(c.xGoogHeaders, hds...) |
| 743 |
hds = append(hds, "Content-Type", "application/json") |
| 744 |
headers := gax.BuildHeaders(ctx, hds...) |
| 745 |
opts = append((*c.CallOptions).UpdateJob[0:len((*c.CallOptions).UpdateJob):len((*c.CallOptions).UpdateJob)], opts...) |
| 746 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 747 |
resp := &dataflowpb.Job{} |
| 748 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 749 |
if settings.Path != "" { |
| 750 |
baseUrl.Path = settings.Path |
| 751 |
} |
| 752 |
httpReq, err := http.NewRequest("PUT", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 753 |
if err != nil { |
| 754 |
return err |
| 755 |
} |
| 756 |
httpReq = httpReq.WithContext(ctx) |
| 757 |
httpReq.Header = headers |
| 758 |
|
| 759 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateJob") |
| 760 |
if err != nil { |
| 761 |
return err |
| 762 |
} |
| 763 |
|
| 764 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 765 |
return err |
| 766 |
} |
| 767 |
|
| 768 |
return nil |
| 769 |
}, opts...) |
| 770 |
if e != nil { |
| 771 |
return nil, e |
| 772 |
} |
| 773 |
return resp, nil |
| 774 |
} |
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
by |
| 787 |
|
| 788 |
func (c *jobsV1Beta3RESTClient) ListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 789 |
it := &JobIterator{} |
| 790 |
req = proto.Clone(req).(*dataflowpb.ListJobsRequest) |
| 791 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 792 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*dataflowpb.Job, string, error) { |
| 793 |
resp := &dataflowpb.ListJobsResponse{} |
| 794 |
if pageToken != "" { |
| 795 |
req.PageToken = pageToken |
| 796 |
} |
| 797 |
if pageSize > math.MaxInt32 { |
| 798 |
req.PageSize = math.MaxInt32 |
| 799 |
} else if pageSize != 0 { |
| 800 |
req.PageSize = int32(pageSize) |
| 801 |
} |
| 802 |
baseUrl, err := url.Parse(c.endpoint) |
| 803 |
if err != nil { |
| 804 |
return nil, "", err |
| 805 |
} |
| 806 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/locations/%v/jobs", req.GetProjectId(), req.GetLocation()) |
| 807 |
|
| 808 |
params := url.Values{} |
| 809 |
params.Add("$alt", "json;enum-encoding=int") |
| 810 |
if req.GetFilter() != 0 { |
| 811 |
params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) |
| 812 |
} |
| 813 |
if req != nil && req.Name != nil { |
| 814 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 815 |
} |
| 816 |
if req.GetPageSize() != 0 { |
| 817 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 818 |
} |
| 819 |
if req.GetPageToken() != "" { |
| 820 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 821 |
} |
| 822 |
if req.GetView() != 0 { |
| 823 |
params.Add("view", fmt.Sprintf("%v", req.GetView())) |
| 824 |
} |
| 825 |
|
| 826 |
baseUrl.RawQuery = params.Encode() |
| 827 |
|
| 828 |
|
| 829 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 830 |
headers := gax.BuildHeaders(ctx, hds...) |
| 831 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 832 |
if settings.Path != "" { |
| 833 |
baseUrl.Path = settings.Path |
| 834 |
} |
| 835 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 836 |
if err != nil { |
| 837 |
return err |
| 838 |
} |
| 839 |
httpReq.Header = headers |
| 840 |
|
| 841 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListJobs") |
| 842 |
if err != nil { |
| 843 |
return err |
| 844 |
} |
| 845 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 846 |
return err |
| 847 |
} |
| 848 |
|
| 849 |
return nil |
| 850 |
}, opts...) |
| 851 |
if e != nil { |
| 852 |
return nil, "", e |
| 853 |
} |
| 854 |
it.Response = resp |
| 855 |
return resp.GetJobs(), resp.GetNextPageToken(), nil |
| 856 |
} |
| 857 |
|
| 858 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 859 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 860 |
if err != nil { |
| 861 |
return "", err |
| 862 |
} |
| 863 |
it.items = append(it.items, items...) |
| 864 |
return nextPageToken, nil |
| 865 |
} |
| 866 |
|
| 867 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 868 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 869 |
it.pageInfo.Token = req.GetPageToken() |
| 870 |
|
| 871 |
return it |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
of |
| 877 |
|
| 878 |
func (c *jobsV1Beta3RESTClient) AggregatedListJobs(ctx context.Context, req *dataflowpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { |
| 879 |
it := &JobIterator{} |
| 880 |
req = proto.Clone(req).(*dataflowpb.ListJobsRequest) |
| 881 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 882 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*dataflowpb.Job, string, error) { |
| 883 |
resp := &dataflowpb.ListJobsResponse{} |
| 884 |
if pageToken != "" { |
| 885 |
req.PageToken = pageToken |
| 886 |
} |
| 887 |
if pageSize > math.MaxInt32 { |
| 888 |
req.PageSize = math.MaxInt32 |
| 889 |
} else if pageSize != 0 { |
| 890 |
req.PageSize = int32(pageSize) |
| 891 |
} |
| 892 |
baseUrl, err := url.Parse(c.endpoint) |
| 893 |
if err != nil { |
| 894 |
return nil, "", err |
| 895 |
} |
| 896 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/jobs:aggregated", req.GetProjectId()) |
| 897 |
|
| 898 |
params := url.Values{} |
| 899 |
params.Add("$alt", "json;enum-encoding=int") |
| 900 |
if req.GetFilter() != 0 { |
| 901 |
params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) |
| 902 |
} |
| 903 |
if req.GetLocation() != "" { |
| 904 |
params.Add("location", fmt.Sprintf("%v", req.GetLocation())) |
| 905 |
} |
| 906 |
if req != nil && req.Name != nil { |
| 907 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 908 |
} |
| 909 |
if req.GetPageSize() != 0 { |
| 910 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 911 |
} |
| 912 |
if req.GetPageToken() != "" { |
| 913 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 914 |
} |
| 915 |
if req.GetView() != 0 { |
| 916 |
params.Add("view", fmt.Sprintf("%v", req.GetView())) |
| 917 |
} |
| 918 |
|
| 919 |
baseUrl.RawQuery = params.Encode() |
| 920 |
|
| 921 |
|
| 922 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 923 |
headers := gax.BuildHeaders(ctx, hds...) |
| 924 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 925 |
if settings.Path != "" { |
| 926 |
baseUrl.Path = settings.Path |
| 927 |
} |
| 928 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 929 |
if err != nil { |
| 930 |
return err |
| 931 |
} |
| 932 |
httpReq.Header = headers |
| 933 |
|
| 934 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AggregatedListJobs") |
| 935 |
if err != nil { |
| 936 |
return err |
| 937 |
} |
| 938 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 939 |
return err |
| 940 |
} |
| 941 |
|
| 942 |
return nil |
| 943 |
}, opts...) |
| 944 |
if e != nil { |
| 945 |
return nil, "", e |
| 946 |
} |
| 947 |
it.Response = resp |
| 948 |
return resp.GetJobs(), resp.GetNextPageToken(), nil |
| 949 |
} |
| 950 |
|
| 951 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 952 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 953 |
if err != nil { |
| 954 |
return "", err |
| 955 |
} |
| 956 |
it.items = append(it.items, items...) |
| 957 |
return nextPageToken, nil |
| 958 |
} |
| 959 |
|
| 960 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 961 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 962 |
it.pageInfo.Token = req.GetPageToken() |
| 963 |
|
| 964 |
return it |
| 965 |
} |
| 966 |
|
| 967 |
|
| 968 |
func (c *jobsV1Beta3RESTClient) CheckActiveJobs(ctx context.Context, req *dataflowpb.CheckActiveJobsRequest, opts ...gax.CallOption) (*dataflowpb.CheckActiveJobsResponse, error) { |
| 969 |
baseUrl, err := url.Parse(c.endpoint) |
| 970 |
if err != nil { |
| 971 |
return nil, err |
| 972 |
} |
| 973 |
baseUrl.Path += fmt.Sprintf("") |
| 974 |
|
| 975 |
params := url.Values{} |
| 976 |
params.Add("$alt", "json;enum-encoding=int") |
| 977 |
if req.GetProjectId() != "" { |
| 978 |
params.Add("projectId", fmt.Sprintf("%v", req.GetProjectId())) |
| 979 |
} |
| 980 |
|
| 981 |
baseUrl.RawQuery = params.Encode() |
| 982 |
|
| 983 |
|
| 984 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 985 |
headers := gax.BuildHeaders(ctx, hds...) |
| 986 |
opts = append((*c.CallOptions).CheckActiveJobs[0:len((*c.CallOptions).CheckActiveJobs):len((*c.CallOptions).CheckActiveJobs)], opts...) |
| 987 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 988 |
resp := &dataflowpb.CheckActiveJobsResponse{} |
| 989 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 990 |
if settings.Path != "" { |
| 991 |
baseUrl.Path = settings.Path |
| 992 |
} |
| 993 |
httpReq, err := http.NewRequest("", baseUrl.String(), nil) |
| 994 |
if err != nil { |
| 995 |
return err |
| 996 |
} |
| 997 |
httpReq = httpReq.WithContext(ctx) |
| 998 |
httpReq.Header = headers |
| 999 |
|
| 1000 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CheckActiveJobs") |
| 1001 |
if err != nil { |
| 1002 |
return err |
| 1003 |
} |
| 1004 |
|
| 1005 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1006 |
return err |
| 1007 |
} |
| 1008 |
|
| 1009 |
return nil |
| 1010 |
}, opts...) |
| 1011 |
if e != nil { |
| 1012 |
return nil, e |
| 1013 |
} |
| 1014 |
return resp, nil |
| 1015 |
} |
| 1016 |
|
| 1017 |
|
| 1018 |
func (c *jobsV1Beta3RESTClient) SnapshotJob(ctx context.Context, req *dataflowpb.SnapshotJobRequest, opts ...gax.CallOption) (*dataflowpb.Snapshot, error) { |
| 1019 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1020 |
jsonReq, err := m.Marshal(req) |
| 1021 |
if err != nil { |
| 1022 |
return nil, err |
| 1023 |
} |
| 1024 |
|
| 1025 |
baseUrl, err := url.Parse(c.endpoint) |
| 1026 |
if err != nil { |
| 1027 |
return nil, err |
| 1028 |
} |
| 1029 |
baseUrl.Path += fmt.Sprintf("/v1b3/projects/%v/locations/%v/jobs/%v:snapshot", req.GetProjectId(), req.GetLocation(), req.GetJobId()) |
| 1030 |
|
| 1031 |
params := url.Values{} |
| 1032 |
params.Add("$alt", "json;enum-encoding=int") |
| 1033 |
|
| 1034 |
baseUrl.RawQuery = params.Encode() |
| 1035 |
|
| 1036 |
|
| 1037 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "location", url.QueryEscape(req.GetLocation()), "job_id", url.QueryEscape(req.GetJobId()))} |
| 1038 |
|
| 1039 |
hds = append(c.xGoogHeaders, hds...) |
| 1040 |
hds = append(hds, "Content-Type", "application/json") |
| 1041 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1042 |
opts = append((*c.CallOptions).SnapshotJob[0:len((*c.CallOptions).SnapshotJob):len((*c.CallOptions).SnapshotJob)], opts...) |
| 1043 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1044 |
resp := &dataflowpb.Snapshot{} |
| 1045 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1046 |
if settings.Path != "" { |
| 1047 |
baseUrl.Path = settings.Path |
| 1048 |
} |
| 1049 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1050 |
if err != nil { |
| 1051 |
return err |
| 1052 |
} |
| 1053 |
httpReq = httpReq.WithContext(ctx) |
| 1054 |
httpReq.Header = headers |
| 1055 |
|
| 1056 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SnapshotJob") |
| 1057 |
if err != nil { |
| 1058 |
return err |
| 1059 |
} |
| 1060 |
|
| 1061 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1062 |
return err |
| 1063 |
} |
| 1064 |
|
| 1065 |
return nil |
| 1066 |
}, opts...) |
| 1067 |
if e != nil { |
| 1068 |
return nil, e |
| 1069 |
} |
| 1070 |
return resp, nil |
| 1071 |
} |