Debian Codegraph @

video/livestream/apiv1/livestream_client.go

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