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 securitycenter
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	"github.com/golang/protobuf/proto"
29	emptypb "github.com/golang/protobuf/ptypes/empty"
30	gax "github.com/googleapis/gax-go/v2"
31	"google.golang.org/api/iterator"
32	"google.golang.org/api/option"
33	"google.golang.org/api/option/internaloption"
34	gtransport "google.golang.org/api/transport/grpc"
35	securitycenterpb "google.golang.org/genproto/googleapis/cloud/securitycenter/v1p1beta1"
36	iampb "google.golang.org/genproto/googleapis/iam/v1"
37	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
38	"google.golang.org/grpc"
39	"google.golang.org/grpc/codes"
40	"google.golang.org/grpc/metadata"
41)
42
43var newClientHook clientHook
44
45// CallOptions contains the retry settings for each method of Client.
46type CallOptions struct {
47	CreateSource               []gax.CallOption
48	CreateFinding              []gax.CallOption
49	CreateNotificationConfig   []gax.CallOption
50	DeleteNotificationConfig   []gax.CallOption
51	GetIamPolicy               []gax.CallOption
52	GetNotificationConfig      []gax.CallOption
53	GetOrganizationSettings    []gax.CallOption
54	GetSource                  []gax.CallOption
55	GroupAssets                []gax.CallOption
56	GroupFindings              []gax.CallOption
57	ListAssets                 []gax.CallOption
58	ListFindings               []gax.CallOption
59	ListNotificationConfigs    []gax.CallOption
60	ListSources                []gax.CallOption
61	RunAssetDiscovery          []gax.CallOption
62	SetFindingState            []gax.CallOption
63	SetIamPolicy               []gax.CallOption
64	TestIamPermissions         []gax.CallOption
65	UpdateFinding              []gax.CallOption
66	UpdateNotificationConfig   []gax.CallOption
67	UpdateOrganizationSettings []gax.CallOption
68	UpdateSource               []gax.CallOption
69	UpdateSecurityMarks        []gax.CallOption
70}
71
72func defaultClientOptions() []option.ClientOption {
73	return []option.ClientOption{
74		internaloption.WithDefaultEndpoint("securitycenter.googleapis.com:443"),
75		internaloption.WithDefaultMTLSEndpoint("securitycenter.mtls.googleapis.com:443"),
76		internaloption.WithDefaultAudience("https://securitycenter.googleapis.com/"),
77		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
78		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
79		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
80			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
81	}
82}
83
84func defaultCallOptions() *CallOptions {
85	return &CallOptions{
86		CreateSource:             []gax.CallOption{},
87		CreateFinding:            []gax.CallOption{},
88		CreateNotificationConfig: []gax.CallOption{},
89		DeleteNotificationConfig: []gax.CallOption{},
90		GetIamPolicy: []gax.CallOption{
91			gax.WithRetry(func() gax.Retryer {
92				return gax.OnCodes([]codes.Code{
93					codes.DeadlineExceeded,
94					codes.Unavailable,
95				}, gax.Backoff{
96					Initial:    100 * time.Millisecond,
97					Max:        60000 * time.Millisecond,
98					Multiplier: 1.30,
99				})
100			}),
101		},
102		GetNotificationConfig: []gax.CallOption{
103			gax.WithRetry(func() gax.Retryer {
104				return gax.OnCodes([]codes.Code{
105					codes.DeadlineExceeded,
106					codes.Unavailable,
107				}, gax.Backoff{
108					Initial:    100 * time.Millisecond,
109					Max:        60000 * time.Millisecond,
110					Multiplier: 1.30,
111				})
112			}),
113		},
114		GetOrganizationSettings: []gax.CallOption{
115			gax.WithRetry(func() gax.Retryer {
116				return gax.OnCodes([]codes.Code{
117					codes.DeadlineExceeded,
118					codes.Unavailable,
119				}, gax.Backoff{
120					Initial:    100 * time.Millisecond,
121					Max:        60000 * time.Millisecond,
122					Multiplier: 1.30,
123				})
124			}),
125		},
126		GetSource: []gax.CallOption{
127			gax.WithRetry(func() gax.Retryer {
128				return gax.OnCodes([]codes.Code{
129					codes.DeadlineExceeded,
130					codes.Unavailable,
131				}, gax.Backoff{
132					Initial:    100 * time.Millisecond,
133					Max:        60000 * time.Millisecond,
134					Multiplier: 1.30,
135				})
136			}),
137		},
138		GroupAssets: []gax.CallOption{
139			gax.WithRetry(func() gax.Retryer {
140				return gax.OnCodes([]codes.Code{
141					codes.DeadlineExceeded,
142					codes.Unavailable,
143				}, gax.Backoff{
144					Initial:    100 * time.Millisecond,
145					Max:        60000 * time.Millisecond,
146					Multiplier: 1.30,
147				})
148			}),
149		},
150		GroupFindings: []gax.CallOption{
151			gax.WithRetry(func() gax.Retryer {
152				return gax.OnCodes([]codes.Code{
153					codes.DeadlineExceeded,
154					codes.Unavailable,
155				}, gax.Backoff{
156					Initial:    100 * time.Millisecond,
157					Max:        60000 * time.Millisecond,
158					Multiplier: 1.30,
159				})
160			}),
161		},
162		ListAssets: []gax.CallOption{
163			gax.WithRetry(func() gax.Retryer {
164				return gax.OnCodes([]codes.Code{
165					codes.DeadlineExceeded,
166					codes.Unavailable,
167				}, gax.Backoff{
168					Initial:    100 * time.Millisecond,
169					Max:        60000 * time.Millisecond,
170					Multiplier: 1.30,
171				})
172			}),
173		},
174		ListFindings: []gax.CallOption{
175			gax.WithRetry(func() gax.Retryer {
176				return gax.OnCodes([]codes.Code{
177					codes.DeadlineExceeded,
178					codes.Unavailable,
179				}, gax.Backoff{
180					Initial:    100 * time.Millisecond,
181					Max:        60000 * time.Millisecond,
182					Multiplier: 1.30,
183				})
184			}),
185		},
186		ListNotificationConfigs: []gax.CallOption{
187			gax.WithRetry(func() gax.Retryer {
188				return gax.OnCodes([]codes.Code{
189					codes.DeadlineExceeded,
190					codes.Unavailable,
191				}, gax.Backoff{
192					Initial:    100 * time.Millisecond,
193					Max:        60000 * time.Millisecond,
194					Multiplier: 1.30,
195				})
196			}),
197		},
198		ListSources: []gax.CallOption{
199			gax.WithRetry(func() gax.Retryer {
200				return gax.OnCodes([]codes.Code{
201					codes.DeadlineExceeded,
202					codes.Unavailable,
203				}, gax.Backoff{
204					Initial:    100 * time.Millisecond,
205					Max:        60000 * time.Millisecond,
206					Multiplier: 1.30,
207				})
208			}),
209		},
210		RunAssetDiscovery: []gax.CallOption{},
211		SetFindingState:   []gax.CallOption{},
212		SetIamPolicy:      []gax.CallOption{},
213		TestIamPermissions: []gax.CallOption{
214			gax.WithRetry(func() gax.Retryer {
215				return gax.OnCodes([]codes.Code{
216					codes.DeadlineExceeded,
217					codes.Unavailable,
218				}, gax.Backoff{
219					Initial:    100 * time.Millisecond,
220					Max:        60000 * time.Millisecond,
221					Multiplier: 1.30,
222				})
223			}),
224		},
225		UpdateFinding:              []gax.CallOption{},
226		UpdateNotificationConfig:   []gax.CallOption{},
227		UpdateOrganizationSettings: []gax.CallOption{},
228		UpdateSource:               []gax.CallOption{},
229		UpdateSecurityMarks:        []gax.CallOption{},
230	}
231}
232
233// Client is a client for interacting with Security Command Center API.
234//
235// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
236type Client struct {
237	// Connection pool of gRPC connections to the service.
238	connPool gtransport.ConnPool
239
240	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
241	disableDeadlines bool
242
243	// The gRPC API client.
244	client securitycenterpb.SecurityCenterClient
245
246	// LROClient is used internally to handle longrunning operations.
247	// It is exposed so that its CallOptions can be modified if required.
248	// Users should not Close this client.
249	LROClient *lroauto.OperationsClient
250
251	// The call options for this service.
252	CallOptions *CallOptions
253
254	// The x-goog-* metadata to be sent with each request.
255	xGoogMetadata metadata.MD
256}
257
258// NewClient creates a new security center client.
259//
260// V1p1Beta1 APIs for Security Center service.
261func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
262	clientOpts := defaultClientOptions()
263
264	if newClientHook != nil {
265		hookOpts, err := newClientHook(ctx, clientHookParams{})
266		if err != nil {
267			return nil, err
268		}
269		clientOpts = append(clientOpts, hookOpts...)
270	}
271
272	disableDeadlines, err := checkDisableDeadlines()
273	if err != nil {
274		return nil, err
275	}
276
277	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
278	if err != nil {
279		return nil, err
280	}
281	c := &Client{
282		connPool:         connPool,
283		disableDeadlines: disableDeadlines,
284		CallOptions:      defaultCallOptions(),
285
286		client: securitycenterpb.NewSecurityCenterClient(connPool),
287	}
288	c.setGoogleClientInfo()
289
290	c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
291	if err != nil {
292		// This error "should not happen", since we are just reusing old connection pool
293		// and never actually need to dial.
294		// If this does happen, we could leak connp. However, we cannot close conn:
295		// If the user invoked the constructor with option.WithGRPCConn,
296		// we would close a connection that's still in use.
297		// TODO: investigate error conditions.
298		return nil, err
299	}
300	return c, nil
301}
302
303// Connection returns a connection to the API service.
304//
305// Deprecated.
306func (c *Client) Connection() *grpc.ClientConn {
307	return c.connPool.Conn()
308}
309
310// Close closes the connection to the API service. The user should invoke this when
311// the client is no longer required.
312func (c *Client) Close() error {
313	return c.connPool.Close()
314}
315
316// setGoogleClientInfo sets the name and version of the application in
317// the `x-goog-api-client` header passed on each request. Intended for
318// use by Google-written clients.
319func (c *Client) setGoogleClientInfo(keyval ...string) {
320	kv := append([]string{"gl-go", versionGo()}, keyval...)
321	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
322	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
323}
324
325// CreateSource creates a source.
326func (c *Client) CreateSource(ctx context.Context, req *securitycenterpb.CreateSourceRequest, opts ...gax.CallOption) (*securitycenterpb.Source, error) {
327	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
328		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
329		defer cancel()
330		ctx = cctx
331	}
332	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
333	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
334	opts = append(c.CallOptions.CreateSource[0:len(c.CallOptions.CreateSource):len(c.CallOptions.CreateSource)], opts...)
335	var resp *securitycenterpb.Source
336	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
337		var err error
338		resp, err = c.client.CreateSource(ctx, req, settings.GRPC...)
339		return err
340	}, opts...)
341	if err != nil {
342		return nil, err
343	}
344	return resp, nil
345}
346
347// CreateFinding creates a finding. The corresponding source must exist for finding
348// creation to succeed.
349func (c *Client) CreateFinding(ctx context.Context, req *securitycenterpb.CreateFindingRequest, opts ...gax.CallOption) (*securitycenterpb.Finding, error) {
350	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
351		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
352		defer cancel()
353		ctx = cctx
354	}
355	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
356	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
357	opts = append(c.CallOptions.CreateFinding[0:len(c.CallOptions.CreateFinding):len(c.CallOptions.CreateFinding)], opts...)
358	var resp *securitycenterpb.Finding
359	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
360		var err error
361		resp, err = c.client.CreateFinding(ctx, req, settings.GRPC...)
362		return err
363	}, opts...)
364	if err != nil {
365		return nil, err
366	}
367	return resp, nil
368}
369
370// CreateNotificationConfig creates a notification config.
371func (c *Client) CreateNotificationConfig(ctx context.Context, req *securitycenterpb.CreateNotificationConfigRequest, opts ...gax.CallOption) (*securitycenterpb.NotificationConfig, error) {
372	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
373		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
374		defer cancel()
375		ctx = cctx
376	}
377	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
378	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
379	opts = append(c.CallOptions.CreateNotificationConfig[0:len(c.CallOptions.CreateNotificationConfig):len(c.CallOptions.CreateNotificationConfig)], opts...)
380	var resp *securitycenterpb.NotificationConfig
381	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
382		var err error
383		resp, err = c.client.CreateNotificationConfig(ctx, req, settings.GRPC...)
384		return err
385	}, opts...)
386	if err != nil {
387		return nil, err
388	}
389	return resp, nil
390}
391
392// DeleteNotificationConfig deletes a notification config.
393func (c *Client) DeleteNotificationConfig(ctx context.Context, req *securitycenterpb.DeleteNotificationConfigRequest, opts ...gax.CallOption) error {
394	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
395		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
396		defer cancel()
397		ctx = cctx
398	}
399	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
400	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
401	opts = append(c.CallOptions.DeleteNotificationConfig[0:len(c.CallOptions.DeleteNotificationConfig):len(c.CallOptions.DeleteNotificationConfig)], opts...)
402	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
403		var err error
404		_, err = c.client.DeleteNotificationConfig(ctx, req, settings.GRPC...)
405		return err
406	}, opts...)
407	return err
408}
409
410// GetIamPolicy gets the access control policy on the specified Source.
411func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
412	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
413		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
414		defer cancel()
415		ctx = cctx
416	}
417	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
418	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
419	opts = append(c.CallOptions.GetIamPolicy[0:len(c.CallOptions.GetIamPolicy):len(c.CallOptions.GetIamPolicy)], opts...)
420	var resp *iampb.Policy
421	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
422		var err error
423		resp, err = c.client.GetIamPolicy(ctx, req, settings.GRPC...)
424		return err
425	}, opts...)
426	if err != nil {
427		return nil, err
428	}
429	return resp, nil
430}
431
432// GetNotificationConfig gets a notification config.
433func (c *Client) GetNotificationConfig(ctx context.Context, req *securitycenterpb.GetNotificationConfigRequest, opts ...gax.CallOption) (*securitycenterpb.NotificationConfig, error) {
434	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
435		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
436		defer cancel()
437		ctx = cctx
438	}
439	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
440	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
441	opts = append(c.CallOptions.GetNotificationConfig[0:len(c.CallOptions.GetNotificationConfig):len(c.CallOptions.GetNotificationConfig)], opts...)
442	var resp *securitycenterpb.NotificationConfig
443	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
444		var err error
445		resp, err = c.client.GetNotificationConfig(ctx, req, settings.GRPC...)
446		return err
447	}, opts...)
448	if err != nil {
449		return nil, err
450	}
451	return resp, nil
452}
453
454// GetOrganizationSettings gets the settings for an organization.
455func (c *Client) GetOrganizationSettings(ctx context.Context, req *securitycenterpb.GetOrganizationSettingsRequest, opts ...gax.CallOption) (*securitycenterpb.OrganizationSettings, error) {
456	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
457		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
458		defer cancel()
459		ctx = cctx
460	}
461	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
462	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
463	opts = append(c.CallOptions.GetOrganizationSettings[0:len(c.CallOptions.GetOrganizationSettings):len(c.CallOptions.GetOrganizationSettings)], opts...)
464	var resp *securitycenterpb.OrganizationSettings
465	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
466		var err error
467		resp, err = c.client.GetOrganizationSettings(ctx, req, settings.GRPC...)
468		return err
469	}, opts...)
470	if err != nil {
471		return nil, err
472	}
473	return resp, nil
474}
475
476// GetSource gets a source.
477func (c *Client) GetSource(ctx context.Context, req *securitycenterpb.GetSourceRequest, opts ...gax.CallOption) (*securitycenterpb.Source, error) {
478	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
479		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
480		defer cancel()
481		ctx = cctx
482	}
483	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
484	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
485	opts = append(c.CallOptions.GetSource[0:len(c.CallOptions.GetSource):len(c.CallOptions.GetSource)], opts...)
486	var resp *securitycenterpb.Source
487	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
488		var err error
489		resp, err = c.client.GetSource(ctx, req, settings.GRPC...)
490		return err
491	}, opts...)
492	if err != nil {
493		return nil, err
494	}
495	return resp, nil
496}
497
498// GroupAssets filters an organization’s assets and  groups them by their specified
499// properties.
500func (c *Client) GroupAssets(ctx context.Context, req *securitycenterpb.GroupAssetsRequest, opts ...gax.CallOption) *GroupResultIterator {
501	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
502	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
503	opts = append(c.CallOptions.GroupAssets[0:len(c.CallOptions.GroupAssets):len(c.CallOptions.GroupAssets)], opts...)
504	it := &GroupResultIterator{}
505	req = proto.Clone(req).(*securitycenterpb.GroupAssetsRequest)
506	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.GroupResult, string, error) {
507		var resp *securitycenterpb.GroupAssetsResponse
508		req.PageToken = pageToken
509		if pageSize > math.MaxInt32 {
510			req.PageSize = math.MaxInt32
511		} else {
512			req.PageSize = int32(pageSize)
513		}
514		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
515			var err error
516			resp, err = c.client.GroupAssets(ctx, req, settings.GRPC...)
517			return err
518		}, opts...)
519		if err != nil {
520			return nil, "", err
521		}
522
523		it.Response = resp
524		return resp.GetGroupByResults(), resp.GetNextPageToken(), nil
525	}
526	fetch := func(pageSize int, pageToken string) (string, error) {
527		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
528		if err != nil {
529			return "", err
530		}
531		it.items = append(it.items, items...)
532		return nextPageToken, nil
533	}
534	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
535	it.pageInfo.MaxSize = int(req.GetPageSize())
536	it.pageInfo.Token = req.GetPageToken()
537	return it
538}
539
540// GroupFindings filters an organization or source’s findings and  groups them by their
541// specified properties.
542//
543// To group across all sources provide a - as the source id.
544// Example: /v1p1beta1/organizations/{organization_id}/sources/-/findings
545func (c *Client) GroupFindings(ctx context.Context, req *securitycenterpb.GroupFindingsRequest, opts ...gax.CallOption) *GroupResultIterator {
546	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
547	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
548	opts = append(c.CallOptions.GroupFindings[0:len(c.CallOptions.GroupFindings):len(c.CallOptions.GroupFindings)], opts...)
549	it := &GroupResultIterator{}
550	req = proto.Clone(req).(*securitycenterpb.GroupFindingsRequest)
551	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.GroupResult, string, error) {
552		var resp *securitycenterpb.GroupFindingsResponse
553		req.PageToken = pageToken
554		if pageSize > math.MaxInt32 {
555			req.PageSize = math.MaxInt32
556		} else {
557			req.PageSize = int32(pageSize)
558		}
559		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
560			var err error
561			resp, err = c.client.GroupFindings(ctx, req, settings.GRPC...)
562			return err
563		}, opts...)
564		if err != nil {
565			return nil, "", err
566		}
567
568		it.Response = resp
569		return resp.GetGroupByResults(), resp.GetNextPageToken(), nil
570	}
571	fetch := func(pageSize int, pageToken string) (string, error) {
572		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
573		if err != nil {
574			return "", err
575		}
576		it.items = append(it.items, items...)
577		return nextPageToken, nil
578	}
579	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
580	it.pageInfo.MaxSize = int(req.GetPageSize())
581	it.pageInfo.Token = req.GetPageToken()
582	return it
583}
584
585// ListAssets lists an organization’s assets.
586func (c *Client) ListAssets(ctx context.Context, req *securitycenterpb.ListAssetsRequest, opts ...gax.CallOption) *ListAssetsResponse_ListAssetsResultIterator {
587	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
588	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
589	opts = append(c.CallOptions.ListAssets[0:len(c.CallOptions.ListAssets):len(c.CallOptions.ListAssets)], opts...)
590	it := &ListAssetsResponse_ListAssetsResultIterator{}
591	req = proto.Clone(req).(*securitycenterpb.ListAssetsRequest)
592	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.ListAssetsResponse_ListAssetsResult, string, error) {
593		var resp *securitycenterpb.ListAssetsResponse
594		req.PageToken = pageToken
595		if pageSize > math.MaxInt32 {
596			req.PageSize = math.MaxInt32
597		} else {
598			req.PageSize = int32(pageSize)
599		}
600		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
601			var err error
602			resp, err = c.client.ListAssets(ctx, req, settings.GRPC...)
603			return err
604		}, opts...)
605		if err != nil {
606			return nil, "", err
607		}
608
609		it.Response = resp
610		return resp.GetListAssetsResults(), resp.GetNextPageToken(), nil
611	}
612	fetch := func(pageSize int, pageToken string) (string, error) {
613		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
614		if err != nil {
615			return "", err
616		}
617		it.items = append(it.items, items...)
618		return nextPageToken, nil
619	}
620	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
621	it.pageInfo.MaxSize = int(req.GetPageSize())
622	it.pageInfo.Token = req.GetPageToken()
623	return it
624}
625
626// ListFindings lists an organization or source’s findings.
627//
628// To list across all sources provide a - as the source id.
629// Example: /v1p1beta1/organizations/{organization_id}/sources/-/findings
630func (c *Client) ListFindings(ctx context.Context, req *securitycenterpb.ListFindingsRequest, opts ...gax.CallOption) *ListFindingsResponse_ListFindingsResultIterator {
631	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
632	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
633	opts = append(c.CallOptions.ListFindings[0:len(c.CallOptions.ListFindings):len(c.CallOptions.ListFindings)], opts...)
634	it := &ListFindingsResponse_ListFindingsResultIterator{}
635	req = proto.Clone(req).(*securitycenterpb.ListFindingsRequest)
636	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.ListFindingsResponse_ListFindingsResult, string, error) {
637		var resp *securitycenterpb.ListFindingsResponse
638		req.PageToken = pageToken
639		if pageSize > math.MaxInt32 {
640			req.PageSize = math.MaxInt32
641		} else {
642			req.PageSize = int32(pageSize)
643		}
644		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
645			var err error
646			resp, err = c.client.ListFindings(ctx, req, settings.GRPC...)
647			return err
648		}, opts...)
649		if err != nil {
650			return nil, "", err
651		}
652
653		it.Response = resp
654		return resp.GetListFindingsResults(), resp.GetNextPageToken(), nil
655	}
656	fetch := func(pageSize int, pageToken string) (string, error) {
657		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
658		if err != nil {
659			return "", err
660		}
661		it.items = append(it.items, items...)
662		return nextPageToken, nil
663	}
664	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
665	it.pageInfo.MaxSize = int(req.GetPageSize())
666	it.pageInfo.Token = req.GetPageToken()
667	return it
668}
669
670// ListNotificationConfigs lists notification configs.
671func (c *Client) ListNotificationConfigs(ctx context.Context, req *securitycenterpb.ListNotificationConfigsRequest, opts ...gax.CallOption) *NotificationConfigIterator {
672	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
673	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
674	opts = append(c.CallOptions.ListNotificationConfigs[0:len(c.CallOptions.ListNotificationConfigs):len(c.CallOptions.ListNotificationConfigs)], opts...)
675	it := &NotificationConfigIterator{}
676	req = proto.Clone(req).(*securitycenterpb.ListNotificationConfigsRequest)
677	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.NotificationConfig, string, error) {
678		var resp *securitycenterpb.ListNotificationConfigsResponse
679		req.PageToken = pageToken
680		if pageSize > math.MaxInt32 {
681			req.PageSize = math.MaxInt32
682		} else {
683			req.PageSize = int32(pageSize)
684		}
685		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
686			var err error
687			resp, err = c.client.ListNotificationConfigs(ctx, req, settings.GRPC...)
688			return err
689		}, opts...)
690		if err != nil {
691			return nil, "", err
692		}
693
694		it.Response = resp
695		return resp.GetNotificationConfigs(), resp.GetNextPageToken(), nil
696	}
697	fetch := func(pageSize int, pageToken string) (string, error) {
698		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
699		if err != nil {
700			return "", err
701		}
702		it.items = append(it.items, items...)
703		return nextPageToken, nil
704	}
705	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
706	it.pageInfo.MaxSize = int(req.GetPageSize())
707	it.pageInfo.Token = req.GetPageToken()
708	return it
709}
710
711// ListSources lists all sources belonging to an organization.
712func (c *Client) ListSources(ctx context.Context, req *securitycenterpb.ListSourcesRequest, opts ...gax.CallOption) *SourceIterator {
713	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
714	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
715	opts = append(c.CallOptions.ListSources[0:len(c.CallOptions.ListSources):len(c.CallOptions.ListSources)], opts...)
716	it := &SourceIterator{}
717	req = proto.Clone(req).(*securitycenterpb.ListSourcesRequest)
718	it.InternalFetch = func(pageSize int, pageToken string) ([]*securitycenterpb.Source, string, error) {
719		var resp *securitycenterpb.ListSourcesResponse
720		req.PageToken = pageToken
721		if pageSize > math.MaxInt32 {
722			req.PageSize = math.MaxInt32
723		} else {
724			req.PageSize = int32(pageSize)
725		}
726		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
727			var err error
728			resp, err = c.client.ListSources(ctx, req, settings.GRPC...)
729			return err
730		}, opts...)
731		if err != nil {
732			return nil, "", err
733		}
734
735		it.Response = resp
736		return resp.GetSources(), resp.GetNextPageToken(), nil
737	}
738	fetch := func(pageSize int, pageToken string) (string, error) {
739		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
740		if err != nil {
741			return "", err
742		}
743		it.items = append(it.items, items...)
744		return nextPageToken, nil
745	}
746	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
747	it.pageInfo.MaxSize = int(req.GetPageSize())
748	it.pageInfo.Token = req.GetPageToken()
749	return it
750}
751
752// RunAssetDiscovery runs asset discovery. The discovery is tracked with a long-running
753// operation.
754//
755// This API can only be called with limited frequency for an organization. If
756// it is called too frequently the caller will receive a TOO_MANY_REQUESTS
757// error.
758func (c *Client) RunAssetDiscovery(ctx context.Context, req *securitycenterpb.RunAssetDiscoveryRequest, opts ...gax.CallOption) (*RunAssetDiscoveryOperation, error) {
759	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
760		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
761		defer cancel()
762		ctx = cctx
763	}
764	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
765	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
766	opts = append(c.CallOptions.RunAssetDiscovery[0:len(c.CallOptions.RunAssetDiscovery):len(c.CallOptions.RunAssetDiscovery)], opts...)
767	var resp *longrunningpb.Operation
768	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
769		var err error
770		resp, err = c.client.RunAssetDiscovery(ctx, req, settings.GRPC...)
771		return err
772	}, opts...)
773	if err != nil {
774		return nil, err
775	}
776	return &RunAssetDiscoveryOperation{
777		lro: longrunning.InternalNewOperation(c.LROClient, resp),
778	}, nil
779}
780
781// SetFindingState updates the state of a finding.
782func (c *Client) SetFindingState(ctx context.Context, req *securitycenterpb.SetFindingStateRequest, opts ...gax.CallOption) (*securitycenterpb.Finding, error) {
783	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
784		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
785		defer cancel()
786		ctx = cctx
787	}
788	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
789	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
790	opts = append(c.CallOptions.SetFindingState[0:len(c.CallOptions.SetFindingState):len(c.CallOptions.SetFindingState)], opts...)
791	var resp *securitycenterpb.Finding
792	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
793		var err error
794		resp, err = c.client.SetFindingState(ctx, req, settings.GRPC...)
795		return err
796	}, opts...)
797	if err != nil {
798		return nil, err
799	}
800	return resp, nil
801}
802
803// SetIamPolicy sets the access control policy on the specified Source.
804func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
805	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
806		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
807		defer cancel()
808		ctx = cctx
809	}
810	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
811	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
812	opts = append(c.CallOptions.SetIamPolicy[0:len(c.CallOptions.SetIamPolicy):len(c.CallOptions.SetIamPolicy)], opts...)
813	var resp *iampb.Policy
814	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
815		var err error
816		resp, err = c.client.SetIamPolicy(ctx, req, settings.GRPC...)
817		return err
818	}, opts...)
819	if err != nil {
820		return nil, err
821	}
822	return resp, nil
823}
824
825// TestIamPermissions returns the permissions that a caller has on the specified source.
826func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
827	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
828		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
829		defer cancel()
830		ctx = cctx
831	}
832	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
833	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
834	opts = append(c.CallOptions.TestIamPermissions[0:len(c.CallOptions.TestIamPermissions):len(c.CallOptions.TestIamPermissions)], opts...)
835	var resp *iampb.TestIamPermissionsResponse
836	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
837		var err error
838		resp, err = c.client.TestIamPermissions(ctx, req, settings.GRPC...)
839		return err
840	}, opts...)
841	if err != nil {
842		return nil, err
843	}
844	return resp, nil
845}
846
847// UpdateFinding creates or updates a finding. The corresponding source must exist for a
848// finding creation to succeed.
849func (c *Client) UpdateFinding(ctx context.Context, req *securitycenterpb.UpdateFindingRequest, opts ...gax.CallOption) (*securitycenterpb.Finding, error) {
850	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
851		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
852		defer cancel()
853		ctx = cctx
854	}
855	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "finding.name", url.QueryEscape(req.GetFinding().GetName())))
856	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
857	opts = append(c.CallOptions.UpdateFinding[0:len(c.CallOptions.UpdateFinding):len(c.CallOptions.UpdateFinding)], opts...)
858	var resp *securitycenterpb.Finding
859	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
860		var err error
861		resp, err = c.client.UpdateFinding(ctx, req, settings.GRPC...)
862		return err
863	}, opts...)
864	if err != nil {
865		return nil, err
866	}
867	return resp, nil
868}
869
870// UpdateNotificationConfig updates a notification config. The following update
871// fields are allowed: description, pubsub_topic, streaming_config.filter
872func (c *Client) UpdateNotificationConfig(ctx context.Context, req *securitycenterpb.UpdateNotificationConfigRequest, opts ...gax.CallOption) (*securitycenterpb.NotificationConfig, error) {
873	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
874		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
875		defer cancel()
876		ctx = cctx
877	}
878	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "notification_config.name", url.QueryEscape(req.GetNotificationConfig().GetName())))
879	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
880	opts = append(c.CallOptions.UpdateNotificationConfig[0:len(c.CallOptions.UpdateNotificationConfig):len(c.CallOptions.UpdateNotificationConfig)], opts...)
881	var resp *securitycenterpb.NotificationConfig
882	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
883		var err error
884		resp, err = c.client.UpdateNotificationConfig(ctx, req, settings.GRPC...)
885		return err
886	}, opts...)
887	if err != nil {
888		return nil, err
889	}
890	return resp, nil
891}
892
893// UpdateOrganizationSettings updates an organization’s settings.
894func (c *Client) UpdateOrganizationSettings(ctx context.Context, req *securitycenterpb.UpdateOrganizationSettingsRequest, opts ...gax.CallOption) (*securitycenterpb.OrganizationSettings, error) {
895	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
896		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
897		defer cancel()
898		ctx = cctx
899	}
900	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "organization_settings.name", url.QueryEscape(req.GetOrganizationSettings().GetName())))
901	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
902	opts = append(c.CallOptions.UpdateOrganizationSettings[0:len(c.CallOptions.UpdateOrganizationSettings):len(c.CallOptions.UpdateOrganizationSettings)], opts...)
903	var resp *securitycenterpb.OrganizationSettings
904	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
905		var err error
906		resp, err = c.client.UpdateOrganizationSettings(ctx, req, settings.GRPC...)
907		return err
908	}, opts...)
909	if err != nil {
910		return nil, err
911	}
912	return resp, nil
913}
914
915// UpdateSource updates a source.
916func (c *Client) UpdateSource(ctx context.Context, req *securitycenterpb.UpdateSourceRequest, opts ...gax.CallOption) (*securitycenterpb.Source, error) {
917	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
918		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
919		defer cancel()
920		ctx = cctx
921	}
922	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "source.name", url.QueryEscape(req.GetSource().GetName())))
923	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
924	opts = append(c.CallOptions.UpdateSource[0:len(c.CallOptions.UpdateSource):len(c.CallOptions.UpdateSource)], opts...)
925	var resp *securitycenterpb.Source
926	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
927		var err error
928		resp, err = c.client.UpdateSource(ctx, req, settings.GRPC...)
929		return err
930	}, opts...)
931	if err != nil {
932		return nil, err
933	}
934	return resp, nil
935}
936
937// UpdateSecurityMarks updates security marks.
938func (c *Client) UpdateSecurityMarks(ctx context.Context, req *securitycenterpb.UpdateSecurityMarksRequest, opts ...gax.CallOption) (*securitycenterpb.SecurityMarks, error) {
939	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
940		cctx, cancel := context.WithTimeout(ctx, 480000*time.Millisecond)
941		defer cancel()
942		ctx = cctx
943	}
944	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "security_marks.name", url.QueryEscape(req.GetSecurityMarks().GetName())))
945	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
946	opts = append(c.CallOptions.UpdateSecurityMarks[0:len(c.CallOptions.UpdateSecurityMarks):len(c.CallOptions.UpdateSecurityMarks)], opts...)
947	var resp *securitycenterpb.SecurityMarks
948	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
949		var err error
950		resp, err = c.client.UpdateSecurityMarks(ctx, req, settings.GRPC...)
951		return err
952	}, opts...)
953	if err != nil {
954		return nil, err
955	}
956	return resp, nil
957}
958
959// RunAssetDiscoveryOperation manages a long-running operation from RunAssetDiscovery.
960type RunAssetDiscoveryOperation struct {
961	lro *longrunning.Operation
962}
963
964// RunAssetDiscoveryOperation returns a new RunAssetDiscoveryOperation from a given name.
965// The name must be that of a previously created RunAssetDiscoveryOperation, possibly from a different process.
966func (c *Client) RunAssetDiscoveryOperation(name string) *RunAssetDiscoveryOperation {
967	return &RunAssetDiscoveryOperation{
968		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
969	}
970}
971
972// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
973//
974// See documentation of Poll for error-handling information.
975func (op *RunAssetDiscoveryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*securitycenterpb.RunAssetDiscoveryResponse, error) {
976	var resp securitycenterpb.RunAssetDiscoveryResponse
977	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
978		return nil, err
979	}
980	return &resp, nil
981}
982
983// Poll fetches the latest state of the long-running operation.
984//
985// Poll also fetches the latest metadata, which can be retrieved by Metadata.
986//
987// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
988// the operation has completed with failure, the error is returned and op.Done will return true.
989// If Poll succeeds and the operation has completed successfully,
990// op.Done will return true, and the response of the operation is returned.
991// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
992func (op *RunAssetDiscoveryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*securitycenterpb.RunAssetDiscoveryResponse, error) {
993	var resp securitycenterpb.RunAssetDiscoveryResponse
994	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
995		return nil, err
996	}
997	if !op.Done() {
998		return nil, nil
999	}
1000	return &resp, nil
1001}
1002
1003// Metadata returns metadata associated with the long-running operation.
1004// Metadata itself does not contact the server, but Poll does.
1005// To get the latest metadata, call this method after a successful call to Poll.
1006// If the metadata is not available, the returned metadata and error are both nil.
1007func (op *RunAssetDiscoveryOperation) Metadata() (*emptypb.Empty, error) {
1008	var meta emptypb.Empty
1009	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1010		return nil, nil
1011	} else if err != nil {
1012		return nil, err
1013	}
1014	return &meta, nil
1015}
1016
1017// Done reports whether the long-running operation has completed.
1018func (op *RunAssetDiscoveryOperation) Done() bool {
1019	return op.lro.Done()
1020}
1021
1022// Name returns the name of the long-running operation.
1023// The name is assigned by the server and is unique within the service from which the operation is created.
1024func (op *RunAssetDiscoveryOperation) Name() string {
1025	return op.lro.Name()
1026}
1027
1028// GroupResultIterator manages a stream of *securitycenterpb.GroupResult.
1029type GroupResultIterator struct {
1030	items    []*securitycenterpb.GroupResult
1031	pageInfo *iterator.PageInfo
1032	nextFunc func() error
1033
1034	// Response is the raw response for the current page.
1035	// It must be cast to the RPC response type.
1036	// Calling Next() or InternalFetch() updates this value.
1037	Response interface{}
1038
1039	// InternalFetch is for use by the Google Cloud Libraries only.
1040	// It is not part of the stable interface of this package.
1041	//
1042	// InternalFetch returns results from a single call to the underlying RPC.
1043	// The number of results is no greater than pageSize.
1044	// If there are no more results, nextPageToken is empty and err is nil.
1045	InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.GroupResult, nextPageToken string, err error)
1046}
1047
1048// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1049func (it *GroupResultIterator) PageInfo() *iterator.PageInfo {
1050	return it.pageInfo
1051}
1052
1053// Next returns the next result. Its second return value is iterator.Done if there are no more
1054// results. Once Next returns Done, all subsequent calls will return Done.
1055func (it *GroupResultIterator) Next() (*securitycenterpb.GroupResult, error) {
1056	var item *securitycenterpb.GroupResult
1057	if err := it.nextFunc(); err != nil {
1058		return item, err
1059	}
1060	item = it.items[0]
1061	it.items = it.items[1:]
1062	return item, nil
1063}
1064
1065func (it *GroupResultIterator) bufLen() int {
1066	return len(it.items)
1067}
1068
1069func (it *GroupResultIterator) takeBuf() interface{} {
1070	b := it.items
1071	it.items = nil
1072	return b
1073}
1074
1075// ListAssetsResponse_ListAssetsResultIterator manages a stream of *securitycenterpb.ListAssetsResponse_ListAssetsResult.
1076type ListAssetsResponse_ListAssetsResultIterator struct {
1077	items    []*securitycenterpb.ListAssetsResponse_ListAssetsResult
1078	pageInfo *iterator.PageInfo
1079	nextFunc func() error
1080
1081	// Response is the raw response for the current page.
1082	// It must be cast to the RPC response type.
1083	// Calling Next() or InternalFetch() updates this value.
1084	Response interface{}
1085
1086	// InternalFetch is for use by the Google Cloud Libraries only.
1087	// It is not part of the stable interface of this package.
1088	//
1089	// InternalFetch returns results from a single call to the underlying RPC.
1090	// The number of results is no greater than pageSize.
1091	// If there are no more results, nextPageToken is empty and err is nil.
1092	InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.ListAssetsResponse_ListAssetsResult, nextPageToken string, err error)
1093}
1094
1095// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1096func (it *ListAssetsResponse_ListAssetsResultIterator) PageInfo() *iterator.PageInfo {
1097	return it.pageInfo
1098}
1099
1100// Next returns the next result. Its second return value is iterator.Done if there are no more
1101// results. Once Next returns Done, all subsequent calls will return Done.
1102func (it *ListAssetsResponse_ListAssetsResultIterator) Next() (*securitycenterpb.ListAssetsResponse_ListAssetsResult, error) {
1103	var item *securitycenterpb.ListAssetsResponse_ListAssetsResult
1104	if err := it.nextFunc(); err != nil {
1105		return item, err
1106	}
1107	item = it.items[0]
1108	it.items = it.items[1:]
1109	return item, nil
1110}
1111
1112func (it *ListAssetsResponse_ListAssetsResultIterator) bufLen() int {
1113	return len(it.items)
1114}
1115
1116func (it *ListAssetsResponse_ListAssetsResultIterator) takeBuf() interface{} {
1117	b := it.items
1118	it.items = nil
1119	return b
1120}
1121
1122// ListFindingsResponse_ListFindingsResultIterator manages a stream of *securitycenterpb.ListFindingsResponse_ListFindingsResult.
1123type ListFindingsResponse_ListFindingsResultIterator struct {
1124	items    []*securitycenterpb.ListFindingsResponse_ListFindingsResult
1125	pageInfo *iterator.PageInfo
1126	nextFunc func() error
1127
1128	// Response is the raw response for the current page.
1129	// It must be cast to the RPC response type.
1130	// Calling Next() or InternalFetch() updates this value.
1131	Response interface{}
1132
1133	// InternalFetch is for use by the Google Cloud Libraries only.
1134	// It is not part of the stable interface of this package.
1135	//
1136	// InternalFetch returns results from a single call to the underlying RPC.
1137	// The number of results is no greater than pageSize.
1138	// If there are no more results, nextPageToken is empty and err is nil.
1139	InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.ListFindingsResponse_ListFindingsResult, nextPageToken string, err error)
1140}
1141
1142// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1143func (it *ListFindingsResponse_ListFindingsResultIterator) PageInfo() *iterator.PageInfo {
1144	return it.pageInfo
1145}
1146
1147// Next returns the next result. Its second return value is iterator.Done if there are no more
1148// results. Once Next returns Done, all subsequent calls will return Done.
1149func (it *ListFindingsResponse_ListFindingsResultIterator) Next() (*securitycenterpb.ListFindingsResponse_ListFindingsResult, error) {
1150	var item *securitycenterpb.ListFindingsResponse_ListFindingsResult
1151	if err := it.nextFunc(); err != nil {
1152		return item, err
1153	}
1154	item = it.items[0]
1155	it.items = it.items[1:]
1156	return item, nil
1157}
1158
1159func (it *ListFindingsResponse_ListFindingsResultIterator) bufLen() int {
1160	return len(it.items)
1161}
1162
1163func (it *ListFindingsResponse_ListFindingsResultIterator) takeBuf() interface{} {
1164	b := it.items
1165	it.items = nil
1166	return b
1167}
1168
1169// NotificationConfigIterator manages a stream of *securitycenterpb.NotificationConfig.
1170type NotificationConfigIterator struct {
1171	items    []*securitycenterpb.NotificationConfig
1172	pageInfo *iterator.PageInfo
1173	nextFunc func() error
1174
1175	// Response is the raw response for the current page.
1176	// It must be cast to the RPC response type.
1177	// Calling Next() or InternalFetch() updates this value.
1178	Response interface{}
1179
1180	// InternalFetch is for use by the Google Cloud Libraries only.
1181	// It is not part of the stable interface of this package.
1182	//
1183	// InternalFetch returns results from a single call to the underlying RPC.
1184	// The number of results is no greater than pageSize.
1185	// If there are no more results, nextPageToken is empty and err is nil.
1186	InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.NotificationConfig, nextPageToken string, err error)
1187}
1188
1189// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1190func (it *NotificationConfigIterator) PageInfo() *iterator.PageInfo {
1191	return it.pageInfo
1192}
1193
1194// Next returns the next result. Its second return value is iterator.Done if there are no more
1195// results. Once Next returns Done, all subsequent calls will return Done.
1196func (it *NotificationConfigIterator) Next() (*securitycenterpb.NotificationConfig, error) {
1197	var item *securitycenterpb.NotificationConfig
1198	if err := it.nextFunc(); err != nil {
1199		return item, err
1200	}
1201	item = it.items[0]
1202	it.items = it.items[1:]
1203	return item, nil
1204}
1205
1206func (it *NotificationConfigIterator) bufLen() int {
1207	return len(it.items)
1208}
1209
1210func (it *NotificationConfigIterator) takeBuf() interface{} {
1211	b := it.items
1212	it.items = nil
1213	return b
1214}
1215
1216// SourceIterator manages a stream of *securitycenterpb.Source.
1217type SourceIterator struct {
1218	items    []*securitycenterpb.Source
1219	pageInfo *iterator.PageInfo
1220	nextFunc func() error
1221
1222	// Response is the raw response for the current page.
1223	// It must be cast to the RPC response type.
1224	// Calling Next() or InternalFetch() updates this value.
1225	Response interface{}
1226
1227	// InternalFetch is for use by the Google Cloud Libraries only.
1228	// It is not part of the stable interface of this package.
1229	//
1230	// InternalFetch returns results from a single call to the underlying RPC.
1231	// The number of results is no greater than pageSize.
1232	// If there are no more results, nextPageToken is empty and err is nil.
1233	InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.Source, nextPageToken string, err error)
1234}
1235
1236// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1237func (it *SourceIterator) PageInfo() *iterator.PageInfo {
1238	return it.pageInfo
1239}
1240
1241// Next returns the next result. Its second return value is iterator.Done if there are no more
1242// results. Once Next returns Done, all subsequent calls will return Done.
1243func (it *SourceIterator) Next() (*securitycenterpb.Source, error) {
1244	var item *securitycenterpb.Source
1245	if err := it.nextFunc(); err != nil {
1246		return item, err
1247	}
1248	item = it.items[0]
1249	it.items = it.items[1:]
1250	return item, nil
1251}
1252
1253func (it *SourceIterator) bufLen() int {
1254	return len(it.items)
1255}
1256
1257func (it *SourceIterator) takeBuf() interface{} {
1258	b := it.items
1259	it.items = nil
1260	return b
1261}
1262