1// Copyright 2021 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
17package transcoder
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	gax "github.com/googleapis/gax-go/v2"
27	"google.golang.org/api/iterator"
28	"google.golang.org/api/option"
29	"google.golang.org/api/option/internaloption"
30	gtransport "google.golang.org/api/transport/grpc"
31	transcoderpb "google.golang.org/genproto/googleapis/cloud/video/transcoder/v1beta1"
32	"google.golang.org/grpc"
33	"google.golang.org/grpc/metadata"
34	"google.golang.org/protobuf/proto"
35)
36
37var newClientHook clientHook
38
39// CallOptions contains the retry settings for each method of Client.
40type CallOptions struct {
41	CreateJob         []gax.CallOption
42	ListJobs          []gax.CallOption
43	GetJob            []gax.CallOption
44	DeleteJob         []gax.CallOption
45	CreateJobTemplate []gax.CallOption
46	ListJobTemplates  []gax.CallOption
47	GetJobTemplate    []gax.CallOption
48	DeleteJobTemplate []gax.CallOption
49}
50
51func defaultGRPCClientOptions() []option.ClientOption {
52	return []option.ClientOption{
53		internaloption.WithDefaultEndpoint("transcoder.googleapis.com:443"),
54		internaloption.WithDefaultMTLSEndpoint("transcoder.mtls.googleapis.com:443"),
55		internaloption.WithDefaultAudience("https://transcoder.googleapis.com/"),
56		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
57		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
58		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
59			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
60	}
61}
62
63func defaultCallOptions() *CallOptions {
64	return &CallOptions{
65		CreateJob:         []gax.CallOption{},
66		ListJobs:          []gax.CallOption{},
67		GetJob:            []gax.CallOption{},
68		DeleteJob:         []gax.CallOption{},
69		CreateJobTemplate: []gax.CallOption{},
70		ListJobTemplates:  []gax.CallOption{},
71		GetJobTemplate:    []gax.CallOption{},
72		DeleteJobTemplate: []gax.CallOption{},
73	}
74}
75
76// internalClient is an interface that defines the methods availaible from Transcoder API.
77type internalClient interface {
78	Close() error
79	setGoogleClientInfo(...string)
80	Connection() *grpc.ClientConn
81	CreateJob(context.Context, *transcoderpb.CreateJobRequest, ...gax.CallOption) (*transcoderpb.Job, error)
82	ListJobs(context.Context, *transcoderpb.ListJobsRequest, ...gax.CallOption) *JobIterator
83	GetJob(context.Context, *transcoderpb.GetJobRequest, ...gax.CallOption) (*transcoderpb.Job, error)
84	DeleteJob(context.Context, *transcoderpb.DeleteJobRequest, ...gax.CallOption) error
85	CreateJobTemplate(context.Context, *transcoderpb.CreateJobTemplateRequest, ...gax.CallOption) (*transcoderpb.JobTemplate, error)
86	ListJobTemplates(context.Context, *transcoderpb.ListJobTemplatesRequest, ...gax.CallOption) *JobTemplateIterator
87	GetJobTemplate(context.Context, *transcoderpb.GetJobTemplateRequest, ...gax.CallOption) (*transcoderpb.JobTemplate, error)
88	DeleteJobTemplate(context.Context, *transcoderpb.DeleteJobTemplateRequest, ...gax.CallOption) error
89}
90
91// Client is a client for interacting with Transcoder API.
92// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
93//
94// Using the Transcoder API, you can queue asynchronous jobs for transcoding
95// media into various output formats. Output formats may include different
96// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive
97// Streaming over HTTP (DASH). You can also customize jobs using advanced
98// features such as Digital Rights Management (DRM), audio equalization, content
99// concatenation, and digital ad-stitch ready content generation.
100type Client struct {
101	// The internal transport-dependent client.
102	internalClient internalClient
103
104	// The call options for this service.
105	CallOptions *CallOptions
106}
107
108// Wrapper methods routed to the internal client.
109
110// Close closes the connection to the API service. The user should invoke this when
111// the client is no longer required.
112func (c *Client) Close() error {
113	return c.internalClient.Close()
114}
115
116// setGoogleClientInfo sets the name and version of the application in
117// the `x-goog-api-client` header passed on each request. Intended for
118// use by Google-written clients.
119func (c *Client) setGoogleClientInfo(keyval ...string) {
120	c.internalClient.setGoogleClientInfo(keyval...)
121}
122
123// Connection returns a connection to the API service.
124//
125// Deprecated.
126func (c *Client) Connection() *grpc.ClientConn {
127	return c.internalClient.Connection()
128}
129
130// CreateJob creates a job in the specified region.
131func (c *Client) CreateJob(ctx context.Context, req *transcoderpb.CreateJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) {
132	return c.internalClient.CreateJob(ctx, req, opts...)
133}
134
135// ListJobs lists jobs in the specified region.
136func (c *Client) ListJobs(ctx context.Context, req *transcoderpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator {
137	return c.internalClient.ListJobs(ctx, req, opts...)
138}
139
140// GetJob returns the job data.
141func (c *Client) GetJob(ctx context.Context, req *transcoderpb.GetJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) {
142	return c.internalClient.GetJob(ctx, req, opts...)
143}
144
145// DeleteJob deletes a job.
146func (c *Client) DeleteJob(ctx context.Context, req *transcoderpb.DeleteJobRequest, opts ...gax.CallOption) error {
147	return c.internalClient.DeleteJob(ctx, req, opts...)
148}
149
150// CreateJobTemplate creates a job template in the specified region.
151func (c *Client) CreateJobTemplate(ctx context.Context, req *transcoderpb.CreateJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) {
152	return c.internalClient.CreateJobTemplate(ctx, req, opts...)
153}
154
155// ListJobTemplates lists job templates in the specified region.
156func (c *Client) ListJobTemplates(ctx context.Context, req *transcoderpb.ListJobTemplatesRequest, opts ...gax.CallOption) *JobTemplateIterator {
157	return c.internalClient.ListJobTemplates(ctx, req, opts...)
158}
159
160// GetJobTemplate returns the job template data.
161func (c *Client) GetJobTemplate(ctx context.Context, req *transcoderpb.GetJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) {
162	return c.internalClient.GetJobTemplate(ctx, req, opts...)
163}
164
165// DeleteJobTemplate deletes a job template.
166func (c *Client) DeleteJobTemplate(ctx context.Context, req *transcoderpb.DeleteJobTemplateRequest, opts ...gax.CallOption) error {
167	return c.internalClient.DeleteJobTemplate(ctx, req, opts...)
168}
169
170// gRPCClient is a client for interacting with Transcoder API over gRPC transport.
171//
172// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
173type gRPCClient struct {
174	// Connection pool of gRPC connections to the service.
175	connPool gtransport.ConnPool
176
177	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
178	disableDeadlines bool
179
180	// Points back to the CallOptions field of the containing Client
181	CallOptions **CallOptions
182
183	// The gRPC API client.
184	client transcoderpb.TranscoderServiceClient
185
186	// The x-goog-* metadata to be sent with each request.
187	xGoogMetadata metadata.MD
188}
189
190// NewClient creates a new transcoder service client based on gRPC.
191// The returned client must be Closed when it is done being used to clean up its underlying connections.
192//
193// Using the Transcoder API, you can queue asynchronous jobs for transcoding
194// media into various output formats. Output formats may include different
195// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive
196// Streaming over HTTP (DASH). You can also customize jobs using advanced
197// features such as Digital Rights Management (DRM), audio equalization, content
198// concatenation, and digital ad-stitch ready content generation.
199func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
200	clientOpts := defaultGRPCClientOptions()
201	if newClientHook != nil {
202		hookOpts, err := newClientHook(ctx, clientHookParams{})
203		if err != nil {
204			return nil, err
205		}
206		clientOpts = append(clientOpts, hookOpts...)
207	}
208
209	disableDeadlines, err := checkDisableDeadlines()
210	if err != nil {
211		return nil, err
212	}
213
214	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
215	if err != nil {
216		return nil, err
217	}
218	client := Client{CallOptions: defaultCallOptions()}
219
220	c := &gRPCClient{
221		connPool:         connPool,
222		disableDeadlines: disableDeadlines,
223		client:           transcoderpb.NewTranscoderServiceClient(connPool),
224		CallOptions:      &client.CallOptions,
225	}
226	c.setGoogleClientInfo()
227
228	client.internalClient = c
229
230	return &client, nil
231}
232
233// Connection returns a connection to the API service.
234//
235// Deprecated.
236func (c *gRPCClient) Connection() *grpc.ClientConn {
237	return c.connPool.Conn()
238}
239
240// setGoogleClientInfo sets the name and version of the application in
241// the `x-goog-api-client` header passed on each request. Intended for
242// use by Google-written clients.
243func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
244	kv := append([]string{"gl-go", versionGo()}, keyval...)
245	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
246	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
247}
248
249// Close closes the connection to the API service. The user should invoke this when
250// the client is no longer required.
251func (c *gRPCClient) Close() error {
252	return c.connPool.Close()
253}
254
255func (c *gRPCClient) CreateJob(ctx context.Context, req *transcoderpb.CreateJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) {
256	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
257		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
258		defer cancel()
259		ctx = cctx
260	}
261	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
262	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
263	opts = append((*c.CallOptions).CreateJob[0:len((*c.CallOptions).CreateJob):len((*c.CallOptions).CreateJob)], opts...)
264	var resp *transcoderpb.Job
265	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
266		var err error
267		resp, err = c.client.CreateJob(ctx, req, settings.GRPC...)
268		return err
269	}, opts...)
270	if err != nil {
271		return nil, err
272	}
273	return resp, nil
274}
275
276func (c *gRPCClient) ListJobs(ctx context.Context, req *transcoderpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator {
277	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
278	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
279	opts = append((*c.CallOptions).ListJobs[0:len((*c.CallOptions).ListJobs):len((*c.CallOptions).ListJobs)], opts...)
280	it := &JobIterator{}
281	req = proto.Clone(req).(*transcoderpb.ListJobsRequest)
282	it.InternalFetch = func(pageSize int, pageToken string) ([]*transcoderpb.Job, string, error) {
283		var resp *transcoderpb.ListJobsResponse
284		req.PageToken = pageToken
285		if pageSize > math.MaxInt32 {
286			req.PageSize = math.MaxInt32
287		} else {
288			req.PageSize = int32(pageSize)
289		}
290		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
291			var err error
292			resp, err = c.client.ListJobs(ctx, req, settings.GRPC...)
293			return err
294		}, opts...)
295		if err != nil {
296			return nil, "", err
297		}
298
299		it.Response = resp
300		return resp.GetJobs(), resp.GetNextPageToken(), nil
301	}
302	fetch := func(pageSize int, pageToken string) (string, error) {
303		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
304		if err != nil {
305			return "", err
306		}
307		it.items = append(it.items, items...)
308		return nextPageToken, nil
309	}
310	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
311	it.pageInfo.MaxSize = int(req.GetPageSize())
312	it.pageInfo.Token = req.GetPageToken()
313	return it
314}
315
316func (c *gRPCClient) GetJob(ctx context.Context, req *transcoderpb.GetJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) {
317	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
318		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
319		defer cancel()
320		ctx = cctx
321	}
322	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
323	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
324	opts = append((*c.CallOptions).GetJob[0:len((*c.CallOptions).GetJob):len((*c.CallOptions).GetJob)], opts...)
325	var resp *transcoderpb.Job
326	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
327		var err error
328		resp, err = c.client.GetJob(ctx, req, settings.GRPC...)
329		return err
330	}, opts...)
331	if err != nil {
332		return nil, err
333	}
334	return resp, nil
335}
336
337func (c *gRPCClient) DeleteJob(ctx context.Context, req *transcoderpb.DeleteJobRequest, opts ...gax.CallOption) error {
338	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
339		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
340		defer cancel()
341		ctx = cctx
342	}
343	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
344	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
345	opts = append((*c.CallOptions).DeleteJob[0:len((*c.CallOptions).DeleteJob):len((*c.CallOptions).DeleteJob)], opts...)
346	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
347		var err error
348		_, err = c.client.DeleteJob(ctx, req, settings.GRPC...)
349		return err
350	}, opts...)
351	return err
352}
353
354func (c *gRPCClient) CreateJobTemplate(ctx context.Context, req *transcoderpb.CreateJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) {
355	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
356		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
357		defer cancel()
358		ctx = cctx
359	}
360	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
361	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
362	opts = append((*c.CallOptions).CreateJobTemplate[0:len((*c.CallOptions).CreateJobTemplate):len((*c.CallOptions).CreateJobTemplate)], opts...)
363	var resp *transcoderpb.JobTemplate
364	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
365		var err error
366		resp, err = c.client.CreateJobTemplate(ctx, req, settings.GRPC...)
367		return err
368	}, opts...)
369	if err != nil {
370		return nil, err
371	}
372	return resp, nil
373}
374
375func (c *gRPCClient) ListJobTemplates(ctx context.Context, req *transcoderpb.ListJobTemplatesRequest, opts ...gax.CallOption) *JobTemplateIterator {
376	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
377	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
378	opts = append((*c.CallOptions).ListJobTemplates[0:len((*c.CallOptions).ListJobTemplates):len((*c.CallOptions).ListJobTemplates)], opts...)
379	it := &JobTemplateIterator{}
380	req = proto.Clone(req).(*transcoderpb.ListJobTemplatesRequest)
381	it.InternalFetch = func(pageSize int, pageToken string) ([]*transcoderpb.JobTemplate, string, error) {
382		var resp *transcoderpb.ListJobTemplatesResponse
383		req.PageToken = pageToken
384		if pageSize > math.MaxInt32 {
385			req.PageSize = math.MaxInt32
386		} else {
387			req.PageSize = int32(pageSize)
388		}
389		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
390			var err error
391			resp, err = c.client.ListJobTemplates(ctx, req, settings.GRPC...)
392			return err
393		}, opts...)
394		if err != nil {
395			return nil, "", err
396		}
397
398		it.Response = resp
399		return resp.GetJobTemplates(), resp.GetNextPageToken(), nil
400	}
401	fetch := func(pageSize int, pageToken string) (string, error) {
402		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
403		if err != nil {
404			return "", err
405		}
406		it.items = append(it.items, items...)
407		return nextPageToken, nil
408	}
409	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
410	it.pageInfo.MaxSize = int(req.GetPageSize())
411	it.pageInfo.Token = req.GetPageToken()
412	return it
413}
414
415func (c *gRPCClient) GetJobTemplate(ctx context.Context, req *transcoderpb.GetJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) {
416	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
417		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
418		defer cancel()
419		ctx = cctx
420	}
421	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
422	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
423	opts = append((*c.CallOptions).GetJobTemplate[0:len((*c.CallOptions).GetJobTemplate):len((*c.CallOptions).GetJobTemplate)], opts...)
424	var resp *transcoderpb.JobTemplate
425	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
426		var err error
427		resp, err = c.client.GetJobTemplate(ctx, req, settings.GRPC...)
428		return err
429	}, opts...)
430	if err != nil {
431		return nil, err
432	}
433	return resp, nil
434}
435
436func (c *gRPCClient) DeleteJobTemplate(ctx context.Context, req *transcoderpb.DeleteJobTemplateRequest, opts ...gax.CallOption) error {
437	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
438		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
439		defer cancel()
440		ctx = cctx
441	}
442	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
443	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
444	opts = append((*c.CallOptions).DeleteJobTemplate[0:len((*c.CallOptions).DeleteJobTemplate):len((*c.CallOptions).DeleteJobTemplate)], opts...)
445	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
446		var err error
447		_, err = c.client.DeleteJobTemplate(ctx, req, settings.GRPC...)
448		return err
449	}, opts...)
450	return err
451}
452
453// JobIterator manages a stream of *transcoderpb.Job.
454type JobIterator struct {
455	items    []*transcoderpb.Job
456	pageInfo *iterator.PageInfo
457	nextFunc func() error
458
459	// Response is the raw response for the current page.
460	// It must be cast to the RPC response type.
461	// Calling Next() or InternalFetch() updates this value.
462	Response interface{}
463
464	// InternalFetch is for use by the Google Cloud Libraries only.
465	// It is not part of the stable interface of this package.
466	//
467	// InternalFetch returns results from a single call to the underlying RPC.
468	// The number of results is no greater than pageSize.
469	// If there are no more results, nextPageToken is empty and err is nil.
470	InternalFetch func(pageSize int, pageToken string) (results []*transcoderpb.Job, nextPageToken string, err error)
471}
472
473// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
474func (it *JobIterator) PageInfo() *iterator.PageInfo {
475	return it.pageInfo
476}
477
478// Next returns the next result. Its second return value is iterator.Done if there are no more
479// results. Once Next returns Done, all subsequent calls will return Done.
480func (it *JobIterator) Next() (*transcoderpb.Job, error) {
481	var item *transcoderpb.Job
482	if err := it.nextFunc(); err != nil {
483		return item, err
484	}
485	item = it.items[0]
486	it.items = it.items[1:]
487	return item, nil
488}
489
490func (it *JobIterator) bufLen() int {
491	return len(it.items)
492}
493
494func (it *JobIterator) takeBuf() interface{} {
495	b := it.items
496	it.items = nil
497	return b
498}
499
500// JobTemplateIterator manages a stream of *transcoderpb.JobTemplate.
501type JobTemplateIterator struct {
502	items    []*transcoderpb.JobTemplate
503	pageInfo *iterator.PageInfo
504	nextFunc func() error
505
506	// Response is the raw response for the current page.
507	// It must be cast to the RPC response type.
508	// Calling Next() or InternalFetch() updates this value.
509	Response interface{}
510
511	// InternalFetch is for use by the Google Cloud Libraries only.
512	// It is not part of the stable interface of this package.
513	//
514	// InternalFetch returns results from a single call to the underlying RPC.
515	// The number of results is no greater than pageSize.
516	// If there are no more results, nextPageToken is empty and err is nil.
517	InternalFetch func(pageSize int, pageToken string) (results []*transcoderpb.JobTemplate, nextPageToken string, err error)
518}
519
520// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
521func (it *JobTemplateIterator) PageInfo() *iterator.PageInfo {
522	return it.pageInfo
523}
524
525// Next returns the next result. Its second return value is iterator.Done if there are no more
526// results. Once Next returns Done, all subsequent calls will return Done.
527func (it *JobTemplateIterator) Next() (*transcoderpb.JobTemplate, error) {
528	var item *transcoderpb.JobTemplate
529	if err := it.nextFunc(); err != nil {
530		return item, err
531	}
532	item = it.items[0]
533	it.items = it.items[1:]
534	return item, nil
535}
536
537func (it *JobTemplateIterator) bufLen() int {
538	return len(it.items)
539}
540
541func (it *JobTemplateIterator) takeBuf() interface{} {
542	b := it.items
543	it.items = nil
544	return b
545}
546