Debian Codegraph @

securitycenter/apiv1p1beta1/auxiliary.go

raw symbols SCIP
1 // Copyright 2025 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
17 package securitycenter
18
19 import (
20 "context"
21 "time"
22
23 "cloud.google.com/go/longrunning"
24 securitycenterpb "cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb"
25 gax "github.com/googleapis/gax-go/v2"
26 "google.golang.org/api/iterator"
27 emptypb "google.golang.org/protobuf/types/known/emptypb"
28 )
29
30 // RunAssetDiscoveryOperation manages a long-running operation from RunAssetDiscovery.
31 type RunAssetDiscoveryOperation struct {
32 lro *longrunning.Operation
33 pollPath string
34 }
35
36 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
37 //
38 // See documentation of Poll for error-handling information.
39 func (op *RunAssetDiscoveryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*securitycenterpb.RunAssetDiscoveryResponse, error) {
40 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
41 var resp securitycenterpb.RunAssetDiscoveryResponse
42 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
43 return nil, err
44 }
45 return &resp, nil
46 }
47
48 // Poll fetches the latest state of the long-running operation.
49 //
50 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
51 //
52 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
53 // the operation has completed with failure, the error is returned and op.Done will return true.
54 // If Poll succeeds and the operation has completed successfully,
55 // op.Done will return true, and the response of the operation is returned.
56 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
57 func (op *RunAssetDiscoveryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*securitycenterpb.RunAssetDiscoveryResponse, error) {
58 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
59 var resp securitycenterpb.RunAssetDiscoveryResponse
60 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
61 return nil, err
62 }
63 if !op.Done() {
64 return nil, nil
65 }
66 return &resp, nil
67 }
68
69 // Metadata returns metadata associated with the long-running operation.
70 // Metadata itself does not contact the server, but Poll does.
71 // To get the latest metadata, call this method after a successful call to Poll.
72 // If the metadata is not available, the returned metadata and error are both nil.
73 func (op *RunAssetDiscoveryOperation) Metadata() (*emptypb.Empty, error) {
74 var meta emptypb.Empty
75 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
76 return nil, nil
77 } else if err != nil {
78 return nil, err
79 }
80 return &meta, nil
81 }
82
83 // Done reports whether the long-running operation has completed.
84 func (op *RunAssetDiscoveryOperation) Done() bool {
85 return op.lro.Done()
86 }
87
88 // Name returns the name of the long-running operation.
89 // The name is assigned by the server and is unique within the service from which the operation is created.
90 func (op *RunAssetDiscoveryOperation) Name() string {
91 return op.lro.Name()
92 }
93
94 // GroupResultIterator manages a stream of *securitycenterpb.GroupResult.
95 type GroupResultIterator struct {
96 items []*securitycenterpb.GroupResult
97 pageInfo *iterator.PageInfo
98 nextFunc func() error
99
100 // Response is the raw response for the current page.
101 // It must be cast to the RPC response type.
102 // Calling Next() or InternalFetch() updates this value.
103 Response interface{}
104
105 // InternalFetch is for use by the Google Cloud Libraries only.
106 // It is not part of the stable interface of this package.
107 //
108 // InternalFetch returns results from a single call to the underlying RPC.
109 // The number of results is no greater than pageSize.
110 // If there are no more results, nextPageToken is empty and err is nil.
111 InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.GroupResult, nextPageToken string, err error)
112 }
113
114 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
115 func (it *GroupResultIterator) PageInfo() *iterator.PageInfo {
116 return it.pageInfo
117 }
118
119 // Next returns the next result. Its second return value is iterator.Done if there are no more
120 // results. Once Next returns Done, all subsequent calls will return Done.
121 func (it *GroupResultIterator) Next() (*securitycenterpb.GroupResult, error) {
122 var item *securitycenterpb.GroupResult
123 if err := it.nextFunc(); err != nil {
124 return item, err
125 }
126 item = it.items[0]
127 it.items = it.items[1:]
128 return item, nil
129 }
130
131 func (it *GroupResultIterator) bufLen() int {
132 return len(it.items)
133 }
134
135 func (it *GroupResultIterator) takeBuf() interface{} {
136 b := it.items
137 it.items = nil
138 return b
139 }
140
141 // ListAssetsResponse_ListAssetsResultIterator manages a stream of *securitycenterpb.ListAssetsResponse_ListAssetsResult.
142 type ListAssetsResponse_ListAssetsResultIterator struct {
143 items []*securitycenterpb.ListAssetsResponse_ListAssetsResult
144 pageInfo *iterator.PageInfo
145 nextFunc func() error
146
147 // Response is the raw response for the current page.
148 // It must be cast to the RPC response type.
149 // Calling Next() or InternalFetch() updates this value.
150 Response interface{}
151
152 // InternalFetch is for use by the Google Cloud Libraries only.
153 // It is not part of the stable interface of this package.
154 //
155 // InternalFetch returns results from a single call to the underlying RPC.
156 // The number of results is no greater than pageSize.
157 // If there are no more results, nextPageToken is empty and err is nil.
158 InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.ListAssetsResponse_ListAssetsResult, nextPageToken string, err error)
159 }
160
161 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
162 func (it *ListAssetsResponse_ListAssetsResultIterator) PageInfo() *iterator.PageInfo {
163 return it.pageInfo
164 }
165
166 // Next returns the next result. Its second return value is iterator.Done if there are no more
167 // results. Once Next returns Done, all subsequent calls will return Done.
168 func (it *ListAssetsResponse_ListAssetsResultIterator) Next() (*securitycenterpb.ListAssetsResponse_ListAssetsResult, error) {
169 var item *securitycenterpb.ListAssetsResponse_ListAssetsResult
170 if err := it.nextFunc(); err != nil {
171 return item, err
172 }
173 item = it.items[0]
174 it.items = it.items[1:]
175 return item, nil
176 }
177
178 func (it *ListAssetsResponse_ListAssetsResultIterator) bufLen() int {
179 return len(it.items)
180 }
181
182 func (it *ListAssetsResponse_ListAssetsResultIterator) takeBuf() interface{} {
183 b := it.items
184 it.items = nil
185 return b
186 }
187
188 // ListFindingsResponse_ListFindingsResultIterator manages a stream of *securitycenterpb.ListFindingsResponse_ListFindingsResult.
189 type ListFindingsResponse_ListFindingsResultIterator struct {
190 items []*securitycenterpb.ListFindingsResponse_ListFindingsResult
191 pageInfo *iterator.PageInfo
192 nextFunc func() error
193
194 // Response is the raw response for the current page.
195 // It must be cast to the RPC response type.
196 // Calling Next() or InternalFetch() updates this value.
197 Response interface{}
198
199 // InternalFetch is for use by the Google Cloud Libraries only.
200 // It is not part of the stable interface of this package.
201 //
202 // InternalFetch returns results from a single call to the underlying RPC.
203 // The number of results is no greater than pageSize.
204 // If there are no more results, nextPageToken is empty and err is nil.
205 InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.ListFindingsResponse_ListFindingsResult, nextPageToken string, err error)
206 }
207
208 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
209 func (it *ListFindingsResponse_ListFindingsResultIterator) PageInfo() *iterator.PageInfo {
210 return it.pageInfo
211 }
212
213 // Next returns the next result. Its second return value is iterator.Done if there are no more
214 // results. Once Next returns Done, all subsequent calls will return Done.
215 func (it *ListFindingsResponse_ListFindingsResultIterator) Next() (*securitycenterpb.ListFindingsResponse_ListFindingsResult, error) {
216 var item *securitycenterpb.ListFindingsResponse_ListFindingsResult
217 if err := it.nextFunc(); err != nil {
218 return item, err
219 }
220 item = it.items[0]
221 it.items = it.items[1:]
222 return item, nil
223 }
224
225 func (it *ListFindingsResponse_ListFindingsResultIterator) bufLen() int {
226 return len(it.items)
227 }
228
229 func (it *ListFindingsResponse_ListFindingsResultIterator) takeBuf() interface{} {
230 b := it.items
231 it.items = nil
232 return b
233 }
234
235 // NotificationConfigIterator manages a stream of *securitycenterpb.NotificationConfig.
236 type NotificationConfigIterator struct {
237 items []*securitycenterpb.NotificationConfig
238 pageInfo *iterator.PageInfo
239 nextFunc func() error
240
241 // Response is the raw response for the current page.
242 // It must be cast to the RPC response type.
243 // Calling Next() or InternalFetch() updates this value.
244 Response interface{}
245
246 // InternalFetch is for use by the Google Cloud Libraries only.
247 // It is not part of the stable interface of this package.
248 //
249 // InternalFetch returns results from a single call to the underlying RPC.
250 // The number of results is no greater than pageSize.
251 // If there are no more results, nextPageToken is empty and err is nil.
252 InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.NotificationConfig, nextPageToken string, err error)
253 }
254
255 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
256 func (it *NotificationConfigIterator) PageInfo() *iterator.PageInfo {
257 return it.pageInfo
258 }
259
260 // Next returns the next result. Its second return value is iterator.Done if there are no more
261 // results. Once Next returns Done, all subsequent calls will return Done.
262 func (it *NotificationConfigIterator) Next() (*securitycenterpb.NotificationConfig, error) {
263 var item *securitycenterpb.NotificationConfig
264 if err := it.nextFunc(); err != nil {
265 return item, err
266 }
267 item = it.items[0]
268 it.items = it.items[1:]
269 return item, nil
270 }
271
272 func (it *NotificationConfigIterator) bufLen() int {
273 return len(it.items)
274 }
275
276 func (it *NotificationConfigIterator) takeBuf() interface{} {
277 b := it.items
278 it.items = nil
279 return b
280 }
281
282 // SourceIterator manages a stream of *securitycenterpb.Source.
283 type SourceIterator struct {
284 items []*securitycenterpb.Source
285 pageInfo *iterator.PageInfo
286 nextFunc func() error
287
288 // Response is the raw response for the current page.
289 // It must be cast to the RPC response type.
290 // Calling Next() or InternalFetch() updates this value.
291 Response interface{}
292
293 // InternalFetch is for use by the Google Cloud Libraries only.
294 // It is not part of the stable interface of this package.
295 //
296 // InternalFetch returns results from a single call to the underlying RPC.
297 // The number of results is no greater than pageSize.
298 // If there are no more results, nextPageToken is empty and err is nil.
299 InternalFetch func(pageSize int, pageToken string) (results []*securitycenterpb.Source, nextPageToken string, err error)
300 }
301
302 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
303 func (it *SourceIterator) PageInfo() *iterator.PageInfo {
304 return it.pageInfo
305 }
306
307 // Next returns the next result. Its second return value is iterator.Done if there are no more
308 // results. Once Next returns Done, all subsequent calls will return Done.
309 func (it *SourceIterator) Next() (*securitycenterpb.Source, error) {
310 var item *securitycenterpb.Source
311 if err := it.nextFunc(); err != nil {
312 return item, err
313 }
314 item = it.items[0]
315 it.items = it.items[1:]
316 return item, nil
317 }
318
319 func (it *SourceIterator) bufLen() int {
320 return len(it.items)
321 }
322
323 func (it *SourceIterator) takeBuf() interface{} {
324 b := it.items
325 it.items = nil
326 return b
327 }