Debian Codegraph @

visionai/apiv1/streams_client.go

raw
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 visionai
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27
28 "cloud.google.com/go/longrunning"
29 lroauto "cloud.google.com/go/longrunning/autogen"
30 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
31 visionaipb "cloud.google.com/go/visionai/apiv1/visionaipb"
32 gax "github.com/googleapis/gax-go/v2"
33 "google.golang.org/api/iterator"
34 "google.golang.org/api/option"
35 "google.golang.org/api/option/internaloption"
36 gtransport "google.golang.org/api/transport/grpc"
37 httptransport "google.golang.org/api/transport/http"
38 "google.golang.org/grpc"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newStreamsClientHook clientHook
44
45 // StreamsCallOptions contains the retry settings for each method of StreamsClient.
46 type StreamsCallOptions struct {
47 ListClusters []gax.CallOption
48 GetCluster []gax.CallOption
49 CreateCluster []gax.CallOption
50 UpdateCluster []gax.CallOption
51 DeleteCluster []gax.CallOption
52 ListStreams []gax.CallOption
53 GetStream []gax.CallOption
54 CreateStream []gax.CallOption
55 UpdateStream []gax.CallOption
56 DeleteStream []gax.CallOption
57 GetStreamThumbnail []gax.CallOption
58 GenerateStreamHlsToken []gax.CallOption
59 ListEvents []gax.CallOption
60 GetEvent []gax.CallOption
61 CreateEvent []gax.CallOption
62 UpdateEvent []gax.CallOption
63 DeleteEvent []gax.CallOption
64 ListSeries []gax.CallOption
65 GetSeries []gax.CallOption
66 CreateSeries []gax.CallOption
67 UpdateSeries []gax.CallOption
68 DeleteSeries []gax.CallOption
69 MaterializeChannel []gax.CallOption
70 CancelOperation []gax.CallOption
71 DeleteOperation []gax.CallOption
72 GetOperation []gax.CallOption
73 ListOperations []gax.CallOption
74 }
75
76 func defaultStreamsGRPCClientOptions() []option.ClientOption {
77 return []option.ClientOption{
78 internaloption.WithDefaultEndpoint("visionai.googleapis.com:443"),
79 internaloption.WithDefaultEndpointTemplate("visionai.UNIVERSE_DOMAIN:443"),
80 internaloption.WithDefaultMTLSEndpoint("visionai.mtls.googleapis.com:443"),
81 internaloption.WithDefaultUniverseDomain("googleapis.com"),
82 internaloption.WithDefaultAudience("https://visionai.googleapis.com/"),
83 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
84 internaloption.EnableJwtWithScope(),
85 internaloption.EnableNewAuthLibrary(),
86 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
87 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
88 }
89 }
90
91 func defaultStreamsCallOptions() *StreamsCallOptions {
92 return &StreamsCallOptions{
93 ListClusters: []gax.CallOption{},
94 GetCluster: []gax.CallOption{},
95 CreateCluster: []gax.CallOption{},
96 UpdateCluster: []gax.CallOption{},
97 DeleteCluster: []gax.CallOption{},
98 ListStreams: []gax.CallOption{},
99 GetStream: []gax.CallOption{},
100 CreateStream: []gax.CallOption{},
101 UpdateStream: []gax.CallOption{},
102 DeleteStream: []gax.CallOption{},
103 GetStreamThumbnail: []gax.CallOption{},
104 GenerateStreamHlsToken: []gax.CallOption{},
105 ListEvents: []gax.CallOption{},
106 GetEvent: []gax.CallOption{},
107 CreateEvent: []gax.CallOption{},
108 UpdateEvent: []gax.CallOption{},
109 DeleteEvent: []gax.CallOption{},
110 ListSeries: []gax.CallOption{},
111 GetSeries: []gax.CallOption{},
112 CreateSeries: []gax.CallOption{},
113 UpdateSeries: []gax.CallOption{},
114 DeleteSeries: []gax.CallOption{},
115 MaterializeChannel: []gax.CallOption{},
116 CancelOperation: []gax.CallOption{},
117 DeleteOperation: []gax.CallOption{},
118 GetOperation: []gax.CallOption{},
119 ListOperations: []gax.CallOption{},
120 }
121 }
122
123 func defaultStreamsRESTCallOptions() *StreamsCallOptions {
124 return &StreamsCallOptions{
125 ListClusters: []gax.CallOption{},
126 GetCluster: []gax.CallOption{},
127 CreateCluster: []gax.CallOption{},
128 UpdateCluster: []gax.CallOption{},
129 DeleteCluster: []gax.CallOption{},
130 ListStreams: []gax.CallOption{},
131 GetStream: []gax.CallOption{},
132 CreateStream: []gax.CallOption{},
133 UpdateStream: []gax.CallOption{},
134 DeleteStream: []gax.CallOption{},
135 GetStreamThumbnail: []gax.CallOption{},
136 GenerateStreamHlsToken: []gax.CallOption{},
137 ListEvents: []gax.CallOption{},
138 GetEvent: []gax.CallOption{},
139 CreateEvent: []gax.CallOption{},
140 UpdateEvent: []gax.CallOption{},
141 DeleteEvent: []gax.CallOption{},
142 ListSeries: []gax.CallOption{},
143 GetSeries: []gax.CallOption{},
144 CreateSeries: []gax.CallOption{},
145 UpdateSeries: []gax.CallOption{},
146 DeleteSeries: []gax.CallOption{},
147 MaterializeChannel: []gax.CallOption{},
148 CancelOperation: []gax.CallOption{},
149 DeleteOperation: []gax.CallOption{},
150 GetOperation: []gax.CallOption{},
151 ListOperations: []gax.CallOption{},
152 }
153 }
154
155 // internalStreamsClient is an interface that defines the methods available from Vision AI API.
156 type internalStreamsClient interface {
157 Close() error
158 setGoogleClientInfo(...string)
159 Connection() *grpc.ClientConn
160 ListClusters(context.Context, *visionaipb.ListClustersRequest, ...gax.CallOption) *ClusterIterator
161 GetCluster(context.Context, *visionaipb.GetClusterRequest, ...gax.CallOption) (*visionaipb.Cluster, error)
162 CreateCluster(context.Context, *visionaipb.CreateClusterRequest, ...gax.CallOption) (*CreateClusterOperation, error)
163 CreateClusterOperation(name string) *CreateClusterOperation
164 UpdateCluster(context.Context, *visionaipb.UpdateClusterRequest, ...gax.CallOption) (*UpdateClusterOperation, error)
165 UpdateClusterOperation(name string) *UpdateClusterOperation
166 DeleteCluster(context.Context, *visionaipb.DeleteClusterRequest, ...gax.CallOption) (*DeleteClusterOperation, error)
167 DeleteClusterOperation(name string) *DeleteClusterOperation
168 ListStreams(context.Context, *visionaipb.ListStreamsRequest, ...gax.CallOption) *StreamIterator
169 GetStream(context.Context, *visionaipb.GetStreamRequest, ...gax.CallOption) (*visionaipb.Stream, error)
170 CreateStream(context.Context, *visionaipb.CreateStreamRequest, ...gax.CallOption) (*CreateStreamOperation, error)
171 CreateStreamOperation(name string) *CreateStreamOperation
172 UpdateStream(context.Context, *visionaipb.UpdateStreamRequest, ...gax.CallOption) (*UpdateStreamOperation, error)
173 UpdateStreamOperation(name string) *UpdateStreamOperation
174 DeleteStream(context.Context, *visionaipb.DeleteStreamRequest, ...gax.CallOption) (*DeleteStreamOperation, error)
175 DeleteStreamOperation(name string) *DeleteStreamOperation
176 GetStreamThumbnail(context.Context, *visionaipb.GetStreamThumbnailRequest, ...gax.CallOption) (*GetStreamThumbnailOperation, error)
177 GetStreamThumbnailOperation(name string) *GetStreamThumbnailOperation
178 GenerateStreamHlsToken(context.Context, *visionaipb.GenerateStreamHlsTokenRequest, ...gax.CallOption) (*visionaipb.GenerateStreamHlsTokenResponse, error)
179 ListEvents(context.Context, *visionaipb.ListEventsRequest, ...gax.CallOption) *EventIterator
180 GetEvent(context.Context, *visionaipb.GetEventRequest, ...gax.CallOption) (*visionaipb.Event, error)
181 CreateEvent(context.Context, *visionaipb.CreateEventRequest, ...gax.CallOption) (*CreateEventOperation, error)
182 CreateEventOperation(name string) *CreateEventOperation
183 UpdateEvent(context.Context, *visionaipb.UpdateEventRequest, ...gax.CallOption) (*UpdateEventOperation, error)
184 UpdateEventOperation(name string) *UpdateEventOperation
185 DeleteEvent(context.Context, *visionaipb.DeleteEventRequest, ...gax.CallOption) (*DeleteEventOperation, error)
186 DeleteEventOperation(name string) *DeleteEventOperation
187 ListSeries(context.Context, *visionaipb.ListSeriesRequest, ...gax.CallOption) *SeriesIterator
188 GetSeries(context.Context, *visionaipb.GetSeriesRequest, ...gax.CallOption) (*visionaipb.Series, error)
189 CreateSeries(context.Context, *visionaipb.CreateSeriesRequest, ...gax.CallOption) (*CreateSeriesOperation, error)
190 CreateSeriesOperation(name string) *CreateSeriesOperation
191 UpdateSeries(context.Context, *visionaipb.UpdateSeriesRequest, ...gax.CallOption) (*UpdateSeriesOperation, error)
192 UpdateSeriesOperation(name string) *UpdateSeriesOperation
193 DeleteSeries(context.Context, *visionaipb.DeleteSeriesRequest, ...gax.CallOption) (*DeleteSeriesOperation, error)
194 DeleteSeriesOperation(name string) *DeleteSeriesOperation
195 MaterializeChannel(context.Context, *visionaipb.MaterializeChannelRequest, ...gax.CallOption) (*MaterializeChannelOperation, error)
196 MaterializeChannelOperation(name string) *MaterializeChannelOperation
197 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
198 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
199 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
200 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
201 }
202
203 // StreamsClient is a client for interacting with Vision AI API.
204 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
205 //
206 // Service describing handlers for resources.
207 // Vision API and Vision AI API are two independent APIs developed by the same
208 // team. Vision API is for people to annotate their image while Vision AI is an
209 // e2e solution for customer to build their own computer vision application.
210 type StreamsClient struct {
211 // The internal transport-dependent client.
212 internalClient internalStreamsClient
213
214 // The call options for this service.
215 CallOptions *StreamsCallOptions
216
217 // LROClient is used internally to handle long-running operations.
218 // It is exposed so that its CallOptions can be modified if required.
219 // Users should not Close this client.
220 LROClient *lroauto.OperationsClient
221 }
222
223 // Wrapper methods routed to the internal client.
224
225 // Close closes the connection to the API service. The user should invoke this when
226 // the client is no longer required.
227 func (c *StreamsClient) Close() error {
228 return c.internalClient.Close()
229 }
230
231 // setGoogleClientInfo sets the name and version of the application in
232 // the `x-goog-api-client` header passed on each request. Intended for
233 // use by Google-written clients.
234 func (c *StreamsClient) setGoogleClientInfo(keyval ...string) {
235 c.internalClient.setGoogleClientInfo(keyval...)
236 }
237
238 // Connection returns a connection to the API service.
239 //
240 // Deprecated: Connections are now pooled so this method does not always
241 // return the same resource.
242 func (c *StreamsClient) Connection() *grpc.ClientConn {
243 return c.internalClient.Connection()
244 }
245
246 // ListClusters lists Clusters in a given project and location.
247 func (c *StreamsClient) ListClusters(ctx context.Context, req *visionaipb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
248 return c.internalClient.ListClusters(ctx, req, opts...)
249 }
250
251 // GetCluster gets details of a single Cluster.
252 func (c *StreamsClient) GetCluster(ctx context.Context, req *visionaipb.GetClusterRequest, opts ...gax.CallOption) (*visionaipb.Cluster, error) {
253 return c.internalClient.GetCluster(ctx, req, opts...)
254 }
255
256 // CreateCluster creates a new Cluster in a given project and location.
257 func (c *StreamsClient) CreateCluster(ctx context.Context, req *visionaipb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
258 return c.internalClient.CreateCluster(ctx, req, opts...)
259 }
260
261 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
262 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
263 func (c *StreamsClient) CreateClusterOperation(name string) *CreateClusterOperation {
264 return c.internalClient.CreateClusterOperation(name)
265 }
266
267 // UpdateCluster updates the parameters of a single Cluster.
268 func (c *StreamsClient) UpdateCluster(ctx context.Context, req *visionaipb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
269 return c.internalClient.UpdateCluster(ctx, req, opts...)
270 }
271
272 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
273 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
274 func (c *StreamsClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
275 return c.internalClient.UpdateClusterOperation(name)
276 }
277
278 // DeleteCluster deletes a single Cluster.
279 func (c *StreamsClient) DeleteCluster(ctx context.Context, req *visionaipb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
280 return c.internalClient.DeleteCluster(ctx, req, opts...)
281 }
282
283 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
284 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
285 func (c *StreamsClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
286 return c.internalClient.DeleteClusterOperation(name)
287 }
288
289 // ListStreams lists Streams in a given project and location.
290 func (c *StreamsClient) ListStreams(ctx context.Context, req *visionaipb.ListStreamsRequest, opts ...gax.CallOption) *StreamIterator {
291 return c.internalClient.ListStreams(ctx, req, opts...)
292 }
293
294 // GetStream gets details of a single Stream.
295 func (c *StreamsClient) GetStream(ctx context.Context, req *visionaipb.GetStreamRequest, opts ...gax.CallOption) (*visionaipb.Stream, error) {
296 return c.internalClient.GetStream(ctx, req, opts...)
297 }
298
299 // CreateStream creates a new Stream in a given project and location.
300 func (c *StreamsClient) CreateStream(ctx context.Context, req *visionaipb.CreateStreamRequest, opts ...gax.CallOption) (*CreateStreamOperation, error) {
301 return c.internalClient.CreateStream(ctx, req, opts...)
302 }
303
304 // CreateStreamOperation returns a new CreateStreamOperation from a given name.
305 // The name must be that of a previously created CreateStreamOperation, possibly from a different process.
306 func (c *StreamsClient) CreateStreamOperation(name string) *CreateStreamOperation {
307 return c.internalClient.CreateStreamOperation(name)
308 }
309
310 // UpdateStream updates the parameters of a single Stream.
311 func (c *StreamsClient) UpdateStream(ctx context.Context, req *visionaipb.UpdateStreamRequest, opts ...gax.CallOption) (*UpdateStreamOperation, error) {
312 return c.internalClient.UpdateStream(ctx, req, opts...)
313 }
314
315 // UpdateStreamOperation returns a new UpdateStreamOperation from a given name.
316 // The name must be that of a previously created UpdateStreamOperation, possibly from a different process.
317 func (c *StreamsClient) UpdateStreamOperation(name string) *UpdateStreamOperation {
318 return c.internalClient.UpdateStreamOperation(name)
319 }
320
321 // DeleteStream deletes a single Stream.
322 func (c *StreamsClient) DeleteStream(ctx context.Context, req *visionaipb.DeleteStreamRequest, opts ...gax.CallOption) (*DeleteStreamOperation, error) {
323 return c.internalClient.DeleteStream(ctx, req, opts...)
324 }
325
326 // DeleteStreamOperation returns a new DeleteStreamOperation from a given name.
327 // The name must be that of a previously created DeleteStreamOperation, possibly from a different process.
328 func (c *StreamsClient) DeleteStreamOperation(name string) *DeleteStreamOperation {
329 return c.internalClient.DeleteStreamOperation(name)
330 }
331
332 // GetStreamThumbnail gets the thumbnail (image snapshot) of a single Stream.
333 func (c *StreamsClient) GetStreamThumbnail(ctx context.Context, req *visionaipb.GetStreamThumbnailRequest, opts ...gax.CallOption) (*GetStreamThumbnailOperation, error) {
334 return c.internalClient.GetStreamThumbnail(ctx, req, opts...)
335 }
336
337 // GetStreamThumbnailOperation returns a new GetStreamThumbnailOperation from a given name.
338 // The name must be that of a previously created GetStreamThumbnailOperation, possibly from a different process.
339 func (c *StreamsClient) GetStreamThumbnailOperation(name string) *GetStreamThumbnailOperation {
340 return c.internalClient.GetStreamThumbnailOperation(name)
341 }
342
343 // GenerateStreamHlsToken generate the JWT auth token required to get the stream HLS contents.
344 func (c *StreamsClient) GenerateStreamHlsToken(ctx context.Context, req *visionaipb.GenerateStreamHlsTokenRequest, opts ...gax.CallOption) (*visionaipb.GenerateStreamHlsTokenResponse, error) {
345 return c.internalClient.GenerateStreamHlsToken(ctx, req, opts...)
346 }
347
348 // ListEvents lists Events in a given project and location.
349 func (c *StreamsClient) ListEvents(ctx context.Context, req *visionaipb.ListEventsRequest, opts ...gax.CallOption) *EventIterator {
350 return c.internalClient.ListEvents(ctx, req, opts...)
351 }
352
353 // GetEvent gets details of a single Event.
354 func (c *StreamsClient) GetEvent(ctx context.Context, req *visionaipb.GetEventRequest, opts ...gax.CallOption) (*visionaipb.Event, error) {
355 return c.internalClient.GetEvent(ctx, req, opts...)
356 }
357
358 // CreateEvent creates a new Event in a given project and location.
359 func (c *StreamsClient) CreateEvent(ctx context.Context, req *visionaipb.CreateEventRequest, opts ...gax.CallOption) (*CreateEventOperation, error) {
360 return c.internalClient.CreateEvent(ctx, req, opts...)
361 }
362
363 // CreateEventOperation returns a new CreateEventOperation from a given name.
364 // The name must be that of a previously created CreateEventOperation, possibly from a different process.
365 func (c *StreamsClient) CreateEventOperation(name string) *CreateEventOperation {
366 return c.internalClient.CreateEventOperation(name)
367 }
368
369 // UpdateEvent updates the parameters of a single Event.
370 func (c *StreamsClient) UpdateEvent(ctx context.Context, req *visionaipb.UpdateEventRequest, opts ...gax.CallOption) (*UpdateEventOperation, error) {
371 return c.internalClient.UpdateEvent(ctx, req, opts...)
372 }
373
374 // UpdateEventOperation returns a new UpdateEventOperation from a given name.
375 // The name must be that of a previously created UpdateEventOperation, possibly from a different process.
376 func (c *StreamsClient) UpdateEventOperation(name string) *UpdateEventOperation {
377 return c.internalClient.UpdateEventOperation(name)
378 }
379
380 // DeleteEvent deletes a single Event.
381 func (c *StreamsClient) DeleteEvent(ctx context.Context, req *visionaipb.DeleteEventRequest, opts ...gax.CallOption) (*DeleteEventOperation, error) {
382 return c.internalClient.DeleteEvent(ctx, req, opts...)
383 }
384
385 // DeleteEventOperation returns a new DeleteEventOperation from a given name.
386 // The name must be that of a previously created DeleteEventOperation, possibly from a different process.
387 func (c *StreamsClient) DeleteEventOperation(name string) *DeleteEventOperation {
388 return c.internalClient.DeleteEventOperation(name)
389 }
390
391 // ListSeries lists Series in a given project and location.
392 func (c *StreamsClient) ListSeries(ctx context.Context, req *visionaipb.ListSeriesRequest, opts ...gax.CallOption) *SeriesIterator {
393 return c.internalClient.ListSeries(ctx, req, opts...)
394 }
395
396 // GetSeries gets details of a single Series.
397 func (c *StreamsClient) GetSeries(ctx context.Context, req *visionaipb.GetSeriesRequest, opts ...gax.CallOption) (*visionaipb.Series, error) {
398 return c.internalClient.GetSeries(ctx, req, opts...)
399 }
400
401 // CreateSeries creates a new Series in a given project and location.
402 func (c *StreamsClient) CreateSeries(ctx context.Context, req *visionaipb.CreateSeriesRequest, opts ...gax.CallOption) (*CreateSeriesOperation, error) {
403 return c.internalClient.CreateSeries(ctx, req, opts...)
404 }
405
406 // CreateSeriesOperation returns a new CreateSeriesOperation from a given name.
407 // The name must be that of a previously created CreateSeriesOperation, possibly from a different process.
408 func (c *StreamsClient) CreateSeriesOperation(name string) *CreateSeriesOperation {
409 return c.internalClient.CreateSeriesOperation(name)
410 }
411
412 // UpdateSeries updates the parameters of a single Event.
413 func (c *StreamsClient) UpdateSeries(ctx context.Context, req *visionaipb.UpdateSeriesRequest, opts ...gax.CallOption) (*UpdateSeriesOperation, error) {
414 return c.internalClient.UpdateSeries(ctx, req, opts...)
415 }
416
417 // UpdateSeriesOperation returns a new UpdateSeriesOperation from a given name.
418 // The name must be that of a previously created UpdateSeriesOperation, possibly from a different process.
419 func (c *StreamsClient) UpdateSeriesOperation(name string) *UpdateSeriesOperation {
420 return c.internalClient.UpdateSeriesOperation(name)
421 }
422
423 // DeleteSeries deletes a single Series.
424 func (c *StreamsClient) DeleteSeries(ctx context.Context, req *visionaipb.DeleteSeriesRequest, opts ...gax.CallOption) (*DeleteSeriesOperation, error) {
425 return c.internalClient.DeleteSeries(ctx, req, opts...)
426 }
427
428 // DeleteSeriesOperation returns a new DeleteSeriesOperation from a given name.
429 // The name must be that of a previously created DeleteSeriesOperation, possibly from a different process.
430 func (c *StreamsClient) DeleteSeriesOperation(name string) *DeleteSeriesOperation {
431 return c.internalClient.DeleteSeriesOperation(name)
432 }
433
434 // MaterializeChannel materialize a channel.
435 func (c *StreamsClient) MaterializeChannel(ctx context.Context, req *visionaipb.MaterializeChannelRequest, opts ...gax.CallOption) (*MaterializeChannelOperation, error) {
436 return c.internalClient.MaterializeChannel(ctx, req, opts...)
437 }
438
439 // MaterializeChannelOperation returns a new MaterializeChannelOperation from a given name.
440 // The name must be that of a previously created MaterializeChannelOperation, possibly from a different process.
441 func (c *StreamsClient) MaterializeChannelOperation(name string) *MaterializeChannelOperation {
442 return c.internalClient.MaterializeChannelOperation(name)
443 }
444
445 // CancelOperation is a utility method from google.longrunning.Operations.
446 func (c *StreamsClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
447 return c.internalClient.CancelOperation(ctx, req, opts...)
448 }
449
450 // DeleteOperation is a utility method from google.longrunning.Operations.
451 func (c *StreamsClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
452 return c.internalClient.DeleteOperation(ctx, req, opts...)
453 }
454
455 // GetOperation is a utility method from google.longrunning.Operations.
456 func (c *StreamsClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
457 return c.internalClient.GetOperation(ctx, req, opts...)
458 }
459
460 // ListOperations is a utility method from google.longrunning.Operations.
461 func (c *StreamsClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
462 return c.internalClient.ListOperations(ctx, req, opts...)
463 }
464
465 // streamsGRPCClient is a client for interacting with Vision AI API over gRPC transport.
466 //
467 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
468 type streamsGRPCClient struct {
469 // Connection pool of gRPC connections to the service.
470 connPool gtransport.ConnPool
471
472 // Points back to the CallOptions field of the containing StreamsClient
473 CallOptions **StreamsCallOptions
474
475 // The gRPC API client.
476 streamsClient visionaipb.StreamsServiceClient
477
478 // LROClient is used internally to handle long-running operations.
479 // It is exposed so that its CallOptions can be modified if required.
480 // Users should not Close this client.
481 LROClient **lroauto.OperationsClient
482
483 operationsClient longrunningpb.OperationsClient
484
485 // The x-goog-* metadata to be sent with each request.
486 xGoogHeaders []string
487
488 logger *slog.Logger
489 }
490
491 // NewStreamsClient creates a new streams service client based on gRPC.
492 // The returned client must be Closed when it is done being used to clean up its underlying connections.
493 //
494 // Service describing handlers for resources.
495 // Vision API and Vision AI API are two independent APIs developed by the same
496 // team. Vision API is for people to annotate their image while Vision AI is an
497 // e2e solution for customer to build their own computer vision application.
498 func NewStreamsClient(ctx context.Context, opts ...option.ClientOption) (*StreamsClient, error) {
499 clientOpts := defaultStreamsGRPCClientOptions()
500 if newStreamsClientHook != nil {
501 hookOpts, err := newStreamsClientHook(ctx, clientHookParams{})
502 if err != nil {
503 return nil, err
504 }
505 clientOpts = append(clientOpts, hookOpts...)
506 }
507
508 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
509 if err != nil {
510 return nil, err
511 }
512 client := StreamsClient{CallOptions: defaultStreamsCallOptions()}
513
514 c := &streamsGRPCClient{
515 connPool: connPool,
516 streamsClient: visionaipb.NewStreamsServiceClient(connPool),
517 CallOptions: &client.CallOptions,
518 logger: internaloption.GetLogger(opts),
519 operationsClient: longrunningpb.NewOperationsClient(connPool),
520 }
521 c.setGoogleClientInfo()
522
523 client.internalClient = c
524
525 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
526 if err != nil {
527 // This error "should not happen", since we are just reusing old connection pool
528 // and never actually need to dial.
529 // If this does happen, we could leak connp. However, we cannot close conn:
530 // If the user invoked the constructor with option.WithGRPCConn,
531 // we would close a connection that's still in use.
532 // TODO: investigate error conditions.
533 return nil, err
534 }
535 c.LROClient = &client.LROClient
536 return &client, nil
537 }
538
539 // Connection returns a connection to the API service.
540 //
541 // Deprecated: Connections are now pooled so this method does not always
542 // return the same resource.
543 func (c *streamsGRPCClient) Connection() *grpc.ClientConn {
544 return c.connPool.Conn()
545 }
546
547 // setGoogleClientInfo sets the name and version of the application in
548 // the `x-goog-api-client` header passed on each request. Intended for
549 // use by Google-written clients.
550 func (c *streamsGRPCClient) setGoogleClientInfo(keyval ...string) {
551 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
552 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
553 c.xGoogHeaders = []string{
554 "x-goog-api-client", gax.XGoogHeader(kv...),
555 }
556 }
557
558 // Close closes the connection to the API service. The user should invoke this when
559 // the client is no longer required.
560 func (c *streamsGRPCClient) Close() error {
561 return c.connPool.Close()
562 }
563
564 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
565 type streamsRESTClient struct {
566 // The http endpoint to connect to.
567 endpoint string
568
569 // The http client.
570 httpClient *http.Client
571
572 // LROClient is used internally to handle long-running operations.
573 // It is exposed so that its CallOptions can be modified if required.
574 // Users should not Close this client.
575 LROClient **lroauto.OperationsClient
576
577 // The x-goog-* headers to be sent with each request.
578 xGoogHeaders []string
579
580 // Points back to the CallOptions field of the containing StreamsClient
581 CallOptions **StreamsCallOptions
582
583 logger *slog.Logger
584 }
585
586 // NewStreamsRESTClient creates a new streams service rest client.
587 //
588 // Service describing handlers for resources.
589 // Vision API and Vision AI API are two independent APIs developed by the same
590 // team. Vision API is for people to annotate their image while Vision AI is an
591 // e2e solution for customer to build their own computer vision application.
592 func NewStreamsRESTClient(ctx context.Context, opts ...option.ClientOption) (*StreamsClient, error) {
593 clientOpts := append(defaultStreamsRESTClientOptions(), opts...)
594 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
595 if err != nil {
596 return nil, err
597 }
598
599 callOpts := defaultStreamsRESTCallOptions()
600 c := &streamsRESTClient{
601 endpoint: endpoint,
602 httpClient: httpClient,
603 CallOptions: &callOpts,
604 logger: internaloption.GetLogger(opts),
605 }
606 c.setGoogleClientInfo()
607
608 lroOpts := []option.ClientOption{
609 option.WithHTTPClient(httpClient),
610 option.WithEndpoint(endpoint),
611 }
612 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
613 if err != nil {
614 return nil, err
615 }
616 c.LROClient = &opClient
617
618 return &StreamsClient{internalClient: c, CallOptions: callOpts}, nil
619 }
620
621 func defaultStreamsRESTClientOptions() []option.ClientOption {
622 return []option.ClientOption{
623 internaloption.WithDefaultEndpoint("https://visionai.googleapis.com"),
624 internaloption.WithDefaultEndpointTemplate("https://visionai.UNIVERSE_DOMAIN"),
625 internaloption.WithDefaultMTLSEndpoint("https://visionai.mtls.googleapis.com"),
626 internaloption.WithDefaultUniverseDomain("googleapis.com"),
627 internaloption.WithDefaultAudience("https://visionai.googleapis.com/"),
628 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
629 internaloption.EnableNewAuthLibrary(),
630 }
631 }
632
633 // setGoogleClientInfo sets the name and version of the application in
634 // the `x-goog-api-client` header passed on each request. Intended for
635 // use by Google-written clients.
636 func (c *streamsRESTClient) setGoogleClientInfo(keyval ...string) {
637 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
638 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
639 c.xGoogHeaders = []string{
640 "x-goog-api-client", gax.XGoogHeader(kv...),
641 }
642 }
643
644 // Close closes the connection to the API service. The user should invoke this when
645 // the client is no longer required.
646 func (c *streamsRESTClient) Close() error {
647 // Replace httpClient with nil to force cleanup.
648 c.httpClient = nil
649 return nil
650 }
651
652 // Connection returns a connection to the API service.
653 //
654 // Deprecated: This method always returns nil.
655 func (c *streamsRESTClient) Connection() *grpc.ClientConn {
656 return nil
657 }
658 func (c *streamsGRPCClient) ListClusters(ctx context.Context, req *visionaipb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
659 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
660
661 hds = append(c.xGoogHeaders, hds...)
662 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
663 opts = append((*c.CallOptions).ListClusters[0:len((*c.CallOptions).ListClusters):len((*c.CallOptions).ListClusters)], opts...)
664 it := &ClusterIterator{}
665 req = proto.Clone(req).(*visionaipb.ListClustersRequest)
666 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Cluster, string, error) {
667 resp := &visionaipb.ListClustersResponse{}
668 if pageToken != "" {
669 req.PageToken = pageToken
670 }
671 if pageSize > math.MaxInt32 {
672 req.PageSize = math.MaxInt32
673 } else if pageSize != 0 {
674 req.PageSize = int32(pageSize)
675 }
676 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
677 var err error
678 resp, err = executeRPC(ctx, c.streamsClient.ListClusters, req, settings.GRPC, c.logger, "ListClusters")
679 return err
680 }, opts...)
681 if err != nil {
682 return nil, "", err
683 }
684
685 it.Response = resp
686 return resp.GetClusters(), resp.GetNextPageToken(), nil
687 }
688 fetch := func(pageSize int, pageToken string) (string, error) {
689 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
690 if err != nil {
691 return "", err
692 }
693 it.items = append(it.items, items...)
694 return nextPageToken, nil
695 }
696
697 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
698 it.pageInfo.MaxSize = int(req.GetPageSize())
699 it.pageInfo.Token = req.GetPageToken()
700
701 return it
702 }
703
704 func (c *streamsGRPCClient) GetCluster(ctx context.Context, req *visionaipb.GetClusterRequest, opts ...gax.CallOption) (*visionaipb.Cluster, error) {
705 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
706
707 hds = append(c.xGoogHeaders, hds...)
708 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
709 opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
710 var resp *visionaipb.Cluster
711 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
712 var err error
713 resp, err = executeRPC(ctx, c.streamsClient.GetCluster, req, settings.GRPC, c.logger, "GetCluster")
714 return err
715 }, opts...)
716 if err != nil {
717 return nil, err
718 }
719 return resp, nil
720 }
721
722 func (c *streamsGRPCClient) CreateCluster(ctx context.Context, req *visionaipb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
723 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
724
725 hds = append(c.xGoogHeaders, hds...)
726 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
727 opts = append((*c.CallOptions).CreateCluster[0:len((*c.CallOptions).CreateCluster):len((*c.CallOptions).CreateCluster)], opts...)
728 var resp *longrunningpb.Operation
729 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
730 var err error
731 resp, err = executeRPC(ctx, c.streamsClient.CreateCluster, req, settings.GRPC, c.logger, "CreateCluster")
732 return err
733 }, opts...)
734 if err != nil {
735 return nil, err
736 }
737 return &CreateClusterOperation{
738 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
739 }, nil
740 }
741
742 func (c *streamsGRPCClient) UpdateCluster(ctx context.Context, req *visionaipb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
743 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName()))}
744
745 hds = append(c.xGoogHeaders, hds...)
746 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
747 opts = append((*c.CallOptions).UpdateCluster[0:len((*c.CallOptions).UpdateCluster):len((*c.CallOptions).UpdateCluster)], opts...)
748 var resp *longrunningpb.Operation
749 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
750 var err error
751 resp, err = executeRPC(ctx, c.streamsClient.UpdateCluster, req, settings.GRPC, c.logger, "UpdateCluster")
752 return err
753 }, opts...)
754 if err != nil {
755 return nil, err
756 }
757 return &UpdateClusterOperation{
758 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
759 }, nil
760 }
761
762 func (c *streamsGRPCClient) DeleteCluster(ctx context.Context, req *visionaipb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
763 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
764
765 hds = append(c.xGoogHeaders, hds...)
766 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
767 opts = append((*c.CallOptions).DeleteCluster[0:len((*c.CallOptions).DeleteCluster):len((*c.CallOptions).DeleteCluster)], opts...)
768 var resp *longrunningpb.Operation
769 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
770 var err error
771 resp, err = executeRPC(ctx, c.streamsClient.DeleteCluster, req, settings.GRPC, c.logger, "DeleteCluster")
772 return err
773 }, opts...)
774 if err != nil {
775 return nil, err
776 }
777 return &DeleteClusterOperation{
778 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
779 }, nil
780 }
781
782 func (c *streamsGRPCClient) ListStreams(ctx context.Context, req *visionaipb.ListStreamsRequest, opts ...gax.CallOption) *StreamIterator {
783 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
784
785 hds = append(c.xGoogHeaders, hds...)
786 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
787 opts = append((*c.CallOptions).ListStreams[0:len((*c.CallOptions).ListStreams):len((*c.CallOptions).ListStreams)], opts...)
788 it := &StreamIterator{}
789 req = proto.Clone(req).(*visionaipb.ListStreamsRequest)
790 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Stream, string, error) {
791 resp := &visionaipb.ListStreamsResponse{}
792 if pageToken != "" {
793 req.PageToken = pageToken
794 }
795 if pageSize > math.MaxInt32 {
796 req.PageSize = math.MaxInt32
797 } else if pageSize != 0 {
798 req.PageSize = int32(pageSize)
799 }
800 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
801 var err error
802 resp, err = executeRPC(ctx, c.streamsClient.ListStreams, req, settings.GRPC, c.logger, "ListStreams")
803 return err
804 }, opts...)
805 if err != nil {
806 return nil, "", err
807 }
808
809 it.Response = resp
810 return resp.GetStreams(), resp.GetNextPageToken(), nil
811 }
812 fetch := func(pageSize int, pageToken string) (string, error) {
813 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
814 if err != nil {
815 return "", err
816 }
817 it.items = append(it.items, items...)
818 return nextPageToken, nil
819 }
820
821 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
822 it.pageInfo.MaxSize = int(req.GetPageSize())
823 it.pageInfo.Token = req.GetPageToken()
824
825 return it
826 }
827
828 func (c *streamsGRPCClient) GetStream(ctx context.Context, req *visionaipb.GetStreamRequest, opts ...gax.CallOption) (*visionaipb.Stream, error) {
829 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
830
831 hds = append(c.xGoogHeaders, hds...)
832 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
833 opts = append((*c.CallOptions).GetStream[0:len((*c.CallOptions).GetStream):len((*c.CallOptions).GetStream)], opts...)
834 var resp *visionaipb.Stream
835 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
836 var err error
837 resp, err = executeRPC(ctx, c.streamsClient.GetStream, req, settings.GRPC, c.logger, "GetStream")
838 return err
839 }, opts...)
840 if err != nil {
841 return nil, err
842 }
843 return resp, nil
844 }
845
846 func (c *streamsGRPCClient) CreateStream(ctx context.Context, req *visionaipb.CreateStreamRequest, opts ...gax.CallOption) (*CreateStreamOperation, error) {
847 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
848
849 hds = append(c.xGoogHeaders, hds...)
850 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
851 opts = append((*c.CallOptions).CreateStream[0:len((*c.CallOptions).CreateStream):len((*c.CallOptions).CreateStream)], opts...)
852 var resp *longrunningpb.Operation
853 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
854 var err error
855 resp, err = executeRPC(ctx, c.streamsClient.CreateStream, req, settings.GRPC, c.logger, "CreateStream")
856 return err
857 }, opts...)
858 if err != nil {
859 return nil, err
860 }
861 return &CreateStreamOperation{
862 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
863 }, nil
864 }
865
866 func (c *streamsGRPCClient) UpdateStream(ctx context.Context, req *visionaipb.UpdateStreamRequest, opts ...gax.CallOption) (*UpdateStreamOperation, error) {
867 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream.name", url.QueryEscape(req.GetStream().GetName()))}
868
869 hds = append(c.xGoogHeaders, hds...)
870 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
871 opts = append((*c.CallOptions).UpdateStream[0:len((*c.CallOptions).UpdateStream):len((*c.CallOptions).UpdateStream)], opts...)
872 var resp *longrunningpb.Operation
873 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
874 var err error
875 resp, err = executeRPC(ctx, c.streamsClient.UpdateStream, req, settings.GRPC, c.logger, "UpdateStream")
876 return err
877 }, opts...)
878 if err != nil {
879 return nil, err
880 }
881 return &UpdateStreamOperation{
882 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
883 }, nil
884 }
885
886 func (c *streamsGRPCClient) DeleteStream(ctx context.Context, req *visionaipb.DeleteStreamRequest, opts ...gax.CallOption) (*DeleteStreamOperation, error) {
887 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
888
889 hds = append(c.xGoogHeaders, hds...)
890 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
891 opts = append((*c.CallOptions).DeleteStream[0:len((*c.CallOptions).DeleteStream):len((*c.CallOptions).DeleteStream)], opts...)
892 var resp *longrunningpb.Operation
893 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
894 var err error
895 resp, err = executeRPC(ctx, c.streamsClient.DeleteStream, req, settings.GRPC, c.logger, "DeleteStream")
896 return err
897 }, opts...)
898 if err != nil {
899 return nil, err
900 }
901 return &DeleteStreamOperation{
902 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
903 }, nil
904 }
905
906 func (c *streamsGRPCClient) GetStreamThumbnail(ctx context.Context, req *visionaipb.GetStreamThumbnailRequest, opts ...gax.CallOption) (*GetStreamThumbnailOperation, error) {
907 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream", url.QueryEscape(req.GetStream()))}
908
909 hds = append(c.xGoogHeaders, hds...)
910 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
911 opts = append((*c.CallOptions).GetStreamThumbnail[0:len((*c.CallOptions).GetStreamThumbnail):len((*c.CallOptions).GetStreamThumbnail)], opts...)
912 var resp *longrunningpb.Operation
913 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
914 var err error
915 resp, err = executeRPC(ctx, c.streamsClient.GetStreamThumbnail, req, settings.GRPC, c.logger, "GetStreamThumbnail")
916 return err
917 }, opts...)
918 if err != nil {
919 return nil, err
920 }
921 return &GetStreamThumbnailOperation{
922 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
923 }, nil
924 }
925
926 func (c *streamsGRPCClient) GenerateStreamHlsToken(ctx context.Context, req *visionaipb.GenerateStreamHlsTokenRequest, opts ...gax.CallOption) (*visionaipb.GenerateStreamHlsTokenResponse, error) {
927 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream", url.QueryEscape(req.GetStream()))}
928
929 hds = append(c.xGoogHeaders, hds...)
930 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
931 opts = append((*c.CallOptions).GenerateStreamHlsToken[0:len((*c.CallOptions).GenerateStreamHlsToken):len((*c.CallOptions).GenerateStreamHlsToken)], opts...)
932 var resp *visionaipb.GenerateStreamHlsTokenResponse
933 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
934 var err error
935 resp, err = executeRPC(ctx, c.streamsClient.GenerateStreamHlsToken, req, settings.GRPC, c.logger, "GenerateStreamHlsToken")
936 return err
937 }, opts...)
938 if err != nil {
939 return nil, err
940 }
941 return resp, nil
942 }
943
944 func (c *streamsGRPCClient) ListEvents(ctx context.Context, req *visionaipb.ListEventsRequest, opts ...gax.CallOption) *EventIterator {
945 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
946
947 hds = append(c.xGoogHeaders, hds...)
948 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
949 opts = append((*c.CallOptions).ListEvents[0:len((*c.CallOptions).ListEvents):len((*c.CallOptions).ListEvents)], opts...)
950 it := &EventIterator{}
951 req = proto.Clone(req).(*visionaipb.ListEventsRequest)
952 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Event, string, error) {
953 resp := &visionaipb.ListEventsResponse{}
954 if pageToken != "" {
955 req.PageToken = pageToken
956 }
957 if pageSize > math.MaxInt32 {
958 req.PageSize = math.MaxInt32
959 } else if pageSize != 0 {
960 req.PageSize = int32(pageSize)
961 }
962 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
963 var err error
964 resp, err = executeRPC(ctx, c.streamsClient.ListEvents, req, settings.GRPC, c.logger, "ListEvents")
965 return err
966 }, opts...)
967 if err != nil {
968 return nil, "", err
969 }
970
971 it.Response = resp
972 return resp.GetEvents(), resp.GetNextPageToken(), nil
973 }
974 fetch := func(pageSize int, pageToken string) (string, error) {
975 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
976 if err != nil {
977 return "", err
978 }
979 it.items = append(it.items, items...)
980 return nextPageToken, nil
981 }
982
983 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
984 it.pageInfo.MaxSize = int(req.GetPageSize())
985 it.pageInfo.Token = req.GetPageToken()
986
987 return it
988 }
989
990 func (c *streamsGRPCClient) GetEvent(ctx context.Context, req *visionaipb.GetEventRequest, opts ...gax.CallOption) (*visionaipb.Event, error) {
991 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
992
993 hds = append(c.xGoogHeaders, hds...)
994 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
995 opts = append((*c.CallOptions).GetEvent[0:len((*c.CallOptions).GetEvent):len((*c.CallOptions).GetEvent)], opts...)
996 var resp *visionaipb.Event
997 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
998 var err error
999 resp, err = executeRPC(ctx, c.streamsClient.GetEvent, req, settings.GRPC, c.logger, "GetEvent")
1000 return err
1001 }, opts...)
1002 if err != nil {
1003 return nil, err
1004 }
1005 return resp, nil
1006 }
1007
1008 func (c *streamsGRPCClient) CreateEvent(ctx context.Context, req *visionaipb.CreateEventRequest, opts ...gax.CallOption) (*CreateEventOperation, error) {
1009 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1010
1011 hds = append(c.xGoogHeaders, hds...)
1012 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1013 opts = append((*c.CallOptions).CreateEvent[0:len((*c.CallOptions).CreateEvent):len((*c.CallOptions).CreateEvent)], opts...)
1014 var resp *longrunningpb.Operation
1015 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1016 var err error
1017 resp, err = executeRPC(ctx, c.streamsClient.CreateEvent, req, settings.GRPC, c.logger, "CreateEvent")
1018 return err
1019 }, opts...)
1020 if err != nil {
1021 return nil, err
1022 }
1023 return &CreateEventOperation{
1024 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1025 }, nil
1026 }
1027
1028 func (c *streamsGRPCClient) UpdateEvent(ctx context.Context, req *visionaipb.UpdateEventRequest, opts ...gax.CallOption) (*UpdateEventOperation, error) {
1029 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "event.name", url.QueryEscape(req.GetEvent().GetName()))}
1030
1031 hds = append(c.xGoogHeaders, hds...)
1032 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1033 opts = append((*c.CallOptions).UpdateEvent[0:len((*c.CallOptions).UpdateEvent):len((*c.CallOptions).UpdateEvent)], opts...)
1034 var resp *longrunningpb.Operation
1035 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1036 var err error
1037 resp, err = executeRPC(ctx, c.streamsClient.UpdateEvent, req, settings.GRPC, c.logger, "UpdateEvent")
1038 return err
1039 }, opts...)
1040 if err != nil {
1041 return nil, err
1042 }
1043 return &UpdateEventOperation{
1044 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1045 }, nil
1046 }
1047
1048 func (c *streamsGRPCClient) DeleteEvent(ctx context.Context, req *visionaipb.DeleteEventRequest, opts ...gax.CallOption) (*DeleteEventOperation, error) {
1049 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1050
1051 hds = append(c.xGoogHeaders, hds...)
1052 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1053 opts = append((*c.CallOptions).DeleteEvent[0:len((*c.CallOptions).DeleteEvent):len((*c.CallOptions).DeleteEvent)], opts...)
1054 var resp *longrunningpb.Operation
1055 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1056 var err error
1057 resp, err = executeRPC(ctx, c.streamsClient.DeleteEvent, req, settings.GRPC, c.logger, "DeleteEvent")
1058 return err
1059 }, opts...)
1060 if err != nil {
1061 return nil, err
1062 }
1063 return &DeleteEventOperation{
1064 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1065 }, nil
1066 }
1067
1068 func (c *streamsGRPCClient) ListSeries(ctx context.Context, req *visionaipb.ListSeriesRequest, opts ...gax.CallOption) *SeriesIterator {
1069 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1070
1071 hds = append(c.xGoogHeaders, hds...)
1072 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1073 opts = append((*c.CallOptions).ListSeries[0:len((*c.CallOptions).ListSeries):len((*c.CallOptions).ListSeries)], opts...)
1074 it := &SeriesIterator{}
1075 req = proto.Clone(req).(*visionaipb.ListSeriesRequest)
1076 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Series, string, error) {
1077 resp := &visionaipb.ListSeriesResponse{}
1078 if pageToken != "" {
1079 req.PageToken = pageToken
1080 }
1081 if pageSize > math.MaxInt32 {
1082 req.PageSize = math.MaxInt32
1083 } else if pageSize != 0 {
1084 req.PageSize = int32(pageSize)
1085 }
1086 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1087 var err error
1088 resp, err = executeRPC(ctx, c.streamsClient.ListSeries, req, settings.GRPC, c.logger, "ListSeries")
1089 return err
1090 }, opts...)
1091 if err != nil {
1092 return nil, "", err
1093 }
1094
1095 it.Response = resp
1096 return resp.GetSeries(), resp.GetNextPageToken(), nil
1097 }
1098 fetch := func(pageSize int, pageToken string) (string, error) {
1099 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1100 if err != nil {
1101 return "", err
1102 }
1103 it.items = append(it.items, items...)
1104 return nextPageToken, nil
1105 }
1106
1107 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1108 it.pageInfo.MaxSize = int(req.GetPageSize())
1109 it.pageInfo.Token = req.GetPageToken()
1110
1111 return it
1112 }
1113
1114 func (c *streamsGRPCClient) GetSeries(ctx context.Context, req *visionaipb.GetSeriesRequest, opts ...gax.CallOption) (*visionaipb.Series, error) {
1115 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1116
1117 hds = append(c.xGoogHeaders, hds...)
1118 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1119 opts = append((*c.CallOptions).GetSeries[0:len((*c.CallOptions).GetSeries):len((*c.CallOptions).GetSeries)], opts...)
1120 var resp *visionaipb.Series
1121 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1122 var err error
1123 resp, err = executeRPC(ctx, c.streamsClient.GetSeries, req, settings.GRPC, c.logger, "GetSeries")
1124 return err
1125 }, opts...)
1126 if err != nil {
1127 return nil, err
1128 }
1129 return resp, nil
1130 }
1131
1132 func (c *streamsGRPCClient) CreateSeries(ctx context.Context, req *visionaipb.CreateSeriesRequest, opts ...gax.CallOption) (*CreateSeriesOperation, error) {
1133 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1134
1135 hds = append(c.xGoogHeaders, hds...)
1136 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1137 opts = append((*c.CallOptions).CreateSeries[0:len((*c.CallOptions).CreateSeries):len((*c.CallOptions).CreateSeries)], opts...)
1138 var resp *longrunningpb.Operation
1139 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1140 var err error
1141 resp, err = executeRPC(ctx, c.streamsClient.CreateSeries, req, settings.GRPC, c.logger, "CreateSeries")
1142 return err
1143 }, opts...)
1144 if err != nil {
1145 return nil, err
1146 }
1147 return &CreateSeriesOperation{
1148 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1149 }, nil
1150 }
1151
1152 func (c *streamsGRPCClient) UpdateSeries(ctx context.Context, req *visionaipb.UpdateSeriesRequest, opts ...gax.CallOption) (*UpdateSeriesOperation, error) {
1153 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "series.name", url.QueryEscape(req.GetSeries().GetName()))}
1154
1155 hds = append(c.xGoogHeaders, hds...)
1156 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1157 opts = append((*c.CallOptions).UpdateSeries[0:len((*c.CallOptions).UpdateSeries):len((*c.CallOptions).UpdateSeries)], opts...)
1158 var resp *longrunningpb.Operation
1159 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1160 var err error
1161 resp, err = executeRPC(ctx, c.streamsClient.UpdateSeries, req, settings.GRPC, c.logger, "UpdateSeries")
1162 return err
1163 }, opts...)
1164 if err != nil {
1165 return nil, err
1166 }
1167 return &UpdateSeriesOperation{
1168 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1169 }, nil
1170 }
1171
1172 func (c *streamsGRPCClient) DeleteSeries(ctx context.Context, req *visionaipb.DeleteSeriesRequest, opts ...gax.CallOption) (*DeleteSeriesOperation, error) {
1173 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1174
1175 hds = append(c.xGoogHeaders, hds...)
1176 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1177 opts = append((*c.CallOptions).DeleteSeries[0:len((*c.CallOptions).DeleteSeries):len((*c.CallOptions).DeleteSeries)], opts...)
1178 var resp *longrunningpb.Operation
1179 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1180 var err error
1181 resp, err = executeRPC(ctx, c.streamsClient.DeleteSeries, req, settings.GRPC, c.logger, "DeleteSeries")
1182 return err
1183 }, opts...)
1184 if err != nil {
1185 return nil, err
1186 }
1187 return &DeleteSeriesOperation{
1188 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1189 }, nil
1190 }
1191
1192 func (c *streamsGRPCClient) MaterializeChannel(ctx context.Context, req *visionaipb.MaterializeChannelRequest, opts ...gax.CallOption) (*MaterializeChannelOperation, error) {
1193 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1194
1195 hds = append(c.xGoogHeaders, hds...)
1196 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1197 opts = append((*c.CallOptions).MaterializeChannel[0:len((*c.CallOptions).MaterializeChannel):len((*c.CallOptions).MaterializeChannel)], opts...)
1198 var resp *longrunningpb.Operation
1199 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1200 var err error
1201 resp, err = executeRPC(ctx, c.streamsClient.MaterializeChannel, req, settings.GRPC, c.logger, "MaterializeChannel")
1202 return err
1203 }, opts...)
1204 if err != nil {
1205 return nil, err
1206 }
1207 return &MaterializeChannelOperation{
1208 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1209 }, nil
1210 }
1211
1212 func (c *streamsGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1213 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1214
1215 hds = append(c.xGoogHeaders, hds...)
1216 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1217 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
1218 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1219 var err error
1220 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
1221 return err
1222 }, opts...)
1223 return err
1224 }
1225
1226 func (c *streamsGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1227 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1228
1229 hds = append(c.xGoogHeaders, hds...)
1230 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1231 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
1232 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1233 var err error
1234 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
1235 return err
1236 }, opts...)
1237 return err
1238 }
1239
1240 func (c *streamsGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1241 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1242
1243 hds = append(c.xGoogHeaders, hds...)
1244 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1245 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1246 var resp *longrunningpb.Operation
1247 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1248 var err error
1249 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1250 return err
1251 }, opts...)
1252 if err != nil {
1253 return nil, err
1254 }
1255 return resp, nil
1256 }
1257
1258 func (c *streamsGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1259 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1260
1261 hds = append(c.xGoogHeaders, hds...)
1262 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1263 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
1264 it := &OperationIterator{}
1265 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1266 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1267 resp := &longrunningpb.ListOperationsResponse{}
1268 if pageToken != "" {
1269 req.PageToken = pageToken
1270 }
1271 if pageSize > math.MaxInt32 {
1272 req.PageSize = math.MaxInt32
1273 } else if pageSize != 0 {
1274 req.PageSize = int32(pageSize)
1275 }
1276 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1277 var err error
1278 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
1279 return err
1280 }, opts...)
1281 if err != nil {
1282 return nil, "", err
1283 }
1284
1285 it.Response = resp
1286 return resp.GetOperations(), resp.GetNextPageToken(), nil
1287 }
1288 fetch := func(pageSize int, pageToken string) (string, error) {
1289 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1290 if err != nil {
1291 return "", err
1292 }
1293 it.items = append(it.items, items...)
1294 return nextPageToken, nil
1295 }
1296
1297 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1298 it.pageInfo.MaxSize = int(req.GetPageSize())
1299 it.pageInfo.Token = req.GetPageToken()
1300
1301 return it
1302 }
1303
1304 // ListClusters lists Clusters in a given project and location.
1305 func (c *streamsRESTClient) ListClusters(ctx context.Context, req *visionaipb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator {
1306 it := &ClusterIterator{}
1307 req = proto.Clone(req).(*visionaipb.ListClustersRequest)
1308 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1309 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Cluster, string, error) {
1310 resp := &visionaipb.ListClustersResponse{}
1311 if pageToken != "" {
1312 req.PageToken = pageToken
1313 }
1314 if pageSize > math.MaxInt32 {
1315 req.PageSize = math.MaxInt32
1316 } else if pageSize != 0 {
1317 req.PageSize = int32(pageSize)
1318 }
1319 baseUrl, err := url.Parse(c.endpoint)
1320 if err != nil {
1321 return nil, "", err
1322 }
1323 baseUrl.Path += fmt.Sprintf("/v1/%v/clusters", req.GetParent())
1324
1325 params := url.Values{}
1326 params.Add("$alt", "json;enum-encoding=int")
1327 if req.GetFilter() != "" {
1328 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1329 }
1330 if req.GetOrderBy() != "" {
1331 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1332 }
1333 if req.GetPageSize() != 0 {
1334 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1335 }
1336 if req.GetPageToken() != "" {
1337 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1338 }
1339
1340 baseUrl.RawQuery = params.Encode()
1341
1342 // Build HTTP headers from client and context metadata.
1343 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1344 headers := gax.BuildHeaders(ctx, hds...)
1345 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1346 if settings.Path != "" {
1347 baseUrl.Path = settings.Path
1348 }
1349 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1350 if err != nil {
1351 return err
1352 }
1353 httpReq.Header = headers
1354
1355 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListClusters")
1356 if err != nil {
1357 return err
1358 }
1359 if err := unm.Unmarshal(buf, resp); err != nil {
1360 return err
1361 }
1362
1363 return nil
1364 }, opts...)
1365 if e != nil {
1366 return nil, "", e
1367 }
1368 it.Response = resp
1369 return resp.GetClusters(), resp.GetNextPageToken(), nil
1370 }
1371
1372 fetch := func(pageSize int, pageToken string) (string, error) {
1373 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1374 if err != nil {
1375 return "", err
1376 }
1377 it.items = append(it.items, items...)
1378 return nextPageToken, nil
1379 }
1380
1381 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1382 it.pageInfo.MaxSize = int(req.GetPageSize())
1383 it.pageInfo.Token = req.GetPageToken()
1384
1385 return it
1386 }
1387
1388 // GetCluster gets details of a single Cluster.
1389 func (c *streamsRESTClient) GetCluster(ctx context.Context, req *visionaipb.GetClusterRequest, opts ...gax.CallOption) (*visionaipb.Cluster, error) {
1390 baseUrl, err := url.Parse(c.endpoint)
1391 if err != nil {
1392 return nil, err
1393 }
1394 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1395
1396 params := url.Values{}
1397 params.Add("$alt", "json;enum-encoding=int")
1398
1399 baseUrl.RawQuery = params.Encode()
1400
1401 // Build HTTP headers from client and context metadata.
1402 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1403
1404 hds = append(c.xGoogHeaders, hds...)
1405 hds = append(hds, "Content-Type", "application/json")
1406 headers := gax.BuildHeaders(ctx, hds...)
1407 opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...)
1408 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1409 resp := &visionaipb.Cluster{}
1410 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1411 if settings.Path != "" {
1412 baseUrl.Path = settings.Path
1413 }
1414 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1415 if err != nil {
1416 return err
1417 }
1418 httpReq = httpReq.WithContext(ctx)
1419 httpReq.Header = headers
1420
1421 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCluster")
1422 if err != nil {
1423 return err
1424 }
1425
1426 if err := unm.Unmarshal(buf, resp); err != nil {
1427 return err
1428 }
1429
1430 return nil
1431 }, opts...)
1432 if e != nil {
1433 return nil, e
1434 }
1435 return resp, nil
1436 }
1437
1438 // CreateCluster creates a new Cluster in a given project and location.
1439 func (c *streamsRESTClient) CreateCluster(ctx context.Context, req *visionaipb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) {
1440 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1441 body := req.GetCluster()
1442 jsonReq, err := m.Marshal(body)
1443 if err != nil {
1444 return nil, err
1445 }
1446
1447 baseUrl, err := url.Parse(c.endpoint)
1448 if err != nil {
1449 return nil, err
1450 }
1451 baseUrl.Path += fmt.Sprintf("/v1/%v/clusters", req.GetParent())
1452
1453 params := url.Values{}
1454 params.Add("$alt", "json;enum-encoding=int")
1455 params.Add("clusterId", fmt.Sprintf("%v", req.GetClusterId()))
1456 if req.GetRequestId() != "" {
1457 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1458 }
1459
1460 baseUrl.RawQuery = params.Encode()
1461
1462 // Build HTTP headers from client and context metadata.
1463 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1464
1465 hds = append(c.xGoogHeaders, hds...)
1466 hds = append(hds, "Content-Type", "application/json")
1467 headers := gax.BuildHeaders(ctx, hds...)
1468 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1469 resp := &longrunningpb.Operation{}
1470 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1471 if settings.Path != "" {
1472 baseUrl.Path = settings.Path
1473 }
1474 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1475 if err != nil {
1476 return err
1477 }
1478 httpReq = httpReq.WithContext(ctx)
1479 httpReq.Header = headers
1480
1481 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCluster")
1482 if err != nil {
1483 return err
1484 }
1485 if err := unm.Unmarshal(buf, resp); err != nil {
1486 return err
1487 }
1488
1489 return nil
1490 }, opts...)
1491 if e != nil {
1492 return nil, e
1493 }
1494
1495 override := fmt.Sprintf("/v1/%s", resp.GetName())
1496 return &CreateClusterOperation{
1497 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1498 pollPath: override,
1499 }, nil
1500 }
1501
1502 // UpdateCluster updates the parameters of a single Cluster.
1503 func (c *streamsRESTClient) UpdateCluster(ctx context.Context, req *visionaipb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) {
1504 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1505 body := req.GetCluster()
1506 jsonReq, err := m.Marshal(body)
1507 if err != nil {
1508 return nil, err
1509 }
1510
1511 baseUrl, err := url.Parse(c.endpoint)
1512 if err != nil {
1513 return nil, err
1514 }
1515 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetCluster().GetName())
1516
1517 params := url.Values{}
1518 params.Add("$alt", "json;enum-encoding=int")
1519 if req.GetRequestId() != "" {
1520 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1521 }
1522 if req.GetUpdateMask() != nil {
1523 field, err := protojson.Marshal(req.GetUpdateMask())
1524 if err != nil {
1525 return nil, err
1526 }
1527 params.Add("updateMask", string(field[1:len(field)-1]))
1528 }
1529
1530 baseUrl.RawQuery = params.Encode()
1531
1532 // Build HTTP headers from client and context metadata.
1533 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "cluster.name", url.QueryEscape(req.GetCluster().GetName()))}
1534
1535 hds = append(c.xGoogHeaders, hds...)
1536 hds = append(hds, "Content-Type", "application/json")
1537 headers := gax.BuildHeaders(ctx, hds...)
1538 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1539 resp := &longrunningpb.Operation{}
1540 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1541 if settings.Path != "" {
1542 baseUrl.Path = settings.Path
1543 }
1544 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1545 if err != nil {
1546 return err
1547 }
1548 httpReq = httpReq.WithContext(ctx)
1549 httpReq.Header = headers
1550
1551 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateCluster")
1552 if err != nil {
1553 return err
1554 }
1555 if err := unm.Unmarshal(buf, resp); err != nil {
1556 return err
1557 }
1558
1559 return nil
1560 }, opts...)
1561 if e != nil {
1562 return nil, e
1563 }
1564
1565 override := fmt.Sprintf("/v1/%s", resp.GetName())
1566 return &UpdateClusterOperation{
1567 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1568 pollPath: override,
1569 }, nil
1570 }
1571
1572 // DeleteCluster deletes a single Cluster.
1573 func (c *streamsRESTClient) DeleteCluster(ctx context.Context, req *visionaipb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) {
1574 baseUrl, err := url.Parse(c.endpoint)
1575 if err != nil {
1576 return nil, err
1577 }
1578 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1579
1580 params := url.Values{}
1581 params.Add("$alt", "json;enum-encoding=int")
1582 if req.GetRequestId() != "" {
1583 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1584 }
1585
1586 baseUrl.RawQuery = params.Encode()
1587
1588 // Build HTTP headers from client and context metadata.
1589 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1590
1591 hds = append(c.xGoogHeaders, hds...)
1592 hds = append(hds, "Content-Type", "application/json")
1593 headers := gax.BuildHeaders(ctx, hds...)
1594 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1595 resp := &longrunningpb.Operation{}
1596 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1597 if settings.Path != "" {
1598 baseUrl.Path = settings.Path
1599 }
1600 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1601 if err != nil {
1602 return err
1603 }
1604 httpReq = httpReq.WithContext(ctx)
1605 httpReq.Header = headers
1606
1607 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCluster")
1608 if err != nil {
1609 return err
1610 }
1611 if err := unm.Unmarshal(buf, resp); err != nil {
1612 return err
1613 }
1614
1615 return nil
1616 }, opts...)
1617 if e != nil {
1618 return nil, e
1619 }
1620
1621 override := fmt.Sprintf("/v1/%s", resp.GetName())
1622 return &DeleteClusterOperation{
1623 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1624 pollPath: override,
1625 }, nil
1626 }
1627
1628 // ListStreams lists Streams in a given project and location.
1629 func (c *streamsRESTClient) ListStreams(ctx context.Context, req *visionaipb.ListStreamsRequest, opts ...gax.CallOption) *StreamIterator {
1630 it := &StreamIterator{}
1631 req = proto.Clone(req).(*visionaipb.ListStreamsRequest)
1632 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1633 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Stream, string, error) {
1634 resp := &visionaipb.ListStreamsResponse{}
1635 if pageToken != "" {
1636 req.PageToken = pageToken
1637 }
1638 if pageSize > math.MaxInt32 {
1639 req.PageSize = math.MaxInt32
1640 } else if pageSize != 0 {
1641 req.PageSize = int32(pageSize)
1642 }
1643 baseUrl, err := url.Parse(c.endpoint)
1644 if err != nil {
1645 return nil, "", err
1646 }
1647 baseUrl.Path += fmt.Sprintf("/v1/%v/streams", req.GetParent())
1648
1649 params := url.Values{}
1650 params.Add("$alt", "json;enum-encoding=int")
1651 if req.GetFilter() != "" {
1652 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1653 }
1654 if req.GetOrderBy() != "" {
1655 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1656 }
1657 if req.GetPageSize() != 0 {
1658 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1659 }
1660 if req.GetPageToken() != "" {
1661 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1662 }
1663
1664 baseUrl.RawQuery = params.Encode()
1665
1666 // Build HTTP headers from client and context metadata.
1667 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1668 headers := gax.BuildHeaders(ctx, hds...)
1669 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1670 if settings.Path != "" {
1671 baseUrl.Path = settings.Path
1672 }
1673 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1674 if err != nil {
1675 return err
1676 }
1677 httpReq.Header = headers
1678
1679 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListStreams")
1680 if err != nil {
1681 return err
1682 }
1683 if err := unm.Unmarshal(buf, resp); err != nil {
1684 return err
1685 }
1686
1687 return nil
1688 }, opts...)
1689 if e != nil {
1690 return nil, "", e
1691 }
1692 it.Response = resp
1693 return resp.GetStreams(), resp.GetNextPageToken(), nil
1694 }
1695
1696 fetch := func(pageSize int, pageToken string) (string, error) {
1697 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1698 if err != nil {
1699 return "", err
1700 }
1701 it.items = append(it.items, items...)
1702 return nextPageToken, nil
1703 }
1704
1705 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1706 it.pageInfo.MaxSize = int(req.GetPageSize())
1707 it.pageInfo.Token = req.GetPageToken()
1708
1709 return it
1710 }
1711
1712 // GetStream gets details of a single Stream.
1713 func (c *streamsRESTClient) GetStream(ctx context.Context, req *visionaipb.GetStreamRequest, opts ...gax.CallOption) (*visionaipb.Stream, error) {
1714 baseUrl, err := url.Parse(c.endpoint)
1715 if err != nil {
1716 return nil, err
1717 }
1718 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1719
1720 params := url.Values{}
1721 params.Add("$alt", "json;enum-encoding=int")
1722
1723 baseUrl.RawQuery = params.Encode()
1724
1725 // Build HTTP headers from client and context metadata.
1726 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1727
1728 hds = append(c.xGoogHeaders, hds...)
1729 hds = append(hds, "Content-Type", "application/json")
1730 headers := gax.BuildHeaders(ctx, hds...)
1731 opts = append((*c.CallOptions).GetStream[0:len((*c.CallOptions).GetStream):len((*c.CallOptions).GetStream)], opts...)
1732 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1733 resp := &visionaipb.Stream{}
1734 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1735 if settings.Path != "" {
1736 baseUrl.Path = settings.Path
1737 }
1738 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1739 if err != nil {
1740 return err
1741 }
1742 httpReq = httpReq.WithContext(ctx)
1743 httpReq.Header = headers
1744
1745 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetStream")
1746 if err != nil {
1747 return err
1748 }
1749
1750 if err := unm.Unmarshal(buf, resp); err != nil {
1751 return err
1752 }
1753
1754 return nil
1755 }, opts...)
1756 if e != nil {
1757 return nil, e
1758 }
1759 return resp, nil
1760 }
1761
1762 // CreateStream creates a new Stream in a given project and location.
1763 func (c *streamsRESTClient) CreateStream(ctx context.Context, req *visionaipb.CreateStreamRequest, opts ...gax.CallOption) (*CreateStreamOperation, error) {
1764 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1765 body := req.GetStream()
1766 jsonReq, err := m.Marshal(body)
1767 if err != nil {
1768 return nil, err
1769 }
1770
1771 baseUrl, err := url.Parse(c.endpoint)
1772 if err != nil {
1773 return nil, err
1774 }
1775 baseUrl.Path += fmt.Sprintf("/v1/%v/streams", req.GetParent())
1776
1777 params := url.Values{}
1778 params.Add("$alt", "json;enum-encoding=int")
1779 if req.GetRequestId() != "" {
1780 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1781 }
1782 params.Add("streamId", fmt.Sprintf("%v", req.GetStreamId()))
1783
1784 baseUrl.RawQuery = params.Encode()
1785
1786 // Build HTTP headers from client and context metadata.
1787 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1788
1789 hds = append(c.xGoogHeaders, hds...)
1790 hds = append(hds, "Content-Type", "application/json")
1791 headers := gax.BuildHeaders(ctx, hds...)
1792 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1793 resp := &longrunningpb.Operation{}
1794 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1795 if settings.Path != "" {
1796 baseUrl.Path = settings.Path
1797 }
1798 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1799 if err != nil {
1800 return err
1801 }
1802 httpReq = httpReq.WithContext(ctx)
1803 httpReq.Header = headers
1804
1805 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateStream")
1806 if err != nil {
1807 return err
1808 }
1809 if err := unm.Unmarshal(buf, resp); err != nil {
1810 return err
1811 }
1812
1813 return nil
1814 }, opts...)
1815 if e != nil {
1816 return nil, e
1817 }
1818
1819 override := fmt.Sprintf("/v1/%s", resp.GetName())
1820 return &CreateStreamOperation{
1821 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1822 pollPath: override,
1823 }, nil
1824 }
1825
1826 // UpdateStream updates the parameters of a single Stream.
1827 func (c *streamsRESTClient) UpdateStream(ctx context.Context, req *visionaipb.UpdateStreamRequest, opts ...gax.CallOption) (*UpdateStreamOperation, error) {
1828 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1829 body := req.GetStream()
1830 jsonReq, err := m.Marshal(body)
1831 if err != nil {
1832 return nil, err
1833 }
1834
1835 baseUrl, err := url.Parse(c.endpoint)
1836 if err != nil {
1837 return nil, err
1838 }
1839 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetStream().GetName())
1840
1841 params := url.Values{}
1842 params.Add("$alt", "json;enum-encoding=int")
1843 if req.GetRequestId() != "" {
1844 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1845 }
1846 if req.GetUpdateMask() != nil {
1847 field, err := protojson.Marshal(req.GetUpdateMask())
1848 if err != nil {
1849 return nil, err
1850 }
1851 params.Add("updateMask", string(field[1:len(field)-1]))
1852 }
1853
1854 baseUrl.RawQuery = params.Encode()
1855
1856 // Build HTTP headers from client and context metadata.
1857 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream.name", url.QueryEscape(req.GetStream().GetName()))}
1858
1859 hds = append(c.xGoogHeaders, hds...)
1860 hds = append(hds, "Content-Type", "application/json")
1861 headers := gax.BuildHeaders(ctx, hds...)
1862 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1863 resp := &longrunningpb.Operation{}
1864 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1865 if settings.Path != "" {
1866 baseUrl.Path = settings.Path
1867 }
1868 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1869 if err != nil {
1870 return err
1871 }
1872 httpReq = httpReq.WithContext(ctx)
1873 httpReq.Header = headers
1874
1875 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateStream")
1876 if err != nil {
1877 return err
1878 }
1879 if err := unm.Unmarshal(buf, resp); err != nil {
1880 return err
1881 }
1882
1883 return nil
1884 }, opts...)
1885 if e != nil {
1886 return nil, e
1887 }
1888
1889 override := fmt.Sprintf("/v1/%s", resp.GetName())
1890 return &UpdateStreamOperation{
1891 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1892 pollPath: override,
1893 }, nil
1894 }
1895
1896 // DeleteStream deletes a single Stream.
1897 func (c *streamsRESTClient) DeleteStream(ctx context.Context, req *visionaipb.DeleteStreamRequest, opts ...gax.CallOption) (*DeleteStreamOperation, error) {
1898 baseUrl, err := url.Parse(c.endpoint)
1899 if err != nil {
1900 return nil, err
1901 }
1902 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1903
1904 params := url.Values{}
1905 params.Add("$alt", "json;enum-encoding=int")
1906 if req.GetRequestId() != "" {
1907 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1908 }
1909
1910 baseUrl.RawQuery = params.Encode()
1911
1912 // Build HTTP headers from client and context metadata.
1913 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1914
1915 hds = append(c.xGoogHeaders, hds...)
1916 hds = append(hds, "Content-Type", "application/json")
1917 headers := gax.BuildHeaders(ctx, hds...)
1918 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1919 resp := &longrunningpb.Operation{}
1920 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1921 if settings.Path != "" {
1922 baseUrl.Path = settings.Path
1923 }
1924 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1925 if err != nil {
1926 return err
1927 }
1928 httpReq = httpReq.WithContext(ctx)
1929 httpReq.Header = headers
1930
1931 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteStream")
1932 if err != nil {
1933 return err
1934 }
1935 if err := unm.Unmarshal(buf, resp); err != nil {
1936 return err
1937 }
1938
1939 return nil
1940 }, opts...)
1941 if e != nil {
1942 return nil, e
1943 }
1944
1945 override := fmt.Sprintf("/v1/%s", resp.GetName())
1946 return &DeleteStreamOperation{
1947 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1948 pollPath: override,
1949 }, nil
1950 }
1951
1952 // GetStreamThumbnail gets the thumbnail (image snapshot) of a single Stream.
1953 func (c *streamsRESTClient) GetStreamThumbnail(ctx context.Context, req *visionaipb.GetStreamThumbnailRequest, opts ...gax.CallOption) (*GetStreamThumbnailOperation, error) {
1954 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1955 jsonReq, err := m.Marshal(req)
1956 if err != nil {
1957 return nil, err
1958 }
1959
1960 baseUrl, err := url.Parse(c.endpoint)
1961 if err != nil {
1962 return nil, err
1963 }
1964 baseUrl.Path += fmt.Sprintf("/v1/%v:getThumbnail", req.GetStream())
1965
1966 params := url.Values{}
1967 params.Add("$alt", "json;enum-encoding=int")
1968
1969 baseUrl.RawQuery = params.Encode()
1970
1971 // Build HTTP headers from client and context metadata.
1972 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream", url.QueryEscape(req.GetStream()))}
1973
1974 hds = append(c.xGoogHeaders, hds...)
1975 hds = append(hds, "Content-Type", "application/json")
1976 headers := gax.BuildHeaders(ctx, hds...)
1977 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1978 resp := &longrunningpb.Operation{}
1979 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1980 if settings.Path != "" {
1981 baseUrl.Path = settings.Path
1982 }
1983 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1984 if err != nil {
1985 return err
1986 }
1987 httpReq = httpReq.WithContext(ctx)
1988 httpReq.Header = headers
1989
1990 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetStreamThumbnail")
1991 if err != nil {
1992 return err
1993 }
1994 if err := unm.Unmarshal(buf, resp); err != nil {
1995 return err
1996 }
1997
1998 return nil
1999 }, opts...)
2000 if e != nil {
2001 return nil, e
2002 }
2003
2004 override := fmt.Sprintf("/v1/%s", resp.GetName())
2005 return &GetStreamThumbnailOperation{
2006 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2007 pollPath: override,
2008 }, nil
2009 }
2010
2011 // GenerateStreamHlsToken generate the JWT auth token required to get the stream HLS contents.
2012 func (c *streamsRESTClient) GenerateStreamHlsToken(ctx context.Context, req *visionaipb.GenerateStreamHlsTokenRequest, opts ...gax.CallOption) (*visionaipb.GenerateStreamHlsTokenResponse, error) {
2013 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2014 jsonReq, err := m.Marshal(req)
2015 if err != nil {
2016 return nil, err
2017 }
2018
2019 baseUrl, err := url.Parse(c.endpoint)
2020 if err != nil {
2021 return nil, err
2022 }
2023 baseUrl.Path += fmt.Sprintf("/v1/%v:generateStreamHlsToken", req.GetStream())
2024
2025 params := url.Values{}
2026 params.Add("$alt", "json;enum-encoding=int")
2027
2028 baseUrl.RawQuery = params.Encode()
2029
2030 // Build HTTP headers from client and context metadata.
2031 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "stream", url.QueryEscape(req.GetStream()))}
2032
2033 hds = append(c.xGoogHeaders, hds...)
2034 hds = append(hds, "Content-Type", "application/json")
2035 headers := gax.BuildHeaders(ctx, hds...)
2036 opts = append((*c.CallOptions).GenerateStreamHlsToken[0:len((*c.CallOptions).GenerateStreamHlsToken):len((*c.CallOptions).GenerateStreamHlsToken)], opts...)
2037 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2038 resp := &visionaipb.GenerateStreamHlsTokenResponse{}
2039 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2040 if settings.Path != "" {
2041 baseUrl.Path = settings.Path
2042 }
2043 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2044 if err != nil {
2045 return err
2046 }
2047 httpReq = httpReq.WithContext(ctx)
2048 httpReq.Header = headers
2049
2050 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateStreamHlsToken")
2051 if err != nil {
2052 return err
2053 }
2054
2055 if err := unm.Unmarshal(buf, resp); err != nil {
2056 return err
2057 }
2058
2059 return nil
2060 }, opts...)
2061 if e != nil {
2062 return nil, e
2063 }
2064 return resp, nil
2065 }
2066
2067 // ListEvents lists Events in a given project and location.
2068 func (c *streamsRESTClient) ListEvents(ctx context.Context, req *visionaipb.ListEventsRequest, opts ...gax.CallOption) *EventIterator {
2069 it := &EventIterator{}
2070 req = proto.Clone(req).(*visionaipb.ListEventsRequest)
2071 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2072 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Event, string, error) {
2073 resp := &visionaipb.ListEventsResponse{}
2074 if pageToken != "" {
2075 req.PageToken = pageToken
2076 }
2077 if pageSize > math.MaxInt32 {
2078 req.PageSize = math.MaxInt32
2079 } else if pageSize != 0 {
2080 req.PageSize = int32(pageSize)
2081 }
2082 baseUrl, err := url.Parse(c.endpoint)
2083 if err != nil {
2084 return nil, "", err
2085 }
2086 baseUrl.Path += fmt.Sprintf("/v1/%v/events", req.GetParent())
2087
2088 params := url.Values{}
2089 params.Add("$alt", "json;enum-encoding=int")
2090 if req.GetFilter() != "" {
2091 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2092 }
2093 if req.GetOrderBy() != "" {
2094 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2095 }
2096 if req.GetPageSize() != 0 {
2097 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2098 }
2099 if req.GetPageToken() != "" {
2100 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2101 }
2102
2103 baseUrl.RawQuery = params.Encode()
2104
2105 // Build HTTP headers from client and context metadata.
2106 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2107 headers := gax.BuildHeaders(ctx, hds...)
2108 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2109 if settings.Path != "" {
2110 baseUrl.Path = settings.Path
2111 }
2112 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2113 if err != nil {
2114 return err
2115 }
2116 httpReq.Header = headers
2117
2118 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListEvents")
2119 if err != nil {
2120 return err
2121 }
2122 if err := unm.Unmarshal(buf, resp); err != nil {
2123 return err
2124 }
2125
2126 return nil
2127 }, opts...)
2128 if e != nil {
2129 return nil, "", e
2130 }
2131 it.Response = resp
2132 return resp.GetEvents(), resp.GetNextPageToken(), nil
2133 }
2134
2135 fetch := func(pageSize int, pageToken string) (string, error) {
2136 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2137 if err != nil {
2138 return "", err
2139 }
2140 it.items = append(it.items, items...)
2141 return nextPageToken, nil
2142 }
2143
2144 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2145 it.pageInfo.MaxSize = int(req.GetPageSize())
2146 it.pageInfo.Token = req.GetPageToken()
2147
2148 return it
2149 }
2150
2151 // GetEvent gets details of a single Event.
2152 func (c *streamsRESTClient) GetEvent(ctx context.Context, req *visionaipb.GetEventRequest, opts ...gax.CallOption) (*visionaipb.Event, error) {
2153 baseUrl, err := url.Parse(c.endpoint)
2154 if err != nil {
2155 return nil, err
2156 }
2157 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2158
2159 params := url.Values{}
2160 params.Add("$alt", "json;enum-encoding=int")
2161
2162 baseUrl.RawQuery = params.Encode()
2163
2164 // Build HTTP headers from client and context metadata.
2165 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2166
2167 hds = append(c.xGoogHeaders, hds...)
2168 hds = append(hds, "Content-Type", "application/json")
2169 headers := gax.BuildHeaders(ctx, hds...)
2170 opts = append((*c.CallOptions).GetEvent[0:len((*c.CallOptions).GetEvent):len((*c.CallOptions).GetEvent)], opts...)
2171 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2172 resp := &visionaipb.Event{}
2173 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2174 if settings.Path != "" {
2175 baseUrl.Path = settings.Path
2176 }
2177 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2178 if err != nil {
2179 return err
2180 }
2181 httpReq = httpReq.WithContext(ctx)
2182 httpReq.Header = headers
2183
2184 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetEvent")
2185 if err != nil {
2186 return err
2187 }
2188
2189 if err := unm.Unmarshal(buf, resp); err != nil {
2190 return err
2191 }
2192
2193 return nil
2194 }, opts...)
2195 if e != nil {
2196 return nil, e
2197 }
2198 return resp, nil
2199 }
2200
2201 // CreateEvent creates a new Event in a given project and location.
2202 func (c *streamsRESTClient) CreateEvent(ctx context.Context, req *visionaipb.CreateEventRequest, opts ...gax.CallOption) (*CreateEventOperation, error) {
2203 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2204 body := req.GetEvent()
2205 jsonReq, err := m.Marshal(body)
2206 if err != nil {
2207 return nil, err
2208 }
2209
2210 baseUrl, err := url.Parse(c.endpoint)
2211 if err != nil {
2212 return nil, err
2213 }
2214 baseUrl.Path += fmt.Sprintf("/v1/%v/events", req.GetParent())
2215
2216 params := url.Values{}
2217 params.Add("$alt", "json;enum-encoding=int")
2218 params.Add("eventId", fmt.Sprintf("%v", req.GetEventId()))
2219 if req.GetRequestId() != "" {
2220 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2221 }
2222
2223 baseUrl.RawQuery = params.Encode()
2224
2225 // Build HTTP headers from client and context metadata.
2226 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2227
2228 hds = append(c.xGoogHeaders, hds...)
2229 hds = append(hds, "Content-Type", "application/json")
2230 headers := gax.BuildHeaders(ctx, hds...)
2231 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2232 resp := &longrunningpb.Operation{}
2233 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2234 if settings.Path != "" {
2235 baseUrl.Path = settings.Path
2236 }
2237 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2238 if err != nil {
2239 return err
2240 }
2241 httpReq = httpReq.WithContext(ctx)
2242 httpReq.Header = headers
2243
2244 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateEvent")
2245 if err != nil {
2246 return err
2247 }
2248 if err := unm.Unmarshal(buf, resp); err != nil {
2249 return err
2250 }
2251
2252 return nil
2253 }, opts...)
2254 if e != nil {
2255 return nil, e
2256 }
2257
2258 override := fmt.Sprintf("/v1/%s", resp.GetName())
2259 return &CreateEventOperation{
2260 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2261 pollPath: override,
2262 }, nil
2263 }
2264
2265 // UpdateEvent updates the parameters of a single Event.
2266 func (c *streamsRESTClient) UpdateEvent(ctx context.Context, req *visionaipb.UpdateEventRequest, opts ...gax.CallOption) (*UpdateEventOperation, error) {
2267 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2268 body := req.GetEvent()
2269 jsonReq, err := m.Marshal(body)
2270 if err != nil {
2271 return nil, err
2272 }
2273
2274 baseUrl, err := url.Parse(c.endpoint)
2275 if err != nil {
2276 return nil, err
2277 }
2278 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetEvent().GetName())
2279
2280 params := url.Values{}
2281 params.Add("$alt", "json;enum-encoding=int")
2282 if req.GetRequestId() != "" {
2283 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2284 }
2285 if req.GetUpdateMask() != nil {
2286 field, err := protojson.Marshal(req.GetUpdateMask())
2287 if err != nil {
2288 return nil, err
2289 }
2290 params.Add("updateMask", string(field[1:len(field)-1]))
2291 }
2292
2293 baseUrl.RawQuery = params.Encode()
2294
2295 // Build HTTP headers from client and context metadata.
2296 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "event.name", url.QueryEscape(req.GetEvent().GetName()))}
2297
2298 hds = append(c.xGoogHeaders, hds...)
2299 hds = append(hds, "Content-Type", "application/json")
2300 headers := gax.BuildHeaders(ctx, hds...)
2301 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2302 resp := &longrunningpb.Operation{}
2303 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2304 if settings.Path != "" {
2305 baseUrl.Path = settings.Path
2306 }
2307 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2308 if err != nil {
2309 return err
2310 }
2311 httpReq = httpReq.WithContext(ctx)
2312 httpReq.Header = headers
2313
2314 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateEvent")
2315 if err != nil {
2316 return err
2317 }
2318 if err := unm.Unmarshal(buf, resp); err != nil {
2319 return err
2320 }
2321
2322 return nil
2323 }, opts...)
2324 if e != nil {
2325 return nil, e
2326 }
2327
2328 override := fmt.Sprintf("/v1/%s", resp.GetName())
2329 return &UpdateEventOperation{
2330 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2331 pollPath: override,
2332 }, nil
2333 }
2334
2335 // DeleteEvent deletes a single Event.
2336 func (c *streamsRESTClient) DeleteEvent(ctx context.Context, req *visionaipb.DeleteEventRequest, opts ...gax.CallOption) (*DeleteEventOperation, error) {
2337 baseUrl, err := url.Parse(c.endpoint)
2338 if err != nil {
2339 return nil, err
2340 }
2341 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2342
2343 params := url.Values{}
2344 params.Add("$alt", "json;enum-encoding=int")
2345 if req.GetRequestId() != "" {
2346 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2347 }
2348
2349 baseUrl.RawQuery = params.Encode()
2350
2351 // Build HTTP headers from client and context metadata.
2352 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2353
2354 hds = append(c.xGoogHeaders, hds...)
2355 hds = append(hds, "Content-Type", "application/json")
2356 headers := gax.BuildHeaders(ctx, hds...)
2357 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2358 resp := &longrunningpb.Operation{}
2359 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2360 if settings.Path != "" {
2361 baseUrl.Path = settings.Path
2362 }
2363 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2364 if err != nil {
2365 return err
2366 }
2367 httpReq = httpReq.WithContext(ctx)
2368 httpReq.Header = headers
2369
2370 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteEvent")
2371 if err != nil {
2372 return err
2373 }
2374 if err := unm.Unmarshal(buf, resp); err != nil {
2375 return err
2376 }
2377
2378 return nil
2379 }, opts...)
2380 if e != nil {
2381 return nil, e
2382 }
2383
2384 override := fmt.Sprintf("/v1/%s", resp.GetName())
2385 return &DeleteEventOperation{
2386 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2387 pollPath: override,
2388 }, nil
2389 }
2390
2391 // ListSeries lists Series in a given project and location.
2392 func (c *streamsRESTClient) ListSeries(ctx context.Context, req *visionaipb.ListSeriesRequest, opts ...gax.CallOption) *SeriesIterator {
2393 it := &SeriesIterator{}
2394 req = proto.Clone(req).(*visionaipb.ListSeriesRequest)
2395 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2396 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Series, string, error) {
2397 resp := &visionaipb.ListSeriesResponse{}
2398 if pageToken != "" {
2399 req.PageToken = pageToken
2400 }
2401 if pageSize > math.MaxInt32 {
2402 req.PageSize = math.MaxInt32
2403 } else if pageSize != 0 {
2404 req.PageSize = int32(pageSize)
2405 }
2406 baseUrl, err := url.Parse(c.endpoint)
2407 if err != nil {
2408 return nil, "", err
2409 }
2410 baseUrl.Path += fmt.Sprintf("/v1/%v/series", req.GetParent())
2411
2412 params := url.Values{}
2413 params.Add("$alt", "json;enum-encoding=int")
2414 if req.GetFilter() != "" {
2415 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2416 }
2417 if req.GetOrderBy() != "" {
2418 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2419 }
2420 if req.GetPageSize() != 0 {
2421 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2422 }
2423 if req.GetPageToken() != "" {
2424 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2425 }
2426
2427 baseUrl.RawQuery = params.Encode()
2428
2429 // Build HTTP headers from client and context metadata.
2430 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2431 headers := gax.BuildHeaders(ctx, hds...)
2432 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2433 if settings.Path != "" {
2434 baseUrl.Path = settings.Path
2435 }
2436 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2437 if err != nil {
2438 return err
2439 }
2440 httpReq.Header = headers
2441
2442 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSeries")
2443 if err != nil {
2444 return err
2445 }
2446 if err := unm.Unmarshal(buf, resp); err != nil {
2447 return err
2448 }
2449
2450 return nil
2451 }, opts...)
2452 if e != nil {
2453 return nil, "", e
2454 }
2455 it.Response = resp
2456 return resp.GetSeries(), resp.GetNextPageToken(), nil
2457 }
2458
2459 fetch := func(pageSize int, pageToken string) (string, error) {
2460 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2461 if err != nil {
2462 return "", err
2463 }
2464 it.items = append(it.items, items...)
2465 return nextPageToken, nil
2466 }
2467
2468 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2469 it.pageInfo.MaxSize = int(req.GetPageSize())
2470 it.pageInfo.Token = req.GetPageToken()
2471
2472 return it
2473 }
2474
2475 // GetSeries gets details of a single Series.
2476 func (c *streamsRESTClient) GetSeries(ctx context.Context, req *visionaipb.GetSeriesRequest, opts ...gax.CallOption) (*visionaipb.Series, error) {
2477 baseUrl, err := url.Parse(c.endpoint)
2478 if err != nil {
2479 return nil, err
2480 }
2481 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2482
2483 params := url.Values{}
2484 params.Add("$alt", "json;enum-encoding=int")
2485
2486 baseUrl.RawQuery = params.Encode()
2487
2488 // Build HTTP headers from client and context metadata.
2489 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2490
2491 hds = append(c.xGoogHeaders, hds...)
2492 hds = append(hds, "Content-Type", "application/json")
2493 headers := gax.BuildHeaders(ctx, hds...)
2494 opts = append((*c.CallOptions).GetSeries[0:len((*c.CallOptions).GetSeries):len((*c.CallOptions).GetSeries)], opts...)
2495 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2496 resp := &visionaipb.Series{}
2497 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2498 if settings.Path != "" {
2499 baseUrl.Path = settings.Path
2500 }
2501 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2502 if err != nil {
2503 return err
2504 }
2505 httpReq = httpReq.WithContext(ctx)
2506 httpReq.Header = headers
2507
2508 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSeries")
2509 if err != nil {
2510 return err
2511 }
2512
2513 if err := unm.Unmarshal(buf, resp); err != nil {
2514 return err
2515 }
2516
2517 return nil
2518 }, opts...)
2519 if e != nil {
2520 return nil, e
2521 }
2522 return resp, nil
2523 }
2524
2525 // CreateSeries creates a new Series in a given project and location.
2526 func (c *streamsRESTClient) CreateSeries(ctx context.Context, req *visionaipb.CreateSeriesRequest, opts ...gax.CallOption) (*CreateSeriesOperation, error) {
2527 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2528 body := req.GetSeries()
2529 jsonReq, err := m.Marshal(body)
2530 if err != nil {
2531 return nil, err
2532 }
2533
2534 baseUrl, err := url.Parse(c.endpoint)
2535 if err != nil {
2536 return nil, err
2537 }
2538 baseUrl.Path += fmt.Sprintf("/v1/%v/series", req.GetParent())
2539
2540 params := url.Values{}
2541 params.Add("$alt", "json;enum-encoding=int")
2542 if req.GetRequestId() != "" {
2543 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2544 }
2545 params.Add("seriesId", fmt.Sprintf("%v", req.GetSeriesId()))
2546
2547 baseUrl.RawQuery = params.Encode()
2548
2549 // Build HTTP headers from client and context metadata.
2550 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2551
2552 hds = append(c.xGoogHeaders, hds...)
2553 hds = append(hds, "Content-Type", "application/json")
2554 headers := gax.BuildHeaders(ctx, hds...)
2555 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2556 resp := &longrunningpb.Operation{}
2557 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2558 if settings.Path != "" {
2559 baseUrl.Path = settings.Path
2560 }
2561 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2562 if err != nil {
2563 return err
2564 }
2565 httpReq = httpReq.WithContext(ctx)
2566 httpReq.Header = headers
2567
2568 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSeries")
2569 if err != nil {
2570 return err
2571 }
2572 if err := unm.Unmarshal(buf, resp); err != nil {
2573 return err
2574 }
2575
2576 return nil
2577 }, opts...)
2578 if e != nil {
2579 return nil, e
2580 }
2581
2582 override := fmt.Sprintf("/v1/%s", resp.GetName())
2583 return &CreateSeriesOperation{
2584 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2585 pollPath: override,
2586 }, nil
2587 }
2588
2589 // UpdateSeries updates the parameters of a single Event.
2590 func (c *streamsRESTClient) UpdateSeries(ctx context.Context, req *visionaipb.UpdateSeriesRequest, opts ...gax.CallOption) (*UpdateSeriesOperation, error) {
2591 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2592 body := req.GetSeries()
2593 jsonReq, err := m.Marshal(body)
2594 if err != nil {
2595 return nil, err
2596 }
2597
2598 baseUrl, err := url.Parse(c.endpoint)
2599 if err != nil {
2600 return nil, err
2601 }
2602 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetSeries().GetName())
2603
2604 params := url.Values{}
2605 params.Add("$alt", "json;enum-encoding=int")
2606 if req.GetRequestId() != "" {
2607 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2608 }
2609 if req.GetUpdateMask() != nil {
2610 field, err := protojson.Marshal(req.GetUpdateMask())
2611 if err != nil {
2612 return nil, err
2613 }
2614 params.Add("updateMask", string(field[1:len(field)-1]))
2615 }
2616
2617 baseUrl.RawQuery = params.Encode()
2618
2619 // Build HTTP headers from client and context metadata.
2620 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "series.name", url.QueryEscape(req.GetSeries().GetName()))}
2621
2622 hds = append(c.xGoogHeaders, hds...)
2623 hds = append(hds, "Content-Type", "application/json")
2624 headers := gax.BuildHeaders(ctx, hds...)
2625 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2626 resp := &longrunningpb.Operation{}
2627 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2628 if settings.Path != "" {
2629 baseUrl.Path = settings.Path
2630 }
2631 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2632 if err != nil {
2633 return err
2634 }
2635 httpReq = httpReq.WithContext(ctx)
2636 httpReq.Header = headers
2637
2638 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSeries")
2639 if err != nil {
2640 return err
2641 }
2642 if err := unm.Unmarshal(buf, resp); err != nil {
2643 return err
2644 }
2645
2646 return nil
2647 }, opts...)
2648 if e != nil {
2649 return nil, e
2650 }
2651
2652 override := fmt.Sprintf("/v1/%s", resp.GetName())
2653 return &UpdateSeriesOperation{
2654 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2655 pollPath: override,
2656 }, nil
2657 }
2658
2659 // DeleteSeries deletes a single Series.
2660 func (c *streamsRESTClient) DeleteSeries(ctx context.Context, req *visionaipb.DeleteSeriesRequest, opts ...gax.CallOption) (*DeleteSeriesOperation, error) {
2661 baseUrl, err := url.Parse(c.endpoint)
2662 if err != nil {
2663 return nil, err
2664 }
2665 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2666
2667 params := url.Values{}
2668 params.Add("$alt", "json;enum-encoding=int")
2669 if req.GetRequestId() != "" {
2670 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2671 }
2672
2673 baseUrl.RawQuery = params.Encode()
2674
2675 // Build HTTP headers from client and context metadata.
2676 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2677
2678 hds = append(c.xGoogHeaders, hds...)
2679 hds = append(hds, "Content-Type", "application/json")
2680 headers := gax.BuildHeaders(ctx, hds...)
2681 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2682 resp := &longrunningpb.Operation{}
2683 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2684 if settings.Path != "" {
2685 baseUrl.Path = settings.Path
2686 }
2687 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2688 if err != nil {
2689 return err
2690 }
2691 httpReq = httpReq.WithContext(ctx)
2692 httpReq.Header = headers
2693
2694 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSeries")
2695 if err != nil {
2696 return err
2697 }
2698 if err := unm.Unmarshal(buf, resp); err != nil {
2699 return err
2700 }
2701
2702 return nil
2703 }, opts...)
2704 if e != nil {
2705 return nil, e
2706 }
2707
2708 override := fmt.Sprintf("/v1/%s", resp.GetName())
2709 return &DeleteSeriesOperation{
2710 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2711 pollPath: override,
2712 }, nil
2713 }
2714
2715 // MaterializeChannel materialize a channel.
2716 func (c *streamsRESTClient) MaterializeChannel(ctx context.Context, req *visionaipb.MaterializeChannelRequest, opts ...gax.CallOption) (*MaterializeChannelOperation, error) {
2717 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2718 body := req.GetChannel()
2719 jsonReq, err := m.Marshal(body)
2720 if err != nil {
2721 return nil, err
2722 }
2723
2724 baseUrl, err := url.Parse(c.endpoint)
2725 if err != nil {
2726 return nil, err
2727 }
2728 baseUrl.Path += fmt.Sprintf("/v1/%v/channels", req.GetParent())
2729
2730 params := url.Values{}
2731 params.Add("$alt", "json;enum-encoding=int")
2732 params.Add("channelId", fmt.Sprintf("%v", req.GetChannelId()))
2733 if req.GetRequestId() != "" {
2734 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2735 }
2736
2737 baseUrl.RawQuery = params.Encode()
2738
2739 // Build HTTP headers from client and context metadata.
2740 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2741
2742 hds = append(c.xGoogHeaders, hds...)
2743 hds = append(hds, "Content-Type", "application/json")
2744 headers := gax.BuildHeaders(ctx, hds...)
2745 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2746 resp := &longrunningpb.Operation{}
2747 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2748 if settings.Path != "" {
2749 baseUrl.Path = settings.Path
2750 }
2751 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2752 if err != nil {
2753 return err
2754 }
2755 httpReq = httpReq.WithContext(ctx)
2756 httpReq.Header = headers
2757
2758 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "MaterializeChannel")
2759 if err != nil {
2760 return err
2761 }
2762 if err := unm.Unmarshal(buf, resp); err != nil {
2763 return err
2764 }
2765
2766 return nil
2767 }, opts...)
2768 if e != nil {
2769 return nil, e
2770 }
2771
2772 override := fmt.Sprintf("/v1/%s", resp.GetName())
2773 return &MaterializeChannelOperation{
2774 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2775 pollPath: override,
2776 }, nil
2777 }
2778
2779 // CancelOperation is a utility method from google.longrunning.Operations.
2780 func (c *streamsRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2781 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2782 jsonReq, err := m.Marshal(req)
2783 if err != nil {
2784 return err
2785 }
2786
2787 baseUrl, err := url.Parse(c.endpoint)
2788 if err != nil {
2789 return err
2790 }
2791 baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName())
2792
2793 params := url.Values{}
2794 params.Add("$alt", "json;enum-encoding=int")
2795
2796 baseUrl.RawQuery = params.Encode()
2797
2798 // Build HTTP headers from client and context metadata.
2799 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2800
2801 hds = append(c.xGoogHeaders, hds...)
2802 hds = append(hds, "Content-Type", "application/json")
2803 headers := gax.BuildHeaders(ctx, hds...)
2804 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2805 if settings.Path != "" {
2806 baseUrl.Path = settings.Path
2807 }
2808 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2809 if err != nil {
2810 return err
2811 }
2812 httpReq = httpReq.WithContext(ctx)
2813 httpReq.Header = headers
2814
2815 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
2816 return err
2817 }, opts...)
2818 }
2819
2820 // DeleteOperation is a utility method from google.longrunning.Operations.
2821 func (c *streamsRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
2822 baseUrl, err := url.Parse(c.endpoint)
2823 if err != nil {
2824 return err
2825 }
2826 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2827
2828 params := url.Values{}
2829 params.Add("$alt", "json;enum-encoding=int")
2830
2831 baseUrl.RawQuery = params.Encode()
2832
2833 // Build HTTP headers from client and context metadata.
2834 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2835
2836 hds = append(c.xGoogHeaders, hds...)
2837 hds = append(hds, "Content-Type", "application/json")
2838 headers := gax.BuildHeaders(ctx, hds...)
2839 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2840 if settings.Path != "" {
2841 baseUrl.Path = settings.Path
2842 }
2843 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2844 if err != nil {
2845 return err
2846 }
2847 httpReq = httpReq.WithContext(ctx)
2848 httpReq.Header = headers
2849
2850 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
2851 return err
2852 }, opts...)
2853 }
2854
2855 // GetOperation is a utility method from google.longrunning.Operations.
2856 func (c *streamsRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2857 baseUrl, err := url.Parse(c.endpoint)
2858 if err != nil {
2859 return nil, err
2860 }
2861 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2862
2863 params := url.Values{}
2864 params.Add("$alt", "json;enum-encoding=int")
2865
2866 baseUrl.RawQuery = params.Encode()
2867
2868 // Build HTTP headers from client and context metadata.
2869 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2870
2871 hds = append(c.xGoogHeaders, hds...)
2872 hds = append(hds, "Content-Type", "application/json")
2873 headers := gax.BuildHeaders(ctx, hds...)
2874 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2875 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2876 resp := &longrunningpb.Operation{}
2877 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2878 if settings.Path != "" {
2879 baseUrl.Path = settings.Path
2880 }
2881 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2882 if err != nil {
2883 return err
2884 }
2885 httpReq = httpReq.WithContext(ctx)
2886 httpReq.Header = headers
2887
2888 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
2889 if err != nil {
2890 return err
2891 }
2892
2893 if err := unm.Unmarshal(buf, resp); err != nil {
2894 return err
2895 }
2896
2897 return nil
2898 }, opts...)
2899 if e != nil {
2900 return nil, e
2901 }
2902 return resp, nil
2903 }
2904
2905 // ListOperations is a utility method from google.longrunning.Operations.
2906 func (c *streamsRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
2907 it := &OperationIterator{}
2908 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
2909 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2910 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
2911 resp := &longrunningpb.ListOperationsResponse{}
2912 if pageToken != "" {
2913 req.PageToken = pageToken
2914 }
2915 if pageSize > math.MaxInt32 {
2916 req.PageSize = math.MaxInt32
2917 } else if pageSize != 0 {
2918 req.PageSize = int32(pageSize)
2919 }
2920 baseUrl, err := url.Parse(c.endpoint)
2921 if err != nil {
2922 return nil, "", err
2923 }
2924 baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName())
2925
2926 params := url.Values{}
2927 params.Add("$alt", "json;enum-encoding=int")
2928 if req.GetFilter() != "" {
2929 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2930 }
2931 if req.GetPageSize() != 0 {
2932 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2933 }
2934 if req.GetPageToken() != "" {
2935 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2936 }
2937
2938 baseUrl.RawQuery = params.Encode()
2939
2940 // Build HTTP headers from client and context metadata.
2941 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2942 headers := gax.BuildHeaders(ctx, hds...)
2943 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2944 if settings.Path != "" {
2945 baseUrl.Path = settings.Path
2946 }
2947 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2948 if err != nil {
2949 return err
2950 }
2951 httpReq.Header = headers
2952
2953 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
2954 if err != nil {
2955 return err
2956 }
2957 if err := unm.Unmarshal(buf, resp); err != nil {
2958 return err
2959 }
2960
2961 return nil
2962 }, opts...)
2963 if e != nil {
2964 return nil, "", e
2965 }
2966 it.Response = resp
2967 return resp.GetOperations(), resp.GetNextPageToken(), nil
2968 }
2969
2970 fetch := func(pageSize int, pageToken string) (string, error) {
2971 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2972 if err != nil {
2973 return "", err
2974 }
2975 it.items = append(it.items, items...)
2976 return nextPageToken, nil
2977 }
2978
2979 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2980 it.pageInfo.MaxSize = int(req.GetPageSize())
2981 it.pageInfo.Token = req.GetPageToken()
2982
2983 return it
2984 }
2985
2986 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
2987 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
2988 func (c *streamsGRPCClient) CreateClusterOperation(name string) *CreateClusterOperation {
2989 return &CreateClusterOperation{
2990 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2991 }
2992 }
2993
2994 // CreateClusterOperation returns a new CreateClusterOperation from a given name.
2995 // The name must be that of a previously created CreateClusterOperation, possibly from a different process.
2996 func (c *streamsRESTClient) CreateClusterOperation(name string) *CreateClusterOperation {
2997 override := fmt.Sprintf("/v1/%s", name)
2998 return &CreateClusterOperation{
2999 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3000 pollPath: override,
3001 }
3002 }
3003
3004 // CreateEventOperation returns a new CreateEventOperation from a given name.
3005 // The name must be that of a previously created CreateEventOperation, possibly from a different process.
3006 func (c *streamsGRPCClient) CreateEventOperation(name string) *CreateEventOperation {
3007 return &CreateEventOperation{
3008 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3009 }
3010 }
3011
3012 // CreateEventOperation returns a new CreateEventOperation from a given name.
3013 // The name must be that of a previously created CreateEventOperation, possibly from a different process.
3014 func (c *streamsRESTClient) CreateEventOperation(name string) *CreateEventOperation {
3015 override := fmt.Sprintf("/v1/%s", name)
3016 return &CreateEventOperation{
3017 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3018 pollPath: override,
3019 }
3020 }
3021
3022 // CreateSeriesOperation returns a new CreateSeriesOperation from a given name.
3023 // The name must be that of a previously created CreateSeriesOperation, possibly from a different process.
3024 func (c *streamsGRPCClient) CreateSeriesOperation(name string) *CreateSeriesOperation {
3025 return &CreateSeriesOperation{
3026 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3027 }
3028 }
3029
3030 // CreateSeriesOperation returns a new CreateSeriesOperation from a given name.
3031 // The name must be that of a previously created CreateSeriesOperation, possibly from a different process.
3032 func (c *streamsRESTClient) CreateSeriesOperation(name string) *CreateSeriesOperation {
3033 override := fmt.Sprintf("/v1/%s", name)
3034 return &CreateSeriesOperation{
3035 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3036 pollPath: override,
3037 }
3038 }
3039
3040 // CreateStreamOperation returns a new CreateStreamOperation from a given name.
3041 // The name must be that of a previously created CreateStreamOperation, possibly from a different process.
3042 func (c *streamsGRPCClient) CreateStreamOperation(name string) *CreateStreamOperation {
3043 return &CreateStreamOperation{
3044 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3045 }
3046 }
3047
3048 // CreateStreamOperation returns a new CreateStreamOperation from a given name.
3049 // The name must be that of a previously created CreateStreamOperation, possibly from a different process.
3050 func (c *streamsRESTClient) CreateStreamOperation(name string) *CreateStreamOperation {
3051 override := fmt.Sprintf("/v1/%s", name)
3052 return &CreateStreamOperation{
3053 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3054 pollPath: override,
3055 }
3056 }
3057
3058 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
3059 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
3060 func (c *streamsGRPCClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
3061 return &DeleteClusterOperation{
3062 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3063 }
3064 }
3065
3066 // DeleteClusterOperation returns a new DeleteClusterOperation from a given name.
3067 // The name must be that of a previously created DeleteClusterOperation, possibly from a different process.
3068 func (c *streamsRESTClient) DeleteClusterOperation(name string) *DeleteClusterOperation {
3069 override := fmt.Sprintf("/v1/%s", name)
3070 return &DeleteClusterOperation{
3071 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3072 pollPath: override,
3073 }
3074 }
3075
3076 // DeleteEventOperation returns a new DeleteEventOperation from a given name.
3077 // The name must be that of a previously created DeleteEventOperation, possibly from a different process.
3078 func (c *streamsGRPCClient) DeleteEventOperation(name string) *DeleteEventOperation {
3079 return &DeleteEventOperation{
3080 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3081 }
3082 }
3083
3084 // DeleteEventOperation returns a new DeleteEventOperation from a given name.
3085 // The name must be that of a previously created DeleteEventOperation, possibly from a different process.
3086 func (c *streamsRESTClient) DeleteEventOperation(name string) *DeleteEventOperation {
3087 override := fmt.Sprintf("/v1/%s", name)
3088 return &DeleteEventOperation{
3089 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3090 pollPath: override,
3091 }
3092 }
3093
3094 // DeleteSeriesOperation returns a new DeleteSeriesOperation from a given name.
3095 // The name must be that of a previously created DeleteSeriesOperation, possibly from a different process.
3096 func (c *streamsGRPCClient) DeleteSeriesOperation(name string) *DeleteSeriesOperation {
3097 return &DeleteSeriesOperation{
3098 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3099 }
3100 }
3101
3102 // DeleteSeriesOperation returns a new DeleteSeriesOperation from a given name.
3103 // The name must be that of a previously created DeleteSeriesOperation, possibly from a different process.
3104 func (c *streamsRESTClient) DeleteSeriesOperation(name string) *DeleteSeriesOperation {
3105 override := fmt.Sprintf("/v1/%s", name)
3106 return &DeleteSeriesOperation{
3107 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3108 pollPath: override,
3109 }
3110 }
3111
3112 // DeleteStreamOperation returns a new DeleteStreamOperation from a given name.
3113 // The name must be that of a previously created DeleteStreamOperation, possibly from a different process.
3114 func (c *streamsGRPCClient) DeleteStreamOperation(name string) *DeleteStreamOperation {
3115 return &DeleteStreamOperation{
3116 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3117 }
3118 }
3119
3120 // DeleteStreamOperation returns a new DeleteStreamOperation from a given name.
3121 // The name must be that of a previously created DeleteStreamOperation, possibly from a different process.
3122 func (c *streamsRESTClient) DeleteStreamOperation(name string) *DeleteStreamOperation {
3123 override := fmt.Sprintf("/v1/%s", name)
3124 return &DeleteStreamOperation{
3125 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3126 pollPath: override,
3127 }
3128 }
3129
3130 // GetStreamThumbnailOperation returns a new GetStreamThumbnailOperation from a given name.
3131 // The name must be that of a previously created GetStreamThumbnailOperation, possibly from a different process.
3132 func (c *streamsGRPCClient) GetStreamThumbnailOperation(name string) *GetStreamThumbnailOperation {
3133 return &GetStreamThumbnailOperation{
3134 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3135 }
3136 }
3137
3138 // GetStreamThumbnailOperation returns a new GetStreamThumbnailOperation from a given name.
3139 // The name must be that of a previously created GetStreamThumbnailOperation, possibly from a different process.
3140 func (c *streamsRESTClient) GetStreamThumbnailOperation(name string) *GetStreamThumbnailOperation {
3141 override := fmt.Sprintf("/v1/%s", name)
3142 return &GetStreamThumbnailOperation{
3143 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3144 pollPath: override,
3145 }
3146 }
3147
3148 // MaterializeChannelOperation returns a new MaterializeChannelOperation from a given name.
3149 // The name must be that of a previously created MaterializeChannelOperation, possibly from a different process.
3150 func (c *streamsGRPCClient) MaterializeChannelOperation(name string) *MaterializeChannelOperation {
3151 return &MaterializeChannelOperation{
3152 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3153 }
3154 }
3155
3156 // MaterializeChannelOperation returns a new MaterializeChannelOperation from a given name.
3157 // The name must be that of a previously created MaterializeChannelOperation, possibly from a different process.
3158 func (c *streamsRESTClient) MaterializeChannelOperation(name string) *MaterializeChannelOperation {
3159 override := fmt.Sprintf("/v1/%s", name)
3160 return &MaterializeChannelOperation{
3161 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3162 pollPath: override,
3163 }
3164 }
3165
3166 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
3167 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
3168 func (c *streamsGRPCClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
3169 return &UpdateClusterOperation{
3170 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3171 }
3172 }
3173
3174 // UpdateClusterOperation returns a new UpdateClusterOperation from a given name.
3175 // The name must be that of a previously created UpdateClusterOperation, possibly from a different process.
3176 func (c *streamsRESTClient) UpdateClusterOperation(name string) *UpdateClusterOperation {
3177 override := fmt.Sprintf("/v1/%s", name)
3178 return &UpdateClusterOperation{
3179 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3180 pollPath: override,
3181 }
3182 }
3183
3184 // UpdateEventOperation returns a new UpdateEventOperation from a given name.
3185 // The name must be that of a previously created UpdateEventOperation, possibly from a different process.
3186 func (c *streamsGRPCClient) UpdateEventOperation(name string) *UpdateEventOperation {
3187 return &UpdateEventOperation{
3188 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3189 }
3190 }
3191
3192 // UpdateEventOperation returns a new UpdateEventOperation from a given name.
3193 // The name must be that of a previously created UpdateEventOperation, possibly from a different process.
3194 func (c *streamsRESTClient) UpdateEventOperation(name string) *UpdateEventOperation {
3195 override := fmt.Sprintf("/v1/%s", name)
3196 return &UpdateEventOperation{
3197 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3198 pollPath: override,
3199 }
3200 }
3201
3202 // UpdateSeriesOperation returns a new UpdateSeriesOperation from a given name.
3203 // The name must be that of a previously created UpdateSeriesOperation, possibly from a different process.
3204 func (c *streamsGRPCClient) UpdateSeriesOperation(name string) *UpdateSeriesOperation {
3205 return &UpdateSeriesOperation{
3206 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3207 }
3208 }
3209
3210 // UpdateSeriesOperation returns a new UpdateSeriesOperation from a given name.
3211 // The name must be that of a previously created UpdateSeriesOperation, possibly from a different process.
3212 func (c *streamsRESTClient) UpdateSeriesOperation(name string) *UpdateSeriesOperation {
3213 override := fmt.Sprintf("/v1/%s", name)
3214 return &UpdateSeriesOperation{
3215 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3216 pollPath: override,
3217 }
3218 }
3219
3220 // UpdateStreamOperation returns a new UpdateStreamOperation from a given name.
3221 // The name must be that of a previously created UpdateStreamOperation, possibly from a different process.
3222 func (c *streamsGRPCClient) UpdateStreamOperation(name string) *UpdateStreamOperation {
3223 return &UpdateStreamOperation{
3224 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3225 }
3226 }
3227
3228 // UpdateStreamOperation returns a new UpdateStreamOperation from a given name.
3229 // The name must be that of a previously created UpdateStreamOperation, possibly from a different process.
3230 func (c *streamsRESTClient) UpdateStreamOperation(name string) *UpdateStreamOperation {
3231 override := fmt.Sprintf("/v1/%s", name)
3232 return &UpdateStreamOperation{
3233 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3234 pollPath: override,
3235 }
3236 }