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 appengine
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	"cloud.google.com/go/longrunning"
27	lroauto "cloud.google.com/go/longrunning/autogen"
28	gax "github.com/googleapis/gax-go/v2"
29	"google.golang.org/api/iterator"
30	"google.golang.org/api/option"
31	"google.golang.org/api/option/internaloption"
32	gtransport "google.golang.org/api/transport/grpc"
33	appenginepb "google.golang.org/genproto/googleapis/appengine/v1"
34	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
35	"google.golang.org/grpc"
36	"google.golang.org/grpc/metadata"
37	"google.golang.org/protobuf/proto"
38)
39
40var newVersionsClientHook clientHook
41
42// VersionsCallOptions contains the retry settings for each method of VersionsClient.
43type VersionsCallOptions struct {
44	ListVersions  []gax.CallOption
45	GetVersion    []gax.CallOption
46	CreateVersion []gax.CallOption
47	UpdateVersion []gax.CallOption
48	DeleteVersion []gax.CallOption
49}
50
51func defaultVersionsGRPCClientOptions() []option.ClientOption {
52	return []option.ClientOption{
53		internaloption.WithDefaultEndpoint("appengine.googleapis.com:443"),
54		internaloption.WithDefaultMTLSEndpoint("appengine.mtls.googleapis.com:443"),
55		internaloption.WithDefaultAudience("https://appengine.googleapis.com/"),
56		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
57		internaloption.EnableJwtWithScope(),
58		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
59		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
60			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
61	}
62}
63
64func defaultVersionsCallOptions() *VersionsCallOptions {
65	return &VersionsCallOptions{
66		ListVersions:  []gax.CallOption{},
67		GetVersion:    []gax.CallOption{},
68		CreateVersion: []gax.CallOption{},
69		UpdateVersion: []gax.CallOption{},
70		DeleteVersion: []gax.CallOption{},
71	}
72}
73
74// internalVersionsClient is an interface that defines the methods availaible from App Engine Admin API.
75type internalVersionsClient interface {
76	Close() error
77	setGoogleClientInfo(...string)
78	Connection() *grpc.ClientConn
79	ListVersions(context.Context, *appenginepb.ListVersionsRequest, ...gax.CallOption) *VersionIterator
80	GetVersion(context.Context, *appenginepb.GetVersionRequest, ...gax.CallOption) (*appenginepb.Version, error)
81	CreateVersion(context.Context, *appenginepb.CreateVersionRequest, ...gax.CallOption) (*CreateVersionOperation, error)
82	CreateVersionOperation(name string) *CreateVersionOperation
83	UpdateVersion(context.Context, *appenginepb.UpdateVersionRequest, ...gax.CallOption) (*UpdateVersionOperation, error)
84	UpdateVersionOperation(name string) *UpdateVersionOperation
85	DeleteVersion(context.Context, *appenginepb.DeleteVersionRequest, ...gax.CallOption) (*DeleteVersionOperation, error)
86	DeleteVersionOperation(name string) *DeleteVersionOperation
87}
88
89// VersionsClient is a client for interacting with App Engine Admin API.
90// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
91//
92// Manages versions of a service.
93type VersionsClient struct {
94	// The internal transport-dependent client.
95	internalClient internalVersionsClient
96
97	// The call options for this service.
98	CallOptions *VersionsCallOptions
99
100	// LROClient is used internally to handle long-running operations.
101	// It is exposed so that its CallOptions can be modified if required.
102	// Users should not Close this client.
103	LROClient *lroauto.OperationsClient
104}
105
106// Wrapper methods routed to the internal client.
107
108// Close closes the connection to the API service. The user should invoke this when
109// the client is no longer required.
110func (c *VersionsClient) Close() error {
111	return c.internalClient.Close()
112}
113
114// setGoogleClientInfo sets the name and version of the application in
115// the `x-goog-api-client` header passed on each request. Intended for
116// use by Google-written clients.
117func (c *VersionsClient) setGoogleClientInfo(keyval ...string) {
118	c.internalClient.setGoogleClientInfo(keyval...)
119}
120
121// Connection returns a connection to the API service.
122//
123// Deprecated.
124func (c *VersionsClient) Connection() *grpc.ClientConn {
125	return c.internalClient.Connection()
126}
127
128// ListVersions lists the versions of a service.
129func (c *VersionsClient) ListVersions(ctx context.Context, req *appenginepb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
130	return c.internalClient.ListVersions(ctx, req, opts...)
131}
132
133// GetVersion gets the specified Version resource.
134// By default, only a BASIC_VIEW will be returned.
135// Specify the FULL_VIEW parameter to get the full resource.
136func (c *VersionsClient) GetVersion(ctx context.Context, req *appenginepb.GetVersionRequest, opts ...gax.CallOption) (*appenginepb.Version, error) {
137	return c.internalClient.GetVersion(ctx, req, opts...)
138}
139
140// CreateVersion deploys code and resource files to a new version.
141func (c *VersionsClient) CreateVersion(ctx context.Context, req *appenginepb.CreateVersionRequest, opts ...gax.CallOption) (*CreateVersionOperation, error) {
142	return c.internalClient.CreateVersion(ctx, req, opts...)
143}
144
145// CreateVersionOperation returns a new CreateVersionOperation from a given name.
146// The name must be that of a previously created CreateVersionOperation, possibly from a different process.
147func (c *VersionsClient) CreateVersionOperation(name string) *CreateVersionOperation {
148	return c.internalClient.CreateVersionOperation(name)
149}
150
151// UpdateVersion updates the specified Version resource.
152// You can specify the following fields depending on the App Engine
153// environment and type of scaling that the version resource uses:
154//
155// Standard environment
156//
157//   instance_class (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class)
158//
159// automatic scaling in the standard environment:
160//
161//   automatic_scaling.min_idle_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
162//
163//   automatic_scaling.max_idle_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
164//
165//   automaticScaling.standard_scheduler_settings.max_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
166//
167//   automaticScaling.standard_scheduler_settings.min_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
168//
169//   automaticScaling.standard_scheduler_settings.target_cpu_utilization (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
170//
171//   automaticScaling.standard_scheduler_settings.target_throughput_utilization (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)
172//
173// basic scaling or manual scaling in the standard environment:
174//
175//   serving_status (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)
176//
177//   manual_scaling.instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling)
178//
179// Flexible environment
180//
181//   serving_status (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)
182//
183// automatic scaling in the flexible environment:
184//
185//   automatic_scaling.min_total_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
186//
187//   automatic_scaling.max_total_instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
188//
189//   automatic_scaling.cool_down_period_sec (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
190//
191//   automatic_scaling.cpu_utilization.target_utilization (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling)
192//
193// manual scaling in the flexible environment:
194//
195//   manual_scaling.instances (at https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling)
196func (c *VersionsClient) UpdateVersion(ctx context.Context, req *appenginepb.UpdateVersionRequest, opts ...gax.CallOption) (*UpdateVersionOperation, error) {
197	return c.internalClient.UpdateVersion(ctx, req, opts...)
198}
199
200// UpdateVersionOperation returns a new UpdateVersionOperation from a given name.
201// The name must be that of a previously created UpdateVersionOperation, possibly from a different process.
202func (c *VersionsClient) UpdateVersionOperation(name string) *UpdateVersionOperation {
203	return c.internalClient.UpdateVersionOperation(name)
204}
205
206// DeleteVersion deletes an existing Version resource.
207func (c *VersionsClient) DeleteVersion(ctx context.Context, req *appenginepb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
208	return c.internalClient.DeleteVersion(ctx, req, opts...)
209}
210
211// DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
212// The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
213func (c *VersionsClient) DeleteVersionOperation(name string) *DeleteVersionOperation {
214	return c.internalClient.DeleteVersionOperation(name)
215}
216
217// versionsGRPCClient is a client for interacting with App Engine Admin API over gRPC transport.
218//
219// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
220type versionsGRPCClient struct {
221	// Connection pool of gRPC connections to the service.
222	connPool gtransport.ConnPool
223
224	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
225	disableDeadlines bool
226
227	// Points back to the CallOptions field of the containing VersionsClient
228	CallOptions **VersionsCallOptions
229
230	// The gRPC API client.
231	versionsClient appenginepb.VersionsClient
232
233	// LROClient is used internally to handle long-running operations.
234	// It is exposed so that its CallOptions can be modified if required.
235	// Users should not Close this client.
236	LROClient **lroauto.OperationsClient
237
238	// The x-goog-* metadata to be sent with each request.
239	xGoogMetadata metadata.MD
240}
241
242// NewVersionsClient creates a new versions client based on gRPC.
243// The returned client must be Closed when it is done being used to clean up its underlying connections.
244//
245// Manages versions of a service.
246func NewVersionsClient(ctx context.Context, opts ...option.ClientOption) (*VersionsClient, error) {
247	clientOpts := defaultVersionsGRPCClientOptions()
248	if newVersionsClientHook != nil {
249		hookOpts, err := newVersionsClientHook(ctx, clientHookParams{})
250		if err != nil {
251			return nil, err
252		}
253		clientOpts = append(clientOpts, hookOpts...)
254	}
255
256	disableDeadlines, err := checkDisableDeadlines()
257	if err != nil {
258		return nil, err
259	}
260
261	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
262	if err != nil {
263		return nil, err
264	}
265	client := VersionsClient{CallOptions: defaultVersionsCallOptions()}
266
267	c := &versionsGRPCClient{
268		connPool:         connPool,
269		disableDeadlines: disableDeadlines,
270		versionsClient:   appenginepb.NewVersionsClient(connPool),
271		CallOptions:      &client.CallOptions,
272	}
273	c.setGoogleClientInfo()
274
275	client.internalClient = c
276
277	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
278	if err != nil {
279		// This error "should not happen", since we are just reusing old connection pool
280		// and never actually need to dial.
281		// If this does happen, we could leak connp. However, we cannot close conn:
282		// If the user invoked the constructor with option.WithGRPCConn,
283		// we would close a connection that's still in use.
284		// TODO: investigate error conditions.
285		return nil, err
286	}
287	c.LROClient = &client.LROClient
288	return &client, nil
289}
290
291// Connection returns a connection to the API service.
292//
293// Deprecated.
294func (c *versionsGRPCClient) Connection() *grpc.ClientConn {
295	return c.connPool.Conn()
296}
297
298// setGoogleClientInfo sets the name and version of the application in
299// the `x-goog-api-client` header passed on each request. Intended for
300// use by Google-written clients.
301func (c *versionsGRPCClient) setGoogleClientInfo(keyval ...string) {
302	kv := append([]string{"gl-go", versionGo()}, keyval...)
303	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
304	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
305}
306
307// Close closes the connection to the API service. The user should invoke this when
308// the client is no longer required.
309func (c *versionsGRPCClient) Close() error {
310	return c.connPool.Close()
311}
312
313func (c *versionsGRPCClient) ListVersions(ctx context.Context, req *appenginepb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
314	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
315	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
316	opts = append((*c.CallOptions).ListVersions[0:len((*c.CallOptions).ListVersions):len((*c.CallOptions).ListVersions)], opts...)
317	it := &VersionIterator{}
318	req = proto.Clone(req).(*appenginepb.ListVersionsRequest)
319	it.InternalFetch = func(pageSize int, pageToken string) ([]*appenginepb.Version, string, error) {
320		resp := &appenginepb.ListVersionsResponse{}
321		if pageToken != "" {
322			req.PageToken = pageToken
323		}
324		if pageSize > math.MaxInt32 {
325			req.PageSize = math.MaxInt32
326		} else if pageSize != 0 {
327			req.PageSize = int32(pageSize)
328		}
329		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
330			var err error
331			resp, err = c.versionsClient.ListVersions(ctx, req, settings.GRPC...)
332			return err
333		}, opts...)
334		if err != nil {
335			return nil, "", err
336		}
337
338		it.Response = resp
339		return resp.GetVersions(), resp.GetNextPageToken(), nil
340	}
341	fetch := func(pageSize int, pageToken string) (string, error) {
342		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
343		if err != nil {
344			return "", err
345		}
346		it.items = append(it.items, items...)
347		return nextPageToken, nil
348	}
349
350	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
351	it.pageInfo.MaxSize = int(req.GetPageSize())
352	it.pageInfo.Token = req.GetPageToken()
353
354	return it
355}
356
357func (c *versionsGRPCClient) GetVersion(ctx context.Context, req *appenginepb.GetVersionRequest, opts ...gax.CallOption) (*appenginepb.Version, error) {
358	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
359	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
360	opts = append((*c.CallOptions).GetVersion[0:len((*c.CallOptions).GetVersion):len((*c.CallOptions).GetVersion)], opts...)
361	var resp *appenginepb.Version
362	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
363		var err error
364		resp, err = c.versionsClient.GetVersion(ctx, req, settings.GRPC...)
365		return err
366	}, opts...)
367	if err != nil {
368		return nil, err
369	}
370	return resp, nil
371}
372
373func (c *versionsGRPCClient) CreateVersion(ctx context.Context, req *appenginepb.CreateVersionRequest, opts ...gax.CallOption) (*CreateVersionOperation, error) {
374	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
375	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
376	opts = append((*c.CallOptions).CreateVersion[0:len((*c.CallOptions).CreateVersion):len((*c.CallOptions).CreateVersion)], opts...)
377	var resp *longrunningpb.Operation
378	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
379		var err error
380		resp, err = c.versionsClient.CreateVersion(ctx, req, settings.GRPC...)
381		return err
382	}, opts...)
383	if err != nil {
384		return nil, err
385	}
386	return &CreateVersionOperation{
387		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
388	}, nil
389}
390
391func (c *versionsGRPCClient) UpdateVersion(ctx context.Context, req *appenginepb.UpdateVersionRequest, opts ...gax.CallOption) (*UpdateVersionOperation, error) {
392	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
393	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
394	opts = append((*c.CallOptions).UpdateVersion[0:len((*c.CallOptions).UpdateVersion):len((*c.CallOptions).UpdateVersion)], opts...)
395	var resp *longrunningpb.Operation
396	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
397		var err error
398		resp, err = c.versionsClient.UpdateVersion(ctx, req, settings.GRPC...)
399		return err
400	}, opts...)
401	if err != nil {
402		return nil, err
403	}
404	return &UpdateVersionOperation{
405		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
406	}, nil
407}
408
409func (c *versionsGRPCClient) DeleteVersion(ctx context.Context, req *appenginepb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
410	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
411	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
412	opts = append((*c.CallOptions).DeleteVersion[0:len((*c.CallOptions).DeleteVersion):len((*c.CallOptions).DeleteVersion)], opts...)
413	var resp *longrunningpb.Operation
414	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
415		var err error
416		resp, err = c.versionsClient.DeleteVersion(ctx, req, settings.GRPC...)
417		return err
418	}, opts...)
419	if err != nil {
420		return nil, err
421	}
422	return &DeleteVersionOperation{
423		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
424	}, nil
425}
426
427// CreateVersionOperation manages a long-running operation from CreateVersion.
428type CreateVersionOperation struct {
429	lro *longrunning.Operation
430}
431
432// CreateVersionOperation returns a new CreateVersionOperation from a given name.
433// The name must be that of a previously created CreateVersionOperation, possibly from a different process.
434func (c *versionsGRPCClient) CreateVersionOperation(name string) *CreateVersionOperation {
435	return &CreateVersionOperation{
436		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
437	}
438}
439
440// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
441//
442// See documentation of Poll for error-handling information.
443func (op *CreateVersionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*appenginepb.Version, error) {
444	var resp appenginepb.Version
445	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
446		return nil, err
447	}
448	return &resp, nil
449}
450
451// Poll fetches the latest state of the long-running operation.
452//
453// Poll also fetches the latest metadata, which can be retrieved by Metadata.
454//
455// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
456// the operation has completed with failure, the error is returned and op.Done will return true.
457// If Poll succeeds and the operation has completed successfully,
458// op.Done will return true, and the response of the operation is returned.
459// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
460func (op *CreateVersionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*appenginepb.Version, error) {
461	var resp appenginepb.Version
462	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
463		return nil, err
464	}
465	if !op.Done() {
466		return nil, nil
467	}
468	return &resp, nil
469}
470
471// Metadata returns metadata associated with the long-running operation.
472// Metadata itself does not contact the server, but Poll does.
473// To get the latest metadata, call this method after a successful call to Poll.
474// If the metadata is not available, the returned metadata and error are both nil.
475func (op *CreateVersionOperation) Metadata() (*appenginepb.CreateVersionMetadataV1, error) {
476	var meta appenginepb.CreateVersionMetadataV1
477	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
478		return nil, nil
479	} else if err != nil {
480		return nil, err
481	}
482	return &meta, nil
483}
484
485// Done reports whether the long-running operation has completed.
486func (op *CreateVersionOperation) Done() bool {
487	return op.lro.Done()
488}
489
490// Name returns the name of the long-running operation.
491// The name is assigned by the server and is unique within the service from which the operation is created.
492func (op *CreateVersionOperation) Name() string {
493	return op.lro.Name()
494}
495
496// DeleteVersionOperation manages a long-running operation from DeleteVersion.
497type DeleteVersionOperation struct {
498	lro *longrunning.Operation
499}
500
501// DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
502// The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
503func (c *versionsGRPCClient) DeleteVersionOperation(name string) *DeleteVersionOperation {
504	return &DeleteVersionOperation{
505		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
506	}
507}
508
509// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
510//
511// See documentation of Poll for error-handling information.
512func (op *DeleteVersionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
513	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
514}
515
516// Poll fetches the latest state of the long-running operation.
517//
518// Poll also fetches the latest metadata, which can be retrieved by Metadata.
519//
520// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
521// the operation has completed with failure, the error is returned and op.Done will return true.
522// If Poll succeeds and the operation has completed successfully,
523// op.Done will return true, and the response of the operation is returned.
524// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
525func (op *DeleteVersionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
526	return op.lro.Poll(ctx, nil, opts...)
527}
528
529// Metadata returns metadata associated with the long-running operation.
530// Metadata itself does not contact the server, but Poll does.
531// To get the latest metadata, call this method after a successful call to Poll.
532// If the metadata is not available, the returned metadata and error are both nil.
533func (op *DeleteVersionOperation) Metadata() (*appenginepb.OperationMetadataV1, error) {
534	var meta appenginepb.OperationMetadataV1
535	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
536		return nil, nil
537	} else if err != nil {
538		return nil, err
539	}
540	return &meta, nil
541}
542
543// Done reports whether the long-running operation has completed.
544func (op *DeleteVersionOperation) Done() bool {
545	return op.lro.Done()
546}
547
548// Name returns the name of the long-running operation.
549// The name is assigned by the server and is unique within the service from which the operation is created.
550func (op *DeleteVersionOperation) Name() string {
551	return op.lro.Name()
552}
553
554// UpdateVersionOperation manages a long-running operation from UpdateVersion.
555type UpdateVersionOperation struct {
556	lro *longrunning.Operation
557}
558
559// UpdateVersionOperation returns a new UpdateVersionOperation from a given name.
560// The name must be that of a previously created UpdateVersionOperation, possibly from a different process.
561func (c *versionsGRPCClient) UpdateVersionOperation(name string) *UpdateVersionOperation {
562	return &UpdateVersionOperation{
563		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
564	}
565}
566
567// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
568//
569// See documentation of Poll for error-handling information.
570func (op *UpdateVersionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*appenginepb.Version, error) {
571	var resp appenginepb.Version
572	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
573		return nil, err
574	}
575	return &resp, nil
576}
577
578// Poll fetches the latest state of the long-running operation.
579//
580// Poll also fetches the latest metadata, which can be retrieved by Metadata.
581//
582// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
583// the operation has completed with failure, the error is returned and op.Done will return true.
584// If Poll succeeds and the operation has completed successfully,
585// op.Done will return true, and the response of the operation is returned.
586// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
587func (op *UpdateVersionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*appenginepb.Version, error) {
588	var resp appenginepb.Version
589	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
590		return nil, err
591	}
592	if !op.Done() {
593		return nil, nil
594	}
595	return &resp, nil
596}
597
598// Metadata returns metadata associated with the long-running operation.
599// Metadata itself does not contact the server, but Poll does.
600// To get the latest metadata, call this method after a successful call to Poll.
601// If the metadata is not available, the returned metadata and error are both nil.
602func (op *UpdateVersionOperation) Metadata() (*appenginepb.OperationMetadataV1, error) {
603	var meta appenginepb.OperationMetadataV1
604	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
605		return nil, nil
606	} else if err != nil {
607		return nil, err
608	}
609	return &meta, nil
610}
611
612// Done reports whether the long-running operation has completed.
613func (op *UpdateVersionOperation) Done() bool {
614	return op.lro.Done()
615}
616
617// Name returns the name of the long-running operation.
618// The name is assigned by the server and is unique within the service from which the operation is created.
619func (op *UpdateVersionOperation) Name() string {
620	return op.lro.Name()
621}
622
623// VersionIterator manages a stream of *appenginepb.Version.
624type VersionIterator struct {
625	items    []*appenginepb.Version
626	pageInfo *iterator.PageInfo
627	nextFunc func() error
628
629	// Response is the raw response for the current page.
630	// It must be cast to the RPC response type.
631	// Calling Next() or InternalFetch() updates this value.
632	Response interface{}
633
634	// InternalFetch is for use by the Google Cloud Libraries only.
635	// It is not part of the stable interface of this package.
636	//
637	// InternalFetch returns results from a single call to the underlying RPC.
638	// The number of results is no greater than pageSize.
639	// If there are no more results, nextPageToken is empty and err is nil.
640	InternalFetch func(pageSize int, pageToken string) (results []*appenginepb.Version, nextPageToken string, err error)
641}
642
643// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
644func (it *VersionIterator) PageInfo() *iterator.PageInfo {
645	return it.pageInfo
646}
647
648// Next returns the next result. Its second return value is iterator.Done if there are no more
649// results. Once Next returns Done, all subsequent calls will return Done.
650func (it *VersionIterator) Next() (*appenginepb.Version, error) {
651	var item *appenginepb.Version
652	if err := it.nextFunc(); err != nil {
653		return item, err
654	}
655	item = it.items[0]
656	it.items = it.items[1:]
657	return item, nil
658}
659
660func (it *VersionIterator) bufLen() int {
661	return len(it.items)
662}
663
664func (it *VersionIterator) takeBuf() interface{} {
665	b := it.items
666	it.items = nil
667	return b
668}
669