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 recommender
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	gax "github.com/googleapis/gax-go/v2"
27	"google.golang.org/api/iterator"
28	"google.golang.org/api/option"
29	"google.golang.org/api/option/internaloption"
30	gtransport "google.golang.org/api/transport/grpc"
31	recommenderpb "google.golang.org/genproto/googleapis/cloud/recommender/v1beta1"
32	"google.golang.org/grpc"
33	"google.golang.org/grpc/codes"
34	"google.golang.org/grpc/metadata"
35	"google.golang.org/protobuf/proto"
36)
37
38var newClientHook clientHook
39
40// CallOptions contains the retry settings for each method of Client.
41type CallOptions struct {
42	ListInsights                []gax.CallOption
43	GetInsight                  []gax.CallOption
44	MarkInsightAccepted         []gax.CallOption
45	ListRecommendations         []gax.CallOption
46	GetRecommendation           []gax.CallOption
47	MarkRecommendationClaimed   []gax.CallOption
48	MarkRecommendationSucceeded []gax.CallOption
49	MarkRecommendationFailed    []gax.CallOption
50}
51
52func defaultGRPCClientOptions() []option.ClientOption {
53	return []option.ClientOption{
54		internaloption.WithDefaultEndpoint("recommender.googleapis.com:443"),
55		internaloption.WithDefaultMTLSEndpoint("recommender.mtls.googleapis.com:443"),
56		internaloption.WithDefaultAudience("https://recommender.googleapis.com/"),
57		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
58		internaloption.EnableJwtWithScope(),
59		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
60		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
61			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
62	}
63}
64
65func defaultCallOptions() *CallOptions {
66	return &CallOptions{
67		ListInsights: []gax.CallOption{
68			gax.WithRetry(func() gax.Retryer {
69				return gax.OnCodes([]codes.Code{
70					codes.DeadlineExceeded,
71					codes.Unavailable,
72				}, gax.Backoff{
73					Initial:    100 * time.Millisecond,
74					Max:        60000 * time.Millisecond,
75					Multiplier: 1.30,
76				})
77			}),
78		},
79		GetInsight: []gax.CallOption{
80			gax.WithRetry(func() gax.Retryer {
81				return gax.OnCodes([]codes.Code{
82					codes.DeadlineExceeded,
83					codes.Unavailable,
84				}, gax.Backoff{
85					Initial:    100 * time.Millisecond,
86					Max:        60000 * time.Millisecond,
87					Multiplier: 1.30,
88				})
89			}),
90		},
91		MarkInsightAccepted: []gax.CallOption{},
92		ListRecommendations: []gax.CallOption{
93			gax.WithRetry(func() gax.Retryer {
94				return gax.OnCodes([]codes.Code{
95					codes.DeadlineExceeded,
96					codes.Unavailable,
97				}, gax.Backoff{
98					Initial:    100 * time.Millisecond,
99					Max:        60000 * time.Millisecond,
100					Multiplier: 1.30,
101				})
102			}),
103		},
104		GetRecommendation: []gax.CallOption{
105			gax.WithRetry(func() gax.Retryer {
106				return gax.OnCodes([]codes.Code{
107					codes.DeadlineExceeded,
108					codes.Unavailable,
109				}, gax.Backoff{
110					Initial:    100 * time.Millisecond,
111					Max:        60000 * time.Millisecond,
112					Multiplier: 1.30,
113				})
114			}),
115		},
116		MarkRecommendationClaimed:   []gax.CallOption{},
117		MarkRecommendationSucceeded: []gax.CallOption{},
118		MarkRecommendationFailed:    []gax.CallOption{},
119	}
120}
121
122// internalClient is an interface that defines the methods availaible from Recommender API.
123type internalClient interface {
124	Close() error
125	setGoogleClientInfo(...string)
126	Connection() *grpc.ClientConn
127	ListInsights(context.Context, *recommenderpb.ListInsightsRequest, ...gax.CallOption) *InsightIterator
128	GetInsight(context.Context, *recommenderpb.GetInsightRequest, ...gax.CallOption) (*recommenderpb.Insight, error)
129	MarkInsightAccepted(context.Context, *recommenderpb.MarkInsightAcceptedRequest, ...gax.CallOption) (*recommenderpb.Insight, error)
130	ListRecommendations(context.Context, *recommenderpb.ListRecommendationsRequest, ...gax.CallOption) *RecommendationIterator
131	GetRecommendation(context.Context, *recommenderpb.GetRecommendationRequest, ...gax.CallOption) (*recommenderpb.Recommendation, error)
132	MarkRecommendationClaimed(context.Context, *recommenderpb.MarkRecommendationClaimedRequest, ...gax.CallOption) (*recommenderpb.Recommendation, error)
133	MarkRecommendationSucceeded(context.Context, *recommenderpb.MarkRecommendationSucceededRequest, ...gax.CallOption) (*recommenderpb.Recommendation, error)
134	MarkRecommendationFailed(context.Context, *recommenderpb.MarkRecommendationFailedRequest, ...gax.CallOption) (*recommenderpb.Recommendation, error)
135}
136
137// Client is a client for interacting with Recommender API.
138// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
139//
140// Provides insights and recommendations for cloud customers for various
141// categories like performance optimization, cost savings, reliability, feature
142// discovery, etc. Insights and recommendations are generated automatically
143// based on analysis of user resources, configuration and monitoring metrics.
144type Client struct {
145	// The internal transport-dependent client.
146	internalClient internalClient
147
148	// The call options for this service.
149	CallOptions *CallOptions
150}
151
152// Wrapper methods routed to the internal client.
153
154// Close closes the connection to the API service. The user should invoke this when
155// the client is no longer required.
156func (c *Client) Close() error {
157	return c.internalClient.Close()
158}
159
160// setGoogleClientInfo sets the name and version of the application in
161// the `x-goog-api-client` header passed on each request. Intended for
162// use by Google-written clients.
163func (c *Client) setGoogleClientInfo(keyval ...string) {
164	c.internalClient.setGoogleClientInfo(keyval...)
165}
166
167// Connection returns a connection to the API service.
168//
169// Deprecated.
170func (c *Client) Connection() *grpc.ClientConn {
171	return c.internalClient.Connection()
172}
173
174// ListInsights lists insights for a Cloud project. Requires the recommender.*.list IAM
175// permission for the specified insight type.
176func (c *Client) ListInsights(ctx context.Context, req *recommenderpb.ListInsightsRequest, opts ...gax.CallOption) *InsightIterator {
177	return c.internalClient.ListInsights(ctx, req, opts...)
178}
179
180// GetInsight gets the requested insight. Requires the recommender.*.get IAM permission
181// for the specified insight type.
182func (c *Client) GetInsight(ctx context.Context, req *recommenderpb.GetInsightRequest, opts ...gax.CallOption) (*recommenderpb.Insight, error) {
183	return c.internalClient.GetInsight(ctx, req, opts...)
184}
185
186// MarkInsightAccepted marks the Insight State as Accepted. Users can use this method to
187// indicate to the Recommender API that they have applied some action based
188// on the insight. This stops the insight content from being updated.
189//
190// MarkInsightAccepted can be applied to insights in ACTIVE state. Requires
191// the recommender.*.update IAM permission for the specified insight.
192func (c *Client) MarkInsightAccepted(ctx context.Context, req *recommenderpb.MarkInsightAcceptedRequest, opts ...gax.CallOption) (*recommenderpb.Insight, error) {
193	return c.internalClient.MarkInsightAccepted(ctx, req, opts...)
194}
195
196// ListRecommendations lists recommendations for a Cloud project. Requires the recommender.*.list
197// IAM permission for the specified recommender.
198func (c *Client) ListRecommendations(ctx context.Context, req *recommenderpb.ListRecommendationsRequest, opts ...gax.CallOption) *RecommendationIterator {
199	return c.internalClient.ListRecommendations(ctx, req, opts...)
200}
201
202// GetRecommendation gets the requested recommendation. Requires the recommender.*.get
203// IAM permission for the specified recommender.
204func (c *Client) GetRecommendation(ctx context.Context, req *recommenderpb.GetRecommendationRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
205	return c.internalClient.GetRecommendation(ctx, req, opts...)
206}
207
208// MarkRecommendationClaimed marks the Recommendation State as Claimed. Users can use this method to
209// indicate to the Recommender API that they are starting to apply the
210// recommendation themselves. This stops the recommendation content from being
211// updated. Associated insights are frozen and placed in the ACCEPTED state.
212//
213// MarkRecommendationClaimed can be applied to recommendations in CLAIMED or
214// ACTIVE state.
215//
216// Requires the recommender.*.update IAM permission for the specified
217// recommender.
218func (c *Client) MarkRecommendationClaimed(ctx context.Context, req *recommenderpb.MarkRecommendationClaimedRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
219	return c.internalClient.MarkRecommendationClaimed(ctx, req, opts...)
220}
221
222// MarkRecommendationSucceeded marks the Recommendation State as Succeeded. Users can use this method to
223// indicate to the Recommender API that they have applied the recommendation
224// themselves, and the operation was successful. This stops the recommendation
225// content from being updated. Associated insights are frozen and placed in
226// the ACCEPTED state.
227//
228// MarkRecommendationSucceeded can be applied to recommendations in ACTIVE,
229// CLAIMED, SUCCEEDED, or FAILED state.
230//
231// Requires the recommender.*.update IAM permission for the specified
232// recommender.
233func (c *Client) MarkRecommendationSucceeded(ctx context.Context, req *recommenderpb.MarkRecommendationSucceededRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
234	return c.internalClient.MarkRecommendationSucceeded(ctx, req, opts...)
235}
236
237// MarkRecommendationFailed marks the Recommendation State as Failed. Users can use this method to
238// indicate to the Recommender API that they have applied the recommendation
239// themselves, and the operation failed. This stops the recommendation content
240// from being updated. Associated insights are frozen and placed in the
241// ACCEPTED state.
242//
243// MarkRecommendationFailed can be applied to recommendations in ACTIVE,
244// CLAIMED, SUCCEEDED, or FAILED state.
245//
246// Requires the recommender.*.update IAM permission for the specified
247// recommender.
248func (c *Client) MarkRecommendationFailed(ctx context.Context, req *recommenderpb.MarkRecommendationFailedRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
249	return c.internalClient.MarkRecommendationFailed(ctx, req, opts...)
250}
251
252// gRPCClient is a client for interacting with Recommender API over gRPC transport.
253//
254// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
255type gRPCClient struct {
256	// Connection pool of gRPC connections to the service.
257	connPool gtransport.ConnPool
258
259	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
260	disableDeadlines bool
261
262	// Points back to the CallOptions field of the containing Client
263	CallOptions **CallOptions
264
265	// The gRPC API client.
266	client recommenderpb.RecommenderClient
267
268	// The x-goog-* metadata to be sent with each request.
269	xGoogMetadata metadata.MD
270}
271
272// NewClient creates a new recommender client based on gRPC.
273// The returned client must be Closed when it is done being used to clean up its underlying connections.
274//
275// Provides insights and recommendations for cloud customers for various
276// categories like performance optimization, cost savings, reliability, feature
277// discovery, etc. Insights and recommendations are generated automatically
278// based on analysis of user resources, configuration and monitoring metrics.
279func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
280	clientOpts := defaultGRPCClientOptions()
281	if newClientHook != nil {
282		hookOpts, err := newClientHook(ctx, clientHookParams{})
283		if err != nil {
284			return nil, err
285		}
286		clientOpts = append(clientOpts, hookOpts...)
287	}
288
289	disableDeadlines, err := checkDisableDeadlines()
290	if err != nil {
291		return nil, err
292	}
293
294	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
295	if err != nil {
296		return nil, err
297	}
298	client := Client{CallOptions: defaultCallOptions()}
299
300	c := &gRPCClient{
301		connPool:         connPool,
302		disableDeadlines: disableDeadlines,
303		client:           recommenderpb.NewRecommenderClient(connPool),
304		CallOptions:      &client.CallOptions,
305	}
306	c.setGoogleClientInfo()
307
308	client.internalClient = c
309
310	return &client, nil
311}
312
313// Connection returns a connection to the API service.
314//
315// Deprecated.
316func (c *gRPCClient) Connection() *grpc.ClientConn {
317	return c.connPool.Conn()
318}
319
320// setGoogleClientInfo sets the name and version of the application in
321// the `x-goog-api-client` header passed on each request. Intended for
322// use by Google-written clients.
323func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
324	kv := append([]string{"gl-go", versionGo()}, keyval...)
325	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
326	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
327}
328
329// Close closes the connection to the API service. The user should invoke this when
330// the client is no longer required.
331func (c *gRPCClient) Close() error {
332	return c.connPool.Close()
333}
334
335func (c *gRPCClient) ListInsights(ctx context.Context, req *recommenderpb.ListInsightsRequest, opts ...gax.CallOption) *InsightIterator {
336	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
337	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
338	opts = append((*c.CallOptions).ListInsights[0:len((*c.CallOptions).ListInsights):len((*c.CallOptions).ListInsights)], opts...)
339	it := &InsightIterator{}
340	req = proto.Clone(req).(*recommenderpb.ListInsightsRequest)
341	it.InternalFetch = func(pageSize int, pageToken string) ([]*recommenderpb.Insight, string, error) {
342		resp := &recommenderpb.ListInsightsResponse{}
343		if pageToken != "" {
344			req.PageToken = pageToken
345		}
346		if pageSize > math.MaxInt32 {
347			req.PageSize = math.MaxInt32
348		} else if pageSize != 0 {
349			req.PageSize = int32(pageSize)
350		}
351		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
352			var err error
353			resp, err = c.client.ListInsights(ctx, req, settings.GRPC...)
354			return err
355		}, opts...)
356		if err != nil {
357			return nil, "", err
358		}
359
360		it.Response = resp
361		return resp.GetInsights(), resp.GetNextPageToken(), nil
362	}
363	fetch := func(pageSize int, pageToken string) (string, error) {
364		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
365		if err != nil {
366			return "", err
367		}
368		it.items = append(it.items, items...)
369		return nextPageToken, nil
370	}
371
372	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
373	it.pageInfo.MaxSize = int(req.GetPageSize())
374	it.pageInfo.Token = req.GetPageToken()
375
376	return it
377}
378
379func (c *gRPCClient) GetInsight(ctx context.Context, req *recommenderpb.GetInsightRequest, opts ...gax.CallOption) (*recommenderpb.Insight, error) {
380	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
381		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
382		defer cancel()
383		ctx = cctx
384	}
385	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
386	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
387	opts = append((*c.CallOptions).GetInsight[0:len((*c.CallOptions).GetInsight):len((*c.CallOptions).GetInsight)], opts...)
388	var resp *recommenderpb.Insight
389	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
390		var err error
391		resp, err = c.client.GetInsight(ctx, req, settings.GRPC...)
392		return err
393	}, opts...)
394	if err != nil {
395		return nil, err
396	}
397	return resp, nil
398}
399
400func (c *gRPCClient) MarkInsightAccepted(ctx context.Context, req *recommenderpb.MarkInsightAcceptedRequest, opts ...gax.CallOption) (*recommenderpb.Insight, error) {
401	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
402		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
403		defer cancel()
404		ctx = cctx
405	}
406	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
407	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
408	opts = append((*c.CallOptions).MarkInsightAccepted[0:len((*c.CallOptions).MarkInsightAccepted):len((*c.CallOptions).MarkInsightAccepted)], opts...)
409	var resp *recommenderpb.Insight
410	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
411		var err error
412		resp, err = c.client.MarkInsightAccepted(ctx, req, settings.GRPC...)
413		return err
414	}, opts...)
415	if err != nil {
416		return nil, err
417	}
418	return resp, nil
419}
420
421func (c *gRPCClient) ListRecommendations(ctx context.Context, req *recommenderpb.ListRecommendationsRequest, opts ...gax.CallOption) *RecommendationIterator {
422	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
423	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
424	opts = append((*c.CallOptions).ListRecommendations[0:len((*c.CallOptions).ListRecommendations):len((*c.CallOptions).ListRecommendations)], opts...)
425	it := &RecommendationIterator{}
426	req = proto.Clone(req).(*recommenderpb.ListRecommendationsRequest)
427	it.InternalFetch = func(pageSize int, pageToken string) ([]*recommenderpb.Recommendation, string, error) {
428		resp := &recommenderpb.ListRecommendationsResponse{}
429		if pageToken != "" {
430			req.PageToken = pageToken
431		}
432		if pageSize > math.MaxInt32 {
433			req.PageSize = math.MaxInt32
434		} else if pageSize != 0 {
435			req.PageSize = int32(pageSize)
436		}
437		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
438			var err error
439			resp, err = c.client.ListRecommendations(ctx, req, settings.GRPC...)
440			return err
441		}, opts...)
442		if err != nil {
443			return nil, "", err
444		}
445
446		it.Response = resp
447		return resp.GetRecommendations(), resp.GetNextPageToken(), nil
448	}
449	fetch := func(pageSize int, pageToken string) (string, error) {
450		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
451		if err != nil {
452			return "", err
453		}
454		it.items = append(it.items, items...)
455		return nextPageToken, nil
456	}
457
458	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
459	it.pageInfo.MaxSize = int(req.GetPageSize())
460	it.pageInfo.Token = req.GetPageToken()
461
462	return it
463}
464
465func (c *gRPCClient) GetRecommendation(ctx context.Context, req *recommenderpb.GetRecommendationRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
466	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
467		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
468		defer cancel()
469		ctx = cctx
470	}
471	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
472	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
473	opts = append((*c.CallOptions).GetRecommendation[0:len((*c.CallOptions).GetRecommendation):len((*c.CallOptions).GetRecommendation)], opts...)
474	var resp *recommenderpb.Recommendation
475	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
476		var err error
477		resp, err = c.client.GetRecommendation(ctx, req, settings.GRPC...)
478		return err
479	}, opts...)
480	if err != nil {
481		return nil, err
482	}
483	return resp, nil
484}
485
486func (c *gRPCClient) MarkRecommendationClaimed(ctx context.Context, req *recommenderpb.MarkRecommendationClaimedRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
487	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
488		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
489		defer cancel()
490		ctx = cctx
491	}
492	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
493	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
494	opts = append((*c.CallOptions).MarkRecommendationClaimed[0:len((*c.CallOptions).MarkRecommendationClaimed):len((*c.CallOptions).MarkRecommendationClaimed)], opts...)
495	var resp *recommenderpb.Recommendation
496	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
497		var err error
498		resp, err = c.client.MarkRecommendationClaimed(ctx, req, settings.GRPC...)
499		return err
500	}, opts...)
501	if err != nil {
502		return nil, err
503	}
504	return resp, nil
505}
506
507func (c *gRPCClient) MarkRecommendationSucceeded(ctx context.Context, req *recommenderpb.MarkRecommendationSucceededRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
508	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
509		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
510		defer cancel()
511		ctx = cctx
512	}
513	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
514	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
515	opts = append((*c.CallOptions).MarkRecommendationSucceeded[0:len((*c.CallOptions).MarkRecommendationSucceeded):len((*c.CallOptions).MarkRecommendationSucceeded)], opts...)
516	var resp *recommenderpb.Recommendation
517	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
518		var err error
519		resp, err = c.client.MarkRecommendationSucceeded(ctx, req, settings.GRPC...)
520		return err
521	}, opts...)
522	if err != nil {
523		return nil, err
524	}
525	return resp, nil
526}
527
528func (c *gRPCClient) MarkRecommendationFailed(ctx context.Context, req *recommenderpb.MarkRecommendationFailedRequest, opts ...gax.CallOption) (*recommenderpb.Recommendation, error) {
529	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
530		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
531		defer cancel()
532		ctx = cctx
533	}
534	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
535	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
536	opts = append((*c.CallOptions).MarkRecommendationFailed[0:len((*c.CallOptions).MarkRecommendationFailed):len((*c.CallOptions).MarkRecommendationFailed)], opts...)
537	var resp *recommenderpb.Recommendation
538	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
539		var err error
540		resp, err = c.client.MarkRecommendationFailed(ctx, req, settings.GRPC...)
541		return err
542	}, opts...)
543	if err != nil {
544		return nil, err
545	}
546	return resp, nil
547}
548
549// InsightIterator manages a stream of *recommenderpb.Insight.
550type InsightIterator struct {
551	items    []*recommenderpb.Insight
552	pageInfo *iterator.PageInfo
553	nextFunc func() error
554
555	// Response is the raw response for the current page.
556	// It must be cast to the RPC response type.
557	// Calling Next() or InternalFetch() updates this value.
558	Response interface{}
559
560	// InternalFetch is for use by the Google Cloud Libraries only.
561	// It is not part of the stable interface of this package.
562	//
563	// InternalFetch returns results from a single call to the underlying RPC.
564	// The number of results is no greater than pageSize.
565	// If there are no more results, nextPageToken is empty and err is nil.
566	InternalFetch func(pageSize int, pageToken string) (results []*recommenderpb.Insight, nextPageToken string, err error)
567}
568
569// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
570func (it *InsightIterator) PageInfo() *iterator.PageInfo {
571	return it.pageInfo
572}
573
574// Next returns the next result. Its second return value is iterator.Done if there are no more
575// results. Once Next returns Done, all subsequent calls will return Done.
576func (it *InsightIterator) Next() (*recommenderpb.Insight, error) {
577	var item *recommenderpb.Insight
578	if err := it.nextFunc(); err != nil {
579		return item, err
580	}
581	item = it.items[0]
582	it.items = it.items[1:]
583	return item, nil
584}
585
586func (it *InsightIterator) bufLen() int {
587	return len(it.items)
588}
589
590func (it *InsightIterator) takeBuf() interface{} {
591	b := it.items
592	it.items = nil
593	return b
594}
595
596// RecommendationIterator manages a stream of *recommenderpb.Recommendation.
597type RecommendationIterator struct {
598	items    []*recommenderpb.Recommendation
599	pageInfo *iterator.PageInfo
600	nextFunc func() error
601
602	// Response is the raw response for the current page.
603	// It must be cast to the RPC response type.
604	// Calling Next() or InternalFetch() updates this value.
605	Response interface{}
606
607	// InternalFetch is for use by the Google Cloud Libraries only.
608	// It is not part of the stable interface of this package.
609	//
610	// InternalFetch returns results from a single call to the underlying RPC.
611	// The number of results is no greater than pageSize.
612	// If there are no more results, nextPageToken is empty and err is nil.
613	InternalFetch func(pageSize int, pageToken string) (results []*recommenderpb.Recommendation, nextPageToken string, err error)
614}
615
616// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
617func (it *RecommendationIterator) PageInfo() *iterator.PageInfo {
618	return it.pageInfo
619}
620
621// Next returns the next result. Its second return value is iterator.Done if there are no more
622// results. Once Next returns Done, all subsequent calls will return Done.
623func (it *RecommendationIterator) Next() (*recommenderpb.Recommendation, error) {
624	var item *recommenderpb.Recommendation
625	if err := it.nextFunc(); err != nil {
626		return item, err
627	}
628	item = it.items[0]
629	it.items = it.items[1:]
630	return item, nil
631}
632
633func (it *RecommendationIterator) bufLen() int {
634	return len(it.items)
635}
636
637func (it *RecommendationIterator) takeBuf() interface{} {
638	b := it.items
639	it.items = nil
640	return b
641}
642