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 servicemanagement
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	serviceconfigpb "google.golang.org/genproto/googleapis/api/serviceconfig"
34	servicemanagementpb "google.golang.org/genproto/googleapis/api/servicemanagement/v1"
35	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
36	"google.golang.org/grpc"
37	"google.golang.org/grpc/metadata"
38	"google.golang.org/protobuf/proto"
39)
40
41var newServiceManagerClientHook clientHook
42
43// ServiceManagerCallOptions contains the retry settings for each method of ServiceManagerClient.
44type ServiceManagerCallOptions struct {
45	ListServices         []gax.CallOption
46	GetService           []gax.CallOption
47	CreateService        []gax.CallOption
48	DeleteService        []gax.CallOption
49	UndeleteService      []gax.CallOption
50	ListServiceConfigs   []gax.CallOption
51	GetServiceConfig     []gax.CallOption
52	CreateServiceConfig  []gax.CallOption
53	SubmitConfigSource   []gax.CallOption
54	ListServiceRollouts  []gax.CallOption
55	GetServiceRollout    []gax.CallOption
56	CreateServiceRollout []gax.CallOption
57	GenerateConfigReport []gax.CallOption
58	EnableService        []gax.CallOption
59	DisableService       []gax.CallOption
60}
61
62func defaultServiceManagerGRPCClientOptions() []option.ClientOption {
63	return []option.ClientOption{
64		internaloption.WithDefaultEndpoint("servicemanagement.googleapis.com:443"),
65		internaloption.WithDefaultMTLSEndpoint("servicemanagement.mtls.googleapis.com:443"),
66		internaloption.WithDefaultAudience("https://servicemanagement.googleapis.com/"),
67		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
68		internaloption.EnableJwtWithScope(),
69		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
70		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
71			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
72	}
73}
74
75func defaultServiceManagerCallOptions() *ServiceManagerCallOptions {
76	return &ServiceManagerCallOptions{
77		ListServices:         []gax.CallOption{},
78		GetService:           []gax.CallOption{},
79		CreateService:        []gax.CallOption{},
80		DeleteService:        []gax.CallOption{},
81		UndeleteService:      []gax.CallOption{},
82		ListServiceConfigs:   []gax.CallOption{},
83		GetServiceConfig:     []gax.CallOption{},
84		CreateServiceConfig:  []gax.CallOption{},
85		SubmitConfigSource:   []gax.CallOption{},
86		ListServiceRollouts:  []gax.CallOption{},
87		GetServiceRollout:    []gax.CallOption{},
88		CreateServiceRollout: []gax.CallOption{},
89		GenerateConfigReport: []gax.CallOption{},
90		EnableService:        []gax.CallOption{},
91		DisableService:       []gax.CallOption{},
92	}
93}
94
95// internalServiceManagerClient is an interface that defines the methods availaible from Service Management API.
96type internalServiceManagerClient interface {
97	Close() error
98	setGoogleClientInfo(...string)
99	Connection() *grpc.ClientConn
100	ListServices(context.Context, *servicemanagementpb.ListServicesRequest, ...gax.CallOption) *ManagedServiceIterator
101	GetService(context.Context, *servicemanagementpb.GetServiceRequest, ...gax.CallOption) (*servicemanagementpb.ManagedService, error)
102	CreateService(context.Context, *servicemanagementpb.CreateServiceRequest, ...gax.CallOption) (*CreateServiceOperation, error)
103	CreateServiceOperation(name string) *CreateServiceOperation
104	DeleteService(context.Context, *servicemanagementpb.DeleteServiceRequest, ...gax.CallOption) (*DeleteServiceOperation, error)
105	DeleteServiceOperation(name string) *DeleteServiceOperation
106	UndeleteService(context.Context, *servicemanagementpb.UndeleteServiceRequest, ...gax.CallOption) (*UndeleteServiceOperation, error)
107	UndeleteServiceOperation(name string) *UndeleteServiceOperation
108	ListServiceConfigs(context.Context, *servicemanagementpb.ListServiceConfigsRequest, ...gax.CallOption) *ServiceIterator
109	GetServiceConfig(context.Context, *servicemanagementpb.GetServiceConfigRequest, ...gax.CallOption) (*serviceconfigpb.Service, error)
110	CreateServiceConfig(context.Context, *servicemanagementpb.CreateServiceConfigRequest, ...gax.CallOption) (*serviceconfigpb.Service, error)
111	SubmitConfigSource(context.Context, *servicemanagementpb.SubmitConfigSourceRequest, ...gax.CallOption) (*SubmitConfigSourceOperation, error)
112	SubmitConfigSourceOperation(name string) *SubmitConfigSourceOperation
113	ListServiceRollouts(context.Context, *servicemanagementpb.ListServiceRolloutsRequest, ...gax.CallOption) *RolloutIterator
114	GetServiceRollout(context.Context, *servicemanagementpb.GetServiceRolloutRequest, ...gax.CallOption) (*servicemanagementpb.Rollout, error)
115	CreateServiceRollout(context.Context, *servicemanagementpb.CreateServiceRolloutRequest, ...gax.CallOption) (*CreateServiceRolloutOperation, error)
116	CreateServiceRolloutOperation(name string) *CreateServiceRolloutOperation
117	GenerateConfigReport(context.Context, *servicemanagementpb.GenerateConfigReportRequest, ...gax.CallOption) (*servicemanagementpb.GenerateConfigReportResponse, error)
118	EnableService(context.Context, *servicemanagementpb.EnableServiceRequest, ...gax.CallOption) (*EnableServiceOperation, error)
119	EnableServiceOperation(name string) *EnableServiceOperation
120	DisableService(context.Context, *servicemanagementpb.DisableServiceRequest, ...gax.CallOption) (*DisableServiceOperation, error)
121	DisableServiceOperation(name string) *DisableServiceOperation
122}
123
124// ServiceManagerClient is a client for interacting with Service Management API.
125// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
126//
127// Google Service Management API (at https://cloud.google.com/service-management/overview)
128type ServiceManagerClient struct {
129	// The internal transport-dependent client.
130	internalClient internalServiceManagerClient
131
132	// The call options for this service.
133	CallOptions *ServiceManagerCallOptions
134
135	// LROClient is used internally to handle long-running operations.
136	// It is exposed so that its CallOptions can be modified if required.
137	// Users should not Close this client.
138	LROClient *lroauto.OperationsClient
139}
140
141// Wrapper methods routed to the internal client.
142
143// Close closes the connection to the API service. The user should invoke this when
144// the client is no longer required.
145func (c *ServiceManagerClient) Close() error {
146	return c.internalClient.Close()
147}
148
149// setGoogleClientInfo sets the name and version of the application in
150// the `x-goog-api-client` header passed on each request. Intended for
151// use by Google-written clients.
152func (c *ServiceManagerClient) setGoogleClientInfo(keyval ...string) {
153	c.internalClient.setGoogleClientInfo(keyval...)
154}
155
156// Connection returns a connection to the API service.
157//
158// Deprecated.
159func (c *ServiceManagerClient) Connection() *grpc.ClientConn {
160	return c.internalClient.Connection()
161}
162
163// ListServices lists managed services.
164//
165// Returns all public services. For authenticated users, also returns all
166// services the calling user has “servicemanagement.services.get” permission
167// for.
168//
169// BETA: If the caller specifies the consumer_id, it returns only the
170// services enabled on the consumer. The consumer_id must have the format
171// of “project:{PROJECT-ID}”.
172func (c *ServiceManagerClient) ListServices(ctx context.Context, req *servicemanagementpb.ListServicesRequest, opts ...gax.CallOption) *ManagedServiceIterator {
173	return c.internalClient.ListServices(ctx, req, opts...)
174}
175
176// GetService gets a managed service. Authentication is required unless the service is
177// public.
178func (c *ServiceManagerClient) GetService(ctx context.Context, req *servicemanagementpb.GetServiceRequest, opts ...gax.CallOption) (*servicemanagementpb.ManagedService, error) {
179	return c.internalClient.GetService(ctx, req, opts...)
180}
181
182// CreateService creates a new managed service.
183// Please note one producer project can own no more than 20 services.
184//
185// Operation<response: ManagedService>
186func (c *ServiceManagerClient) CreateService(ctx context.Context, req *servicemanagementpb.CreateServiceRequest, opts ...gax.CallOption) (*CreateServiceOperation, error) {
187	return c.internalClient.CreateService(ctx, req, opts...)
188}
189
190// CreateServiceOperation returns a new CreateServiceOperation from a given name.
191// The name must be that of a previously created CreateServiceOperation, possibly from a different process.
192func (c *ServiceManagerClient) CreateServiceOperation(name string) *CreateServiceOperation {
193	return c.internalClient.CreateServiceOperation(name)
194}
195
196// DeleteService deletes a managed service. This method will change the service to the
197// Soft-Delete state for 30 days. Within this period, service producers may
198// call UndeleteService to restore the service.
199// After 30 days, the service will be permanently deleted.
200//
201// Operation<response: google.protobuf.Empty>
202func (c *ServiceManagerClient) DeleteService(ctx context.Context, req *servicemanagementpb.DeleteServiceRequest, opts ...gax.CallOption) (*DeleteServiceOperation, error) {
203	return c.internalClient.DeleteService(ctx, req, opts...)
204}
205
206// DeleteServiceOperation returns a new DeleteServiceOperation from a given name.
207// The name must be that of a previously created DeleteServiceOperation, possibly from a different process.
208func (c *ServiceManagerClient) DeleteServiceOperation(name string) *DeleteServiceOperation {
209	return c.internalClient.DeleteServiceOperation(name)
210}
211
212// UndeleteService revives a previously deleted managed service. The method restores the
213// service using the configuration at the time the service was deleted.
214// The target service must exist and must have been deleted within the
215// last 30 days.
216//
217// Operation<response: UndeleteServiceResponse>
218func (c *ServiceManagerClient) UndeleteService(ctx context.Context, req *servicemanagementpb.UndeleteServiceRequest, opts ...gax.CallOption) (*UndeleteServiceOperation, error) {
219	return c.internalClient.UndeleteService(ctx, req, opts...)
220}
221
222// UndeleteServiceOperation returns a new UndeleteServiceOperation from a given name.
223// The name must be that of a previously created UndeleteServiceOperation, possibly from a different process.
224func (c *ServiceManagerClient) UndeleteServiceOperation(name string) *UndeleteServiceOperation {
225	return c.internalClient.UndeleteServiceOperation(name)
226}
227
228// ListServiceConfigs lists the history of the service configuration for a managed service,
229// from the newest to the oldest.
230func (c *ServiceManagerClient) ListServiceConfigs(ctx context.Context, req *servicemanagementpb.ListServiceConfigsRequest, opts ...gax.CallOption) *ServiceIterator {
231	return c.internalClient.ListServiceConfigs(ctx, req, opts...)
232}
233
234// GetServiceConfig gets a service configuration (version) for a managed service.
235func (c *ServiceManagerClient) GetServiceConfig(ctx context.Context, req *servicemanagementpb.GetServiceConfigRequest, opts ...gax.CallOption) (*serviceconfigpb.Service, error) {
236	return c.internalClient.GetServiceConfig(ctx, req, opts...)
237}
238
239// CreateServiceConfig creates a new service configuration (version) for a managed service.
240// This method only stores the service configuration. To roll out the service
241// configuration to backend systems please call
242// CreateServiceRollout.
243//
244// Only the 100 most recent service configurations and ones referenced by
245// existing rollouts are kept for each service. The rest will be deleted
246// eventually.
247func (c *ServiceManagerClient) CreateServiceConfig(ctx context.Context, req *servicemanagementpb.CreateServiceConfigRequest, opts ...gax.CallOption) (*serviceconfigpb.Service, error) {
248	return c.internalClient.CreateServiceConfig(ctx, req, opts...)
249}
250
251// SubmitConfigSource creates a new service configuration (version) for a managed service based
252// on
253// user-supplied configuration source files (for example: OpenAPI
254// Specification). This method stores the source configurations as well as the
255// generated service configuration. To rollout the service configuration to
256// other services,
257// please call CreateServiceRollout.
258//
259// Only the 100 most recent configuration sources and ones referenced by
260// existing service configurtions are kept for each service. The rest will be
261// deleted eventually.
262//
263// Operation<response: SubmitConfigSourceResponse>
264func (c *ServiceManagerClient) SubmitConfigSource(ctx context.Context, req *servicemanagementpb.SubmitConfigSourceRequest, opts ...gax.CallOption) (*SubmitConfigSourceOperation, error) {
265	return c.internalClient.SubmitConfigSource(ctx, req, opts...)
266}
267
268// SubmitConfigSourceOperation returns a new SubmitConfigSourceOperation from a given name.
269// The name must be that of a previously created SubmitConfigSourceOperation, possibly from a different process.
270func (c *ServiceManagerClient) SubmitConfigSourceOperation(name string) *SubmitConfigSourceOperation {
271	return c.internalClient.SubmitConfigSourceOperation(name)
272}
273
274// ListServiceRollouts lists the history of the service configuration rollouts for a managed
275// service, from the newest to the oldest.
276func (c *ServiceManagerClient) ListServiceRollouts(ctx context.Context, req *servicemanagementpb.ListServiceRolloutsRequest, opts ...gax.CallOption) *RolloutIterator {
277	return c.internalClient.ListServiceRollouts(ctx, req, opts...)
278}
279
280// GetServiceRollout gets a service configuration rollout.
281func (c *ServiceManagerClient) GetServiceRollout(ctx context.Context, req *servicemanagementpb.GetServiceRolloutRequest, opts ...gax.CallOption) (*servicemanagementpb.Rollout, error) {
282	return c.internalClient.GetServiceRollout(ctx, req, opts...)
283}
284
285// CreateServiceRollout creates a new service configuration rollout. Based on rollout, the
286// Google Service Management will roll out the service configurations to
287// different backend services. For example, the logging configuration will be
288// pushed to Google Cloud Logging.
289//
290// Please note that any previous pending and running Rollouts and associated
291// Operations will be automatically cancelled so that the latest Rollout will
292// not be blocked by previous Rollouts.
293//
294// Only the 100 most recent (in any state) and the last 10 successful (if not
295// already part of the set of 100 most recent) rollouts are kept for each
296// service. The rest will be deleted eventually.
297//
298// Operation<response: Rollout>
299func (c *ServiceManagerClient) CreateServiceRollout(ctx context.Context, req *servicemanagementpb.CreateServiceRolloutRequest, opts ...gax.CallOption) (*CreateServiceRolloutOperation, error) {
300	return c.internalClient.CreateServiceRollout(ctx, req, opts...)
301}
302
303// CreateServiceRolloutOperation returns a new CreateServiceRolloutOperation from a given name.
304// The name must be that of a previously created CreateServiceRolloutOperation, possibly from a different process.
305func (c *ServiceManagerClient) CreateServiceRolloutOperation(name string) *CreateServiceRolloutOperation {
306	return c.internalClient.CreateServiceRolloutOperation(name)
307}
308
309// GenerateConfigReport generates and returns a report (errors, warnings and changes from
310// existing configurations) associated with
311// GenerateConfigReportRequest.new_value
312//
313// If GenerateConfigReportRequest.old_value is specified,
314// GenerateConfigReportRequest will contain a single ChangeReport based on the
315// comparison between GenerateConfigReportRequest.new_value and
316// GenerateConfigReportRequest.old_value.
317// If GenerateConfigReportRequest.old_value is not specified, this method
318// will compare GenerateConfigReportRequest.new_value with the last pushed
319// service configuration.
320func (c *ServiceManagerClient) GenerateConfigReport(ctx context.Context, req *servicemanagementpb.GenerateConfigReportRequest, opts ...gax.CallOption) (*servicemanagementpb.GenerateConfigReportResponse, error) {
321	return c.internalClient.GenerateConfigReport(ctx, req, opts...)
322}
323
324// EnableService enables a service for a project, so it can be used
325// for the project. See
326// Cloud Auth Guide (at https://cloud.google.com/docs/authentication) for
327// more information.
328//
329// Operation<response: EnableServiceResponse>
330//
331// Deprecated: EnableService may be removed in a future version.
332func (c *ServiceManagerClient) EnableService(ctx context.Context, req *servicemanagementpb.EnableServiceRequest, opts ...gax.CallOption) (*EnableServiceOperation, error) {
333	return c.internalClient.EnableService(ctx, req, opts...)
334}
335
336// EnableServiceOperation returns a new EnableServiceOperation from a given name.
337// The name must be that of a previously created EnableServiceOperation, possibly from a different process.
338func (c *ServiceManagerClient) EnableServiceOperation(name string) *EnableServiceOperation {
339	return c.internalClient.EnableServiceOperation(name)
340}
341
342// DisableService disables a service for a project, so it can no longer be
343// be used for the project. It prevents accidental usage that may cause
344// unexpected billing charges or security leaks.
345//
346// Operation<response: DisableServiceResponse>
347//
348// Deprecated: DisableService may be removed in a future version.
349func (c *ServiceManagerClient) DisableService(ctx context.Context, req *servicemanagementpb.DisableServiceRequest, opts ...gax.CallOption) (*DisableServiceOperation, error) {
350	return c.internalClient.DisableService(ctx, req, opts...)
351}
352
353// DisableServiceOperation returns a new DisableServiceOperation from a given name.
354// The name must be that of a previously created DisableServiceOperation, possibly from a different process.
355func (c *ServiceManagerClient) DisableServiceOperation(name string) *DisableServiceOperation {
356	return c.internalClient.DisableServiceOperation(name)
357}
358
359// serviceManagerGRPCClient is a client for interacting with Service Management API over gRPC transport.
360//
361// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
362type serviceManagerGRPCClient struct {
363	// Connection pool of gRPC connections to the service.
364	connPool gtransport.ConnPool
365
366	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
367	disableDeadlines bool
368
369	// Points back to the CallOptions field of the containing ServiceManagerClient
370	CallOptions **ServiceManagerCallOptions
371
372	// The gRPC API client.
373	serviceManagerClient servicemanagementpb.ServiceManagerClient
374
375	// LROClient is used internally to handle long-running operations.
376	// It is exposed so that its CallOptions can be modified if required.
377	// Users should not Close this client.
378	LROClient **lroauto.OperationsClient
379
380	// The x-goog-* metadata to be sent with each request.
381	xGoogMetadata metadata.MD
382}
383
384// NewServiceManagerClient creates a new service manager client based on gRPC.
385// The returned client must be Closed when it is done being used to clean up its underlying connections.
386//
387// Google Service Management API (at https://cloud.google.com/service-management/overview)
388func NewServiceManagerClient(ctx context.Context, opts ...option.ClientOption) (*ServiceManagerClient, error) {
389	clientOpts := defaultServiceManagerGRPCClientOptions()
390	if newServiceManagerClientHook != nil {
391		hookOpts, err := newServiceManagerClientHook(ctx, clientHookParams{})
392		if err != nil {
393			return nil, err
394		}
395		clientOpts = append(clientOpts, hookOpts...)
396	}
397
398	disableDeadlines, err := checkDisableDeadlines()
399	if err != nil {
400		return nil, err
401	}
402
403	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
404	if err != nil {
405		return nil, err
406	}
407	client := ServiceManagerClient{CallOptions: defaultServiceManagerCallOptions()}
408
409	c := &serviceManagerGRPCClient{
410		connPool:             connPool,
411		disableDeadlines:     disableDeadlines,
412		serviceManagerClient: servicemanagementpb.NewServiceManagerClient(connPool),
413		CallOptions:          &client.CallOptions,
414	}
415	c.setGoogleClientInfo()
416
417	client.internalClient = c
418
419	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
420	if err != nil {
421		// This error "should not happen", since we are just reusing old connection pool
422		// and never actually need to dial.
423		// If this does happen, we could leak connp. However, we cannot close conn:
424		// If the user invoked the constructor with option.WithGRPCConn,
425		// we would close a connection that's still in use.
426		// TODO: investigate error conditions.
427		return nil, err
428	}
429	c.LROClient = &client.LROClient
430	return &client, nil
431}
432
433// Connection returns a connection to the API service.
434//
435// Deprecated.
436func (c *serviceManagerGRPCClient) Connection() *grpc.ClientConn {
437	return c.connPool.Conn()
438}
439
440// setGoogleClientInfo sets the name and version of the application in
441// the `x-goog-api-client` header passed on each request. Intended for
442// use by Google-written clients.
443func (c *serviceManagerGRPCClient) setGoogleClientInfo(keyval ...string) {
444	kv := append([]string{"gl-go", versionGo()}, keyval...)
445	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
446	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
447}
448
449// Close closes the connection to the API service. The user should invoke this when
450// the client is no longer required.
451func (c *serviceManagerGRPCClient) Close() error {
452	return c.connPool.Close()
453}
454
455func (c *serviceManagerGRPCClient) ListServices(ctx context.Context, req *servicemanagementpb.ListServicesRequest, opts ...gax.CallOption) *ManagedServiceIterator {
456	ctx = insertMetadata(ctx, c.xGoogMetadata)
457	opts = append((*c.CallOptions).ListServices[0:len((*c.CallOptions).ListServices):len((*c.CallOptions).ListServices)], opts...)
458	it := &ManagedServiceIterator{}
459	req = proto.Clone(req).(*servicemanagementpb.ListServicesRequest)
460	it.InternalFetch = func(pageSize int, pageToken string) ([]*servicemanagementpb.ManagedService, string, error) {
461		resp := &servicemanagementpb.ListServicesResponse{}
462		if pageToken != "" {
463			req.PageToken = pageToken
464		}
465		if pageSize > math.MaxInt32 {
466			req.PageSize = math.MaxInt32
467		} else if pageSize != 0 {
468			req.PageSize = int32(pageSize)
469		}
470		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
471			var err error
472			resp, err = c.serviceManagerClient.ListServices(ctx, req, settings.GRPC...)
473			return err
474		}, opts...)
475		if err != nil {
476			return nil, "", err
477		}
478
479		it.Response = resp
480		return resp.GetServices(), resp.GetNextPageToken(), nil
481	}
482	fetch := func(pageSize int, pageToken string) (string, error) {
483		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
484		if err != nil {
485			return "", err
486		}
487		it.items = append(it.items, items...)
488		return nextPageToken, nil
489	}
490
491	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
492	it.pageInfo.MaxSize = int(req.GetPageSize())
493	it.pageInfo.Token = req.GetPageToken()
494
495	return it
496}
497
498func (c *serviceManagerGRPCClient) GetService(ctx context.Context, req *servicemanagementpb.GetServiceRequest, opts ...gax.CallOption) (*servicemanagementpb.ManagedService, error) {
499	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
500		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
501		defer cancel()
502		ctx = cctx
503	}
504	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
505	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
506	opts = append((*c.CallOptions).GetService[0:len((*c.CallOptions).GetService):len((*c.CallOptions).GetService)], opts...)
507	var resp *servicemanagementpb.ManagedService
508	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
509		var err error
510		resp, err = c.serviceManagerClient.GetService(ctx, req, settings.GRPC...)
511		return err
512	}, opts...)
513	if err != nil {
514		return nil, err
515	}
516	return resp, nil
517}
518
519func (c *serviceManagerGRPCClient) CreateService(ctx context.Context, req *servicemanagementpb.CreateServiceRequest, opts ...gax.CallOption) (*CreateServiceOperation, error) {
520	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
521		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
522		defer cancel()
523		ctx = cctx
524	}
525	ctx = insertMetadata(ctx, c.xGoogMetadata)
526	opts = append((*c.CallOptions).CreateService[0:len((*c.CallOptions).CreateService):len((*c.CallOptions).CreateService)], opts...)
527	var resp *longrunningpb.Operation
528	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
529		var err error
530		resp, err = c.serviceManagerClient.CreateService(ctx, req, settings.GRPC...)
531		return err
532	}, opts...)
533	if err != nil {
534		return nil, err
535	}
536	return &CreateServiceOperation{
537		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
538	}, nil
539}
540
541func (c *serviceManagerGRPCClient) DeleteService(ctx context.Context, req *servicemanagementpb.DeleteServiceRequest, opts ...gax.CallOption) (*DeleteServiceOperation, error) {
542	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
543		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
544		defer cancel()
545		ctx = cctx
546	}
547	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
548	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
549	opts = append((*c.CallOptions).DeleteService[0:len((*c.CallOptions).DeleteService):len((*c.CallOptions).DeleteService)], opts...)
550	var resp *longrunningpb.Operation
551	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
552		var err error
553		resp, err = c.serviceManagerClient.DeleteService(ctx, req, settings.GRPC...)
554		return err
555	}, opts...)
556	if err != nil {
557		return nil, err
558	}
559	return &DeleteServiceOperation{
560		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
561	}, nil
562}
563
564func (c *serviceManagerGRPCClient) UndeleteService(ctx context.Context, req *servicemanagementpb.UndeleteServiceRequest, opts ...gax.CallOption) (*UndeleteServiceOperation, error) {
565	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
566		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
567		defer cancel()
568		ctx = cctx
569	}
570	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
571	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
572	opts = append((*c.CallOptions).UndeleteService[0:len((*c.CallOptions).UndeleteService):len((*c.CallOptions).UndeleteService)], opts...)
573	var resp *longrunningpb.Operation
574	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
575		var err error
576		resp, err = c.serviceManagerClient.UndeleteService(ctx, req, settings.GRPC...)
577		return err
578	}, opts...)
579	if err != nil {
580		return nil, err
581	}
582	return &UndeleteServiceOperation{
583		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
584	}, nil
585}
586
587func (c *serviceManagerGRPCClient) ListServiceConfigs(ctx context.Context, req *servicemanagementpb.ListServiceConfigsRequest, opts ...gax.CallOption) *ServiceIterator {
588	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
589	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
590	opts = append((*c.CallOptions).ListServiceConfigs[0:len((*c.CallOptions).ListServiceConfigs):len((*c.CallOptions).ListServiceConfigs)], opts...)
591	it := &ServiceIterator{}
592	req = proto.Clone(req).(*servicemanagementpb.ListServiceConfigsRequest)
593	it.InternalFetch = func(pageSize int, pageToken string) ([]*serviceconfigpb.Service, string, error) {
594		resp := &servicemanagementpb.ListServiceConfigsResponse{}
595		if pageToken != "" {
596			req.PageToken = pageToken
597		}
598		if pageSize > math.MaxInt32 {
599			req.PageSize = math.MaxInt32
600		} else if pageSize != 0 {
601			req.PageSize = int32(pageSize)
602		}
603		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
604			var err error
605			resp, err = c.serviceManagerClient.ListServiceConfigs(ctx, req, settings.GRPC...)
606			return err
607		}, opts...)
608		if err != nil {
609			return nil, "", err
610		}
611
612		it.Response = resp
613		return resp.GetServiceConfigs(), resp.GetNextPageToken(), nil
614	}
615	fetch := func(pageSize int, pageToken string) (string, error) {
616		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
617		if err != nil {
618			return "", err
619		}
620		it.items = append(it.items, items...)
621		return nextPageToken, nil
622	}
623
624	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
625	it.pageInfo.MaxSize = int(req.GetPageSize())
626	it.pageInfo.Token = req.GetPageToken()
627
628	return it
629}
630
631func (c *serviceManagerGRPCClient) GetServiceConfig(ctx context.Context, req *servicemanagementpb.GetServiceConfigRequest, opts ...gax.CallOption) (*serviceconfigpb.Service, error) {
632	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
633		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
634		defer cancel()
635		ctx = cctx
636	}
637	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "service_name", url.QueryEscape(req.GetServiceName()), "config_id", url.QueryEscape(req.GetConfigId())))
638	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
639	opts = append((*c.CallOptions).GetServiceConfig[0:len((*c.CallOptions).GetServiceConfig):len((*c.CallOptions).GetServiceConfig)], opts...)
640	var resp *serviceconfigpb.Service
641	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
642		var err error
643		resp, err = c.serviceManagerClient.GetServiceConfig(ctx, req, settings.GRPC...)
644		return err
645	}, opts...)
646	if err != nil {
647		return nil, err
648	}
649	return resp, nil
650}
651
652func (c *serviceManagerGRPCClient) CreateServiceConfig(ctx context.Context, req *servicemanagementpb.CreateServiceConfigRequest, opts ...gax.CallOption) (*serviceconfigpb.Service, error) {
653	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
654		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
655		defer cancel()
656		ctx = cctx
657	}
658	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
659	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
660	opts = append((*c.CallOptions).CreateServiceConfig[0:len((*c.CallOptions).CreateServiceConfig):len((*c.CallOptions).CreateServiceConfig)], opts...)
661	var resp *serviceconfigpb.Service
662	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
663		var err error
664		resp, err = c.serviceManagerClient.CreateServiceConfig(ctx, req, settings.GRPC...)
665		return err
666	}, opts...)
667	if err != nil {
668		return nil, err
669	}
670	return resp, nil
671}
672
673func (c *serviceManagerGRPCClient) SubmitConfigSource(ctx context.Context, req *servicemanagementpb.SubmitConfigSourceRequest, opts ...gax.CallOption) (*SubmitConfigSourceOperation, error) {
674	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
675		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
676		defer cancel()
677		ctx = cctx
678	}
679	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
680	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
681	opts = append((*c.CallOptions).SubmitConfigSource[0:len((*c.CallOptions).SubmitConfigSource):len((*c.CallOptions).SubmitConfigSource)], opts...)
682	var resp *longrunningpb.Operation
683	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
684		var err error
685		resp, err = c.serviceManagerClient.SubmitConfigSource(ctx, req, settings.GRPC...)
686		return err
687	}, opts...)
688	if err != nil {
689		return nil, err
690	}
691	return &SubmitConfigSourceOperation{
692		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
693	}, nil
694}
695
696func (c *serviceManagerGRPCClient) ListServiceRollouts(ctx context.Context, req *servicemanagementpb.ListServiceRolloutsRequest, opts ...gax.CallOption) *RolloutIterator {
697	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
698	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
699	opts = append((*c.CallOptions).ListServiceRollouts[0:len((*c.CallOptions).ListServiceRollouts):len((*c.CallOptions).ListServiceRollouts)], opts...)
700	it := &RolloutIterator{}
701	req = proto.Clone(req).(*servicemanagementpb.ListServiceRolloutsRequest)
702	it.InternalFetch = func(pageSize int, pageToken string) ([]*servicemanagementpb.Rollout, string, error) {
703		resp := &servicemanagementpb.ListServiceRolloutsResponse{}
704		if pageToken != "" {
705			req.PageToken = pageToken
706		}
707		if pageSize > math.MaxInt32 {
708			req.PageSize = math.MaxInt32
709		} else if pageSize != 0 {
710			req.PageSize = int32(pageSize)
711		}
712		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
713			var err error
714			resp, err = c.serviceManagerClient.ListServiceRollouts(ctx, req, settings.GRPC...)
715			return err
716		}, opts...)
717		if err != nil {
718			return nil, "", err
719		}
720
721		it.Response = resp
722		return resp.GetRollouts(), resp.GetNextPageToken(), nil
723	}
724	fetch := func(pageSize int, pageToken string) (string, error) {
725		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
726		if err != nil {
727			return "", err
728		}
729		it.items = append(it.items, items...)
730		return nextPageToken, nil
731	}
732
733	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
734	it.pageInfo.MaxSize = int(req.GetPageSize())
735	it.pageInfo.Token = req.GetPageToken()
736
737	return it
738}
739
740func (c *serviceManagerGRPCClient) GetServiceRollout(ctx context.Context, req *servicemanagementpb.GetServiceRolloutRequest, opts ...gax.CallOption) (*servicemanagementpb.Rollout, error) {
741	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
742		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
743		defer cancel()
744		ctx = cctx
745	}
746	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "service_name", url.QueryEscape(req.GetServiceName()), "rollout_id", url.QueryEscape(req.GetRolloutId())))
747	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
748	opts = append((*c.CallOptions).GetServiceRollout[0:len((*c.CallOptions).GetServiceRollout):len((*c.CallOptions).GetServiceRollout)], opts...)
749	var resp *servicemanagementpb.Rollout
750	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
751		var err error
752		resp, err = c.serviceManagerClient.GetServiceRollout(ctx, req, settings.GRPC...)
753		return err
754	}, opts...)
755	if err != nil {
756		return nil, err
757	}
758	return resp, nil
759}
760
761func (c *serviceManagerGRPCClient) CreateServiceRollout(ctx context.Context, req *servicemanagementpb.CreateServiceRolloutRequest, opts ...gax.CallOption) (*CreateServiceRolloutOperation, error) {
762	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
763		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
764		defer cancel()
765		ctx = cctx
766	}
767	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
768	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
769	opts = append((*c.CallOptions).CreateServiceRollout[0:len((*c.CallOptions).CreateServiceRollout):len((*c.CallOptions).CreateServiceRollout)], opts...)
770	var resp *longrunningpb.Operation
771	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
772		var err error
773		resp, err = c.serviceManagerClient.CreateServiceRollout(ctx, req, settings.GRPC...)
774		return err
775	}, opts...)
776	if err != nil {
777		return nil, err
778	}
779	return &CreateServiceRolloutOperation{
780		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
781	}, nil
782}
783
784func (c *serviceManagerGRPCClient) GenerateConfigReport(ctx context.Context, req *servicemanagementpb.GenerateConfigReportRequest, opts ...gax.CallOption) (*servicemanagementpb.GenerateConfigReportResponse, error) {
785	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
786		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
787		defer cancel()
788		ctx = cctx
789	}
790	ctx = insertMetadata(ctx, c.xGoogMetadata)
791	opts = append((*c.CallOptions).GenerateConfigReport[0:len((*c.CallOptions).GenerateConfigReport):len((*c.CallOptions).GenerateConfigReport)], opts...)
792	var resp *servicemanagementpb.GenerateConfigReportResponse
793	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
794		var err error
795		resp, err = c.serviceManagerClient.GenerateConfigReport(ctx, req, settings.GRPC...)
796		return err
797	}, opts...)
798	if err != nil {
799		return nil, err
800	}
801	return resp, nil
802}
803
804func (c *serviceManagerGRPCClient) EnableService(ctx context.Context, req *servicemanagementpb.EnableServiceRequest, opts ...gax.CallOption) (*EnableServiceOperation, error) {
805	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
806		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
807		defer cancel()
808		ctx = cctx
809	}
810	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
811	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
812	opts = append((*c.CallOptions).EnableService[0:len((*c.CallOptions).EnableService):len((*c.CallOptions).EnableService)], opts...)
813	var resp *longrunningpb.Operation
814	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
815		var err error
816		resp, err = c.serviceManagerClient.EnableService(ctx, req, settings.GRPC...)
817		return err
818	}, opts...)
819	if err != nil {
820		return nil, err
821	}
822	return &EnableServiceOperation{
823		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
824	}, nil
825}
826
827func (c *serviceManagerGRPCClient) DisableService(ctx context.Context, req *servicemanagementpb.DisableServiceRequest, opts ...gax.CallOption) (*DisableServiceOperation, error) {
828	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
829		cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond)
830		defer cancel()
831		ctx = cctx
832	}
833	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName())))
834	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
835	opts = append((*c.CallOptions).DisableService[0:len((*c.CallOptions).DisableService):len((*c.CallOptions).DisableService)], opts...)
836	var resp *longrunningpb.Operation
837	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
838		var err error
839		resp, err = c.serviceManagerClient.DisableService(ctx, req, settings.GRPC...)
840		return err
841	}, opts...)
842	if err != nil {
843		return nil, err
844	}
845	return &DisableServiceOperation{
846		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
847	}, nil
848}
849
850// CreateServiceOperation manages a long-running operation from CreateService.
851type CreateServiceOperation struct {
852	lro *longrunning.Operation
853}
854
855// CreateServiceOperation returns a new CreateServiceOperation from a given name.
856// The name must be that of a previously created CreateServiceOperation, possibly from a different process.
857func (c *serviceManagerGRPCClient) CreateServiceOperation(name string) *CreateServiceOperation {
858	return &CreateServiceOperation{
859		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
860	}
861}
862
863// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
864//
865// See documentation of Poll for error-handling information.
866func (op *CreateServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.ManagedService, error) {
867	var resp servicemanagementpb.ManagedService
868	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
869		return nil, err
870	}
871	return &resp, nil
872}
873
874// Poll fetches the latest state of the long-running operation.
875//
876// Poll also fetches the latest metadata, which can be retrieved by Metadata.
877//
878// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
879// the operation has completed with failure, the error is returned and op.Done will return true.
880// If Poll succeeds and the operation has completed successfully,
881// op.Done will return true, and the response of the operation is returned.
882// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
883func (op *CreateServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.ManagedService, error) {
884	var resp servicemanagementpb.ManagedService
885	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
886		return nil, err
887	}
888	if !op.Done() {
889		return nil, nil
890	}
891	return &resp, nil
892}
893
894// Metadata returns metadata associated with the long-running operation.
895// Metadata itself does not contact the server, but Poll does.
896// To get the latest metadata, call this method after a successful call to Poll.
897// If the metadata is not available, the returned metadata and error are both nil.
898func (op *CreateServiceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
899	var meta servicemanagementpb.OperationMetadata
900	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
901		return nil, nil
902	} else if err != nil {
903		return nil, err
904	}
905	return &meta, nil
906}
907
908// Done reports whether the long-running operation has completed.
909func (op *CreateServiceOperation) Done() bool {
910	return op.lro.Done()
911}
912
913// Name returns the name of the long-running operation.
914// The name is assigned by the server and is unique within the service from which the operation is created.
915func (op *CreateServiceOperation) Name() string {
916	return op.lro.Name()
917}
918
919// CreateServiceRolloutOperation manages a long-running operation from CreateServiceRollout.
920type CreateServiceRolloutOperation struct {
921	lro *longrunning.Operation
922}
923
924// CreateServiceRolloutOperation returns a new CreateServiceRolloutOperation from a given name.
925// The name must be that of a previously created CreateServiceRolloutOperation, possibly from a different process.
926func (c *serviceManagerGRPCClient) CreateServiceRolloutOperation(name string) *CreateServiceRolloutOperation {
927	return &CreateServiceRolloutOperation{
928		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
929	}
930}
931
932// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
933//
934// See documentation of Poll for error-handling information.
935func (op *CreateServiceRolloutOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.Rollout, error) {
936	var resp servicemanagementpb.Rollout
937	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
938		return nil, err
939	}
940	return &resp, nil
941}
942
943// Poll fetches the latest state of the long-running operation.
944//
945// Poll also fetches the latest metadata, which can be retrieved by Metadata.
946//
947// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
948// the operation has completed with failure, the error is returned and op.Done will return true.
949// If Poll succeeds and the operation has completed successfully,
950// op.Done will return true, and the response of the operation is returned.
951// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
952func (op *CreateServiceRolloutOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.Rollout, error) {
953	var resp servicemanagementpb.Rollout
954	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
955		return nil, err
956	}
957	if !op.Done() {
958		return nil, nil
959	}
960	return &resp, nil
961}
962
963// Metadata returns metadata associated with the long-running operation.
964// Metadata itself does not contact the server, but Poll does.
965// To get the latest metadata, call this method after a successful call to Poll.
966// If the metadata is not available, the returned metadata and error are both nil.
967func (op *CreateServiceRolloutOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
968	var meta servicemanagementpb.OperationMetadata
969	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
970		return nil, nil
971	} else if err != nil {
972		return nil, err
973	}
974	return &meta, nil
975}
976
977// Done reports whether the long-running operation has completed.
978func (op *CreateServiceRolloutOperation) Done() bool {
979	return op.lro.Done()
980}
981
982// Name returns the name of the long-running operation.
983// The name is assigned by the server and is unique within the service from which the operation is created.
984func (op *CreateServiceRolloutOperation) Name() string {
985	return op.lro.Name()
986}
987
988// DeleteServiceOperation manages a long-running operation from DeleteService.
989type DeleteServiceOperation struct {
990	lro *longrunning.Operation
991}
992
993// DeleteServiceOperation returns a new DeleteServiceOperation from a given name.
994// The name must be that of a previously created DeleteServiceOperation, possibly from a different process.
995func (c *serviceManagerGRPCClient) DeleteServiceOperation(name string) *DeleteServiceOperation {
996	return &DeleteServiceOperation{
997		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
998	}
999}
1000
1001// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1002//
1003// See documentation of Poll for error-handling information.
1004func (op *DeleteServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1005	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1006}
1007
1008// Poll fetches the latest state of the long-running operation.
1009//
1010// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1011//
1012// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1013// the operation has completed with failure, the error is returned and op.Done will return true.
1014// If Poll succeeds and the operation has completed successfully,
1015// op.Done will return true, and the response of the operation is returned.
1016// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1017func (op *DeleteServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1018	return op.lro.Poll(ctx, nil, opts...)
1019}
1020
1021// Metadata returns metadata associated with the long-running operation.
1022// Metadata itself does not contact the server, but Poll does.
1023// To get the latest metadata, call this method after a successful call to Poll.
1024// If the metadata is not available, the returned metadata and error are both nil.
1025func (op *DeleteServiceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
1026	var meta servicemanagementpb.OperationMetadata
1027	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1028		return nil, nil
1029	} else if err != nil {
1030		return nil, err
1031	}
1032	return &meta, nil
1033}
1034
1035// Done reports whether the long-running operation has completed.
1036func (op *DeleteServiceOperation) Done() bool {
1037	return op.lro.Done()
1038}
1039
1040// Name returns the name of the long-running operation.
1041// The name is assigned by the server and is unique within the service from which the operation is created.
1042func (op *DeleteServiceOperation) Name() string {
1043	return op.lro.Name()
1044}
1045
1046// DisableServiceOperation manages a long-running operation from DisableService.
1047type DisableServiceOperation struct {
1048	lro *longrunning.Operation
1049}
1050
1051// DisableServiceOperation returns a new DisableServiceOperation from a given name.
1052// The name must be that of a previously created DisableServiceOperation, possibly from a different process.
1053func (c *serviceManagerGRPCClient) DisableServiceOperation(name string) *DisableServiceOperation {
1054	return &DisableServiceOperation{
1055		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1056	}
1057}
1058
1059// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1060//
1061// See documentation of Poll for error-handling information.
1062func (op *DisableServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.DisableServiceResponse, error) {
1063	var resp servicemanagementpb.DisableServiceResponse
1064	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1065		return nil, err
1066	}
1067	return &resp, nil
1068}
1069
1070// Poll fetches the latest state of the long-running operation.
1071//
1072// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1073//
1074// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1075// the operation has completed with failure, the error is returned and op.Done will return true.
1076// If Poll succeeds and the operation has completed successfully,
1077// op.Done will return true, and the response of the operation is returned.
1078// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1079func (op *DisableServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.DisableServiceResponse, error) {
1080	var resp servicemanagementpb.DisableServiceResponse
1081	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1082		return nil, err
1083	}
1084	if !op.Done() {
1085		return nil, nil
1086	}
1087	return &resp, nil
1088}
1089
1090// Metadata returns metadata associated with the long-running operation.
1091// Metadata itself does not contact the server, but Poll does.
1092// To get the latest metadata, call this method after a successful call to Poll.
1093// If the metadata is not available, the returned metadata and error are both nil.
1094func (op *DisableServiceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
1095	var meta servicemanagementpb.OperationMetadata
1096	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1097		return nil, nil
1098	} else if err != nil {
1099		return nil, err
1100	}
1101	return &meta, nil
1102}
1103
1104// Done reports whether the long-running operation has completed.
1105func (op *DisableServiceOperation) Done() bool {
1106	return op.lro.Done()
1107}
1108
1109// Name returns the name of the long-running operation.
1110// The name is assigned by the server and is unique within the service from which the operation is created.
1111func (op *DisableServiceOperation) Name() string {
1112	return op.lro.Name()
1113}
1114
1115// EnableServiceOperation manages a long-running operation from EnableService.
1116type EnableServiceOperation struct {
1117	lro *longrunning.Operation
1118}
1119
1120// EnableServiceOperation returns a new EnableServiceOperation from a given name.
1121// The name must be that of a previously created EnableServiceOperation, possibly from a different process.
1122func (c *serviceManagerGRPCClient) EnableServiceOperation(name string) *EnableServiceOperation {
1123	return &EnableServiceOperation{
1124		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1125	}
1126}
1127
1128// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1129//
1130// See documentation of Poll for error-handling information.
1131func (op *EnableServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.EnableServiceResponse, error) {
1132	var resp servicemanagementpb.EnableServiceResponse
1133	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1134		return nil, err
1135	}
1136	return &resp, nil
1137}
1138
1139// Poll fetches the latest state of the long-running operation.
1140//
1141// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1142//
1143// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1144// the operation has completed with failure, the error is returned and op.Done will return true.
1145// If Poll succeeds and the operation has completed successfully,
1146// op.Done will return true, and the response of the operation is returned.
1147// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1148func (op *EnableServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.EnableServiceResponse, error) {
1149	var resp servicemanagementpb.EnableServiceResponse
1150	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1151		return nil, err
1152	}
1153	if !op.Done() {
1154		return nil, nil
1155	}
1156	return &resp, nil
1157}
1158
1159// Metadata returns metadata associated with the long-running operation.
1160// Metadata itself does not contact the server, but Poll does.
1161// To get the latest metadata, call this method after a successful call to Poll.
1162// If the metadata is not available, the returned metadata and error are both nil.
1163func (op *EnableServiceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
1164	var meta servicemanagementpb.OperationMetadata
1165	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1166		return nil, nil
1167	} else if err != nil {
1168		return nil, err
1169	}
1170	return &meta, nil
1171}
1172
1173// Done reports whether the long-running operation has completed.
1174func (op *EnableServiceOperation) Done() bool {
1175	return op.lro.Done()
1176}
1177
1178// Name returns the name of the long-running operation.
1179// The name is assigned by the server and is unique within the service from which the operation is created.
1180func (op *EnableServiceOperation) Name() string {
1181	return op.lro.Name()
1182}
1183
1184// SubmitConfigSourceOperation manages a long-running operation from SubmitConfigSource.
1185type SubmitConfigSourceOperation struct {
1186	lro *longrunning.Operation
1187}
1188
1189// SubmitConfigSourceOperation returns a new SubmitConfigSourceOperation from a given name.
1190// The name must be that of a previously created SubmitConfigSourceOperation, possibly from a different process.
1191func (c *serviceManagerGRPCClient) SubmitConfigSourceOperation(name string) *SubmitConfigSourceOperation {
1192	return &SubmitConfigSourceOperation{
1193		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1194	}
1195}
1196
1197// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1198//
1199// See documentation of Poll for error-handling information.
1200func (op *SubmitConfigSourceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.SubmitConfigSourceResponse, error) {
1201	var resp servicemanagementpb.SubmitConfigSourceResponse
1202	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1203		return nil, err
1204	}
1205	return &resp, nil
1206}
1207
1208// Poll fetches the latest state of the long-running operation.
1209//
1210// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1211//
1212// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1213// the operation has completed with failure, the error is returned and op.Done will return true.
1214// If Poll succeeds and the operation has completed successfully,
1215// op.Done will return true, and the response of the operation is returned.
1216// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1217func (op *SubmitConfigSourceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.SubmitConfigSourceResponse, error) {
1218	var resp servicemanagementpb.SubmitConfigSourceResponse
1219	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1220		return nil, err
1221	}
1222	if !op.Done() {
1223		return nil, nil
1224	}
1225	return &resp, nil
1226}
1227
1228// Metadata returns metadata associated with the long-running operation.
1229// Metadata itself does not contact the server, but Poll does.
1230// To get the latest metadata, call this method after a successful call to Poll.
1231// If the metadata is not available, the returned metadata and error are both nil.
1232func (op *SubmitConfigSourceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
1233	var meta servicemanagementpb.OperationMetadata
1234	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1235		return nil, nil
1236	} else if err != nil {
1237		return nil, err
1238	}
1239	return &meta, nil
1240}
1241
1242// Done reports whether the long-running operation has completed.
1243func (op *SubmitConfigSourceOperation) Done() bool {
1244	return op.lro.Done()
1245}
1246
1247// Name returns the name of the long-running operation.
1248// The name is assigned by the server and is unique within the service from which the operation is created.
1249func (op *SubmitConfigSourceOperation) Name() string {
1250	return op.lro.Name()
1251}
1252
1253// UndeleteServiceOperation manages a long-running operation from UndeleteService.
1254type UndeleteServiceOperation struct {
1255	lro *longrunning.Operation
1256}
1257
1258// UndeleteServiceOperation returns a new UndeleteServiceOperation from a given name.
1259// The name must be that of a previously created UndeleteServiceOperation, possibly from a different process.
1260func (c *serviceManagerGRPCClient) UndeleteServiceOperation(name string) *UndeleteServiceOperation {
1261	return &UndeleteServiceOperation{
1262		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1263	}
1264}
1265
1266// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1267//
1268// See documentation of Poll for error-handling information.
1269func (op *UndeleteServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.UndeleteServiceResponse, error) {
1270	var resp servicemanagementpb.UndeleteServiceResponse
1271	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1272		return nil, err
1273	}
1274	return &resp, nil
1275}
1276
1277// Poll fetches the latest state of the long-running operation.
1278//
1279// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1280//
1281// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1282// the operation has completed with failure, the error is returned and op.Done will return true.
1283// If Poll succeeds and the operation has completed successfully,
1284// op.Done will return true, and the response of the operation is returned.
1285// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1286func (op *UndeleteServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*servicemanagementpb.UndeleteServiceResponse, error) {
1287	var resp servicemanagementpb.UndeleteServiceResponse
1288	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1289		return nil, err
1290	}
1291	if !op.Done() {
1292		return nil, nil
1293	}
1294	return &resp, nil
1295}
1296
1297// Metadata returns metadata associated with the long-running operation.
1298// Metadata itself does not contact the server, but Poll does.
1299// To get the latest metadata, call this method after a successful call to Poll.
1300// If the metadata is not available, the returned metadata and error are both nil.
1301func (op *UndeleteServiceOperation) Metadata() (*servicemanagementpb.OperationMetadata, error) {
1302	var meta servicemanagementpb.OperationMetadata
1303	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1304		return nil, nil
1305	} else if err != nil {
1306		return nil, err
1307	}
1308	return &meta, nil
1309}
1310
1311// Done reports whether the long-running operation has completed.
1312func (op *UndeleteServiceOperation) Done() bool {
1313	return op.lro.Done()
1314}
1315
1316// Name returns the name of the long-running operation.
1317// The name is assigned by the server and is unique within the service from which the operation is created.
1318func (op *UndeleteServiceOperation) Name() string {
1319	return op.lro.Name()
1320}
1321
1322// ManagedServiceIterator manages a stream of *servicemanagementpb.ManagedService.
1323type ManagedServiceIterator struct {
1324	items    []*servicemanagementpb.ManagedService
1325	pageInfo *iterator.PageInfo
1326	nextFunc func() error
1327
1328	// Response is the raw response for the current page.
1329	// It must be cast to the RPC response type.
1330	// Calling Next() or InternalFetch() updates this value.
1331	Response interface{}
1332
1333	// InternalFetch is for use by the Google Cloud Libraries only.
1334	// It is not part of the stable interface of this package.
1335	//
1336	// InternalFetch returns results from a single call to the underlying RPC.
1337	// The number of results is no greater than pageSize.
1338	// If there are no more results, nextPageToken is empty and err is nil.
1339	InternalFetch func(pageSize int, pageToken string) (results []*servicemanagementpb.ManagedService, nextPageToken string, err error)
1340}
1341
1342// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1343func (it *ManagedServiceIterator) PageInfo() *iterator.PageInfo {
1344	return it.pageInfo
1345}
1346
1347// Next returns the next result. Its second return value is iterator.Done if there are no more
1348// results. Once Next returns Done, all subsequent calls will return Done.
1349func (it *ManagedServiceIterator) Next() (*servicemanagementpb.ManagedService, error) {
1350	var item *servicemanagementpb.ManagedService
1351	if err := it.nextFunc(); err != nil {
1352		return item, err
1353	}
1354	item = it.items[0]
1355	it.items = it.items[1:]
1356	return item, nil
1357}
1358
1359func (it *ManagedServiceIterator) bufLen() int {
1360	return len(it.items)
1361}
1362
1363func (it *ManagedServiceIterator) takeBuf() interface{} {
1364	b := it.items
1365	it.items = nil
1366	return b
1367}
1368
1369// RolloutIterator manages a stream of *servicemanagementpb.Rollout.
1370type RolloutIterator struct {
1371	items    []*servicemanagementpb.Rollout
1372	pageInfo *iterator.PageInfo
1373	nextFunc func() error
1374
1375	// Response is the raw response for the current page.
1376	// It must be cast to the RPC response type.
1377	// Calling Next() or InternalFetch() updates this value.
1378	Response interface{}
1379
1380	// InternalFetch is for use by the Google Cloud Libraries only.
1381	// It is not part of the stable interface of this package.
1382	//
1383	// InternalFetch returns results from a single call to the underlying RPC.
1384	// The number of results is no greater than pageSize.
1385	// If there are no more results, nextPageToken is empty and err is nil.
1386	InternalFetch func(pageSize int, pageToken string) (results []*servicemanagementpb.Rollout, nextPageToken string, err error)
1387}
1388
1389// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1390func (it *RolloutIterator) PageInfo() *iterator.PageInfo {
1391	return it.pageInfo
1392}
1393
1394// Next returns the next result. Its second return value is iterator.Done if there are no more
1395// results. Once Next returns Done, all subsequent calls will return Done.
1396func (it *RolloutIterator) Next() (*servicemanagementpb.Rollout, error) {
1397	var item *servicemanagementpb.Rollout
1398	if err := it.nextFunc(); err != nil {
1399		return item, err
1400	}
1401	item = it.items[0]
1402	it.items = it.items[1:]
1403	return item, nil
1404}
1405
1406func (it *RolloutIterator) bufLen() int {
1407	return len(it.items)
1408}
1409
1410func (it *RolloutIterator) takeBuf() interface{} {
1411	b := it.items
1412	it.items = nil
1413	return b
1414}
1415
1416// ServiceIterator manages a stream of *serviceconfigpb.Service.
1417type ServiceIterator struct {
1418	items    []*serviceconfigpb.Service
1419	pageInfo *iterator.PageInfo
1420	nextFunc func() error
1421
1422	// Response is the raw response for the current page.
1423	// It must be cast to the RPC response type.
1424	// Calling Next() or InternalFetch() updates this value.
1425	Response interface{}
1426
1427	// InternalFetch is for use by the Google Cloud Libraries only.
1428	// It is not part of the stable interface of this package.
1429	//
1430	// InternalFetch returns results from a single call to the underlying RPC.
1431	// The number of results is no greater than pageSize.
1432	// If there are no more results, nextPageToken is empty and err is nil.
1433	InternalFetch func(pageSize int, pageToken string) (results []*serviceconfigpb.Service, nextPageToken string, err error)
1434}
1435
1436// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1437func (it *ServiceIterator) PageInfo() *iterator.PageInfo {
1438	return it.pageInfo
1439}
1440
1441// Next returns the next result. Its second return value is iterator.Done if there are no more
1442// results. Once Next returns Done, all subsequent calls will return Done.
1443func (it *ServiceIterator) Next() (*serviceconfigpb.Service, error) {
1444	var item *serviceconfigpb.Service
1445	if err := it.nextFunc(); err != nil {
1446		return item, err
1447	}
1448	item = it.items[0]
1449	it.items = it.items[1:]
1450	return item, nil
1451}
1452
1453func (it *ServiceIterator) bufLen() int {
1454	return len(it.items)
1455}
1456
1457func (it *ServiceIterator) takeBuf() interface{} {
1458	b := it.items
1459	it.items = nil
1460	return b
1461}
1462