Debian Codegraph @

storageinsights/apiv1/storage_insights_client.go

raw
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 storageinsights
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 "cloud.google.com/go/longrunning"
30 lroauto "cloud.google.com/go/longrunning/autogen"
31 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
32 storageinsightspb "cloud.google.com/go/storageinsights/apiv1/storageinsightspb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 locationpb "google.golang.org/genproto/googleapis/cloud/location"
40 "google.golang.org/grpc"
41 "google.golang.org/grpc/codes"
42 "google.golang.org/protobuf/encoding/protojson"
43 "google.golang.org/protobuf/proto"
44 )
45
46 var newClientHook clientHook
47
48 // CallOptions contains the retry settings for each method of Client.
49 type CallOptions struct {
50 ListReportConfigs []gax.CallOption
51 GetReportConfig []gax.CallOption
52 CreateReportConfig []gax.CallOption
53 UpdateReportConfig []gax.CallOption
54 DeleteReportConfig []gax.CallOption
55 ListReportDetails []gax.CallOption
56 GetReportDetail []gax.CallOption
57 ListDatasetConfigs []gax.CallOption
58 GetDatasetConfig []gax.CallOption
59 CreateDatasetConfig []gax.CallOption
60 UpdateDatasetConfig []gax.CallOption
61 DeleteDatasetConfig []gax.CallOption
62 LinkDataset []gax.CallOption
63 UnlinkDataset []gax.CallOption
64 GetLocation []gax.CallOption
65 ListLocations []gax.CallOption
66 CancelOperation []gax.CallOption
67 DeleteOperation []gax.CallOption
68 GetOperation []gax.CallOption
69 ListOperations []gax.CallOption
70 }
71
72 func defaultGRPCClientOptions() []option.ClientOption {
73 return []option.ClientOption{
74 internaloption.WithDefaultEndpoint("storageinsights.googleapis.com:443"),
75 internaloption.WithDefaultEndpointTemplate("storageinsights.UNIVERSE_DOMAIN:443"),
76 internaloption.WithDefaultMTLSEndpoint("storageinsights.mtls.googleapis.com:443"),
77 internaloption.WithDefaultUniverseDomain("googleapis.com"),
78 internaloption.WithDefaultAudience("https://storageinsights.googleapis.com/"),
79 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
80 internaloption.EnableJwtWithScope(),
81 internaloption.EnableNewAuthLibrary(),
82 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
83 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
84 }
85 }
86
87 func defaultCallOptions() *CallOptions {
88 return &CallOptions{
89 ListReportConfigs: []gax.CallOption{
90 gax.WithTimeout(60000 * time.Millisecond),
91 gax.WithRetry(func() gax.Retryer {
92 return gax.OnCodes([]codes.Code{
93 codes.Unavailable,
94 }, gax.Backoff{
95 Initial: 1000 * time.Millisecond,
96 Max: 60000 * time.Millisecond,
97 Multiplier: 1.30,
98 })
99 }),
100 },
101 GetReportConfig: []gax.CallOption{
102 gax.WithTimeout(60000 * time.Millisecond),
103 gax.WithRetry(func() gax.Retryer {
104 return gax.OnCodes([]codes.Code{
105 codes.Unavailable,
106 }, gax.Backoff{
107 Initial: 1000 * time.Millisecond,
108 Max: 60000 * time.Millisecond,
109 Multiplier: 1.30,
110 })
111 }),
112 },
113 CreateReportConfig: []gax.CallOption{
114 gax.WithTimeout(60000 * time.Millisecond),
115 },
116 UpdateReportConfig: []gax.CallOption{
117 gax.WithTimeout(60000 * time.Millisecond),
118 },
119 DeleteReportConfig: []gax.CallOption{
120 gax.WithTimeout(60000 * time.Millisecond),
121 },
122 ListReportDetails: []gax.CallOption{
123 gax.WithTimeout(60000 * time.Millisecond),
124 gax.WithRetry(func() gax.Retryer {
125 return gax.OnCodes([]codes.Code{
126 codes.Unavailable,
127 }, gax.Backoff{
128 Initial: 1000 * time.Millisecond,
129 Max: 60000 * time.Millisecond,
130 Multiplier: 1.30,
131 })
132 }),
133 },
134 GetReportDetail: []gax.CallOption{
135 gax.WithTimeout(60000 * time.Millisecond),
136 gax.WithRetry(func() gax.Retryer {
137 return gax.OnCodes([]codes.Code{
138 codes.Unavailable,
139 }, gax.Backoff{
140 Initial: 1000 * time.Millisecond,
141 Max: 60000 * time.Millisecond,
142 Multiplier: 1.30,
143 })
144 }),
145 },
146 ListDatasetConfigs: []gax.CallOption{
147 gax.WithTimeout(60000 * time.Millisecond),
148 gax.WithRetry(func() gax.Retryer {
149 return gax.OnCodes([]codes.Code{
150 codes.Unavailable,
151 }, gax.Backoff{
152 Initial: 1000 * time.Millisecond,
153 Max: 60000 * time.Millisecond,
154 Multiplier: 1.30,
155 })
156 }),
157 },
158 GetDatasetConfig: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 },
161 CreateDatasetConfig: []gax.CallOption{
162 gax.WithTimeout(60000 * time.Millisecond),
163 gax.WithRetry(func() gax.Retryer {
164 return gax.OnCodes([]codes.Code{
165 codes.Unavailable,
166 }, gax.Backoff{
167 Initial: 1000 * time.Millisecond,
168 Max: 60000 * time.Millisecond,
169 Multiplier: 1.30,
170 })
171 }),
172 },
173 UpdateDatasetConfig: []gax.CallOption{
174 gax.WithTimeout(60000 * time.Millisecond),
175 gax.WithRetry(func() gax.Retryer {
176 return gax.OnCodes([]codes.Code{
177 codes.Unavailable,
178 }, gax.Backoff{
179 Initial: 1000 * time.Millisecond,
180 Max: 60000 * time.Millisecond,
181 Multiplier: 1.30,
182 })
183 }),
184 },
185 DeleteDatasetConfig: []gax.CallOption{
186 gax.WithTimeout(60000 * time.Millisecond),
187 gax.WithRetry(func() gax.Retryer {
188 return gax.OnCodes([]codes.Code{
189 codes.Unavailable,
190 }, gax.Backoff{
191 Initial: 1000 * time.Millisecond,
192 Max: 60000 * time.Millisecond,
193 Multiplier: 1.30,
194 })
195 }),
196 },
197 LinkDataset: []gax.CallOption{
198 gax.WithTimeout(60000 * time.Millisecond),
199 gax.WithRetry(func() gax.Retryer {
200 return gax.OnCodes([]codes.Code{
201 codes.Unavailable,
202 }, gax.Backoff{
203 Initial: 1000 * time.Millisecond,
204 Max: 60000 * time.Millisecond,
205 Multiplier: 1.30,
206 })
207 }),
208 },
209 UnlinkDataset: []gax.CallOption{
210 gax.WithTimeout(60000 * time.Millisecond),
211 gax.WithRetry(func() gax.Retryer {
212 return gax.OnCodes([]codes.Code{
213 codes.Unavailable,
214 }, gax.Backoff{
215 Initial: 1000 * time.Millisecond,
216 Max: 60000 * time.Millisecond,
217 Multiplier: 1.30,
218 })
219 }),
220 },
221 GetLocation: []gax.CallOption{},
222 ListLocations: []gax.CallOption{},
223 CancelOperation: []gax.CallOption{},
224 DeleteOperation: []gax.CallOption{},
225 GetOperation: []gax.CallOption{},
226 ListOperations: []gax.CallOption{},
227 }
228 }
229
230 func defaultRESTCallOptions() *CallOptions {
231 return &CallOptions{
232 ListReportConfigs: []gax.CallOption{
233 gax.WithTimeout(60000 * time.Millisecond),
234 gax.WithRetry(func() gax.Retryer {
235 return gax.OnHTTPCodes(gax.Backoff{
236 Initial: 1000 * time.Millisecond,
237 Max: 60000 * time.Millisecond,
238 Multiplier: 1.30,
239 },
240 http.StatusServiceUnavailable)
241 }),
242 },
243 GetReportConfig: []gax.CallOption{
244 gax.WithTimeout(60000 * time.Millisecond),
245 gax.WithRetry(func() gax.Retryer {
246 return gax.OnHTTPCodes(gax.Backoff{
247 Initial: 1000 * time.Millisecond,
248 Max: 60000 * time.Millisecond,
249 Multiplier: 1.30,
250 },
251 http.StatusServiceUnavailable)
252 }),
253 },
254 CreateReportConfig: []gax.CallOption{
255 gax.WithTimeout(60000 * time.Millisecond),
256 },
257 UpdateReportConfig: []gax.CallOption{
258 gax.WithTimeout(60000 * time.Millisecond),
259 },
260 DeleteReportConfig: []gax.CallOption{
261 gax.WithTimeout(60000 * time.Millisecond),
262 },
263 ListReportDetails: []gax.CallOption{
264 gax.WithTimeout(60000 * time.Millisecond),
265 gax.WithRetry(func() gax.Retryer {
266 return gax.OnHTTPCodes(gax.Backoff{
267 Initial: 1000 * time.Millisecond,
268 Max: 60000 * time.Millisecond,
269 Multiplier: 1.30,
270 },
271 http.StatusServiceUnavailable)
272 }),
273 },
274 GetReportDetail: []gax.CallOption{
275 gax.WithTimeout(60000 * time.Millisecond),
276 gax.WithRetry(func() gax.Retryer {
277 return gax.OnHTTPCodes(gax.Backoff{
278 Initial: 1000 * time.Millisecond,
279 Max: 60000 * time.Millisecond,
280 Multiplier: 1.30,
281 },
282 http.StatusServiceUnavailable)
283 }),
284 },
285 ListDatasetConfigs: []gax.CallOption{
286 gax.WithTimeout(60000 * time.Millisecond),
287 gax.WithRetry(func() gax.Retryer {
288 return gax.OnHTTPCodes(gax.Backoff{
289 Initial: 1000 * time.Millisecond,
290 Max: 60000 * time.Millisecond,
291 Multiplier: 1.30,
292 },
293 http.StatusServiceUnavailable)
294 }),
295 },
296 GetDatasetConfig: []gax.CallOption{
297 gax.WithTimeout(60000 * time.Millisecond),
298 },
299 CreateDatasetConfig: []gax.CallOption{
300 gax.WithTimeout(60000 * time.Millisecond),
301 gax.WithRetry(func() gax.Retryer {
302 return gax.OnHTTPCodes(gax.Backoff{
303 Initial: 1000 * time.Millisecond,
304 Max: 60000 * time.Millisecond,
305 Multiplier: 1.30,
306 },
307 http.StatusServiceUnavailable)
308 }),
309 },
310 UpdateDatasetConfig: []gax.CallOption{
311 gax.WithTimeout(60000 * time.Millisecond),
312 gax.WithRetry(func() gax.Retryer {
313 return gax.OnHTTPCodes(gax.Backoff{
314 Initial: 1000 * time.Millisecond,
315 Max: 60000 * time.Millisecond,
316 Multiplier: 1.30,
317 },
318 http.StatusServiceUnavailable)
319 }),
320 },
321 DeleteDatasetConfig: []gax.CallOption{
322 gax.WithTimeout(60000 * time.Millisecond),
323 gax.WithRetry(func() gax.Retryer {
324 return gax.OnHTTPCodes(gax.Backoff{
325 Initial: 1000 * time.Millisecond,
326 Max: 60000 * time.Millisecond,
327 Multiplier: 1.30,
328 },
329 http.StatusServiceUnavailable)
330 }),
331 },
332 LinkDataset: []gax.CallOption{
333 gax.WithTimeout(60000 * time.Millisecond),
334 gax.WithRetry(func() gax.Retryer {
335 return gax.OnHTTPCodes(gax.Backoff{
336 Initial: 1000 * time.Millisecond,
337 Max: 60000 * time.Millisecond,
338 Multiplier: 1.30,
339 },
340 http.StatusServiceUnavailable)
341 }),
342 },
343 UnlinkDataset: []gax.CallOption{
344 gax.WithTimeout(60000 * time.Millisecond),
345 gax.WithRetry(func() gax.Retryer {
346 return gax.OnHTTPCodes(gax.Backoff{
347 Initial: 1000 * time.Millisecond,
348 Max: 60000 * time.Millisecond,
349 Multiplier: 1.30,
350 },
351 http.StatusServiceUnavailable)
352 }),
353 },
354 GetLocation: []gax.CallOption{},
355 ListLocations: []gax.CallOption{},
356 CancelOperation: []gax.CallOption{},
357 DeleteOperation: []gax.CallOption{},
358 GetOperation: []gax.CallOption{},
359 ListOperations: []gax.CallOption{},
360 }
361 }
362
363 // internalClient is an interface that defines the methods available from Storage Insights API.
364 type internalClient interface {
365 Close() error
366 setGoogleClientInfo(...string)
367 Connection() *grpc.ClientConn
368 ListReportConfigs(context.Context, *storageinsightspb.ListReportConfigsRequest, ...gax.CallOption) *ReportConfigIterator
369 GetReportConfig(context.Context, *storageinsightspb.GetReportConfigRequest, ...gax.CallOption) (*storageinsightspb.ReportConfig, error)
370 CreateReportConfig(context.Context, *storageinsightspb.CreateReportConfigRequest, ...gax.CallOption) (*storageinsightspb.ReportConfig, error)
371 UpdateReportConfig(context.Context, *storageinsightspb.UpdateReportConfigRequest, ...gax.CallOption) (*storageinsightspb.ReportConfig, error)
372 DeleteReportConfig(context.Context, *storageinsightspb.DeleteReportConfigRequest, ...gax.CallOption) error
373 ListReportDetails(context.Context, *storageinsightspb.ListReportDetailsRequest, ...gax.CallOption) *ReportDetailIterator
374 GetReportDetail(context.Context, *storageinsightspb.GetReportDetailRequest, ...gax.CallOption) (*storageinsightspb.ReportDetail, error)
375 ListDatasetConfigs(context.Context, *storageinsightspb.ListDatasetConfigsRequest, ...gax.CallOption) *DatasetConfigIterator
376 GetDatasetConfig(context.Context, *storageinsightspb.GetDatasetConfigRequest, ...gax.CallOption) (*storageinsightspb.DatasetConfig, error)
377 CreateDatasetConfig(context.Context, *storageinsightspb.CreateDatasetConfigRequest, ...gax.CallOption) (*CreateDatasetConfigOperation, error)
378 CreateDatasetConfigOperation(name string) *CreateDatasetConfigOperation
379 UpdateDatasetConfig(context.Context, *storageinsightspb.UpdateDatasetConfigRequest, ...gax.CallOption) (*UpdateDatasetConfigOperation, error)
380 UpdateDatasetConfigOperation(name string) *UpdateDatasetConfigOperation
381 DeleteDatasetConfig(context.Context, *storageinsightspb.DeleteDatasetConfigRequest, ...gax.CallOption) (*DeleteDatasetConfigOperation, error)
382 DeleteDatasetConfigOperation(name string) *DeleteDatasetConfigOperation
383 LinkDataset(context.Context, *storageinsightspb.LinkDatasetRequest, ...gax.CallOption) (*LinkDatasetOperation, error)
384 LinkDatasetOperation(name string) *LinkDatasetOperation
385 UnlinkDataset(context.Context, *storageinsightspb.UnlinkDatasetRequest, ...gax.CallOption) (*UnlinkDatasetOperation, error)
386 UnlinkDatasetOperation(name string) *UnlinkDatasetOperation
387 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
388 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
389 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
390 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
391 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
392 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
393 }
394
395 // Client is a client for interacting with Storage Insights API.
396 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
397 //
398 // Service describing handlers for resources
399 type Client struct {
400 // The internal transport-dependent client.
401 internalClient internalClient
402
403 // The call options for this service.
404 CallOptions *CallOptions
405
406 // LROClient is used internally to handle long-running operations.
407 // It is exposed so that its CallOptions can be modified if required.
408 // Users should not Close this client.
409 LROClient *lroauto.OperationsClient
410 }
411
412 // Wrapper methods routed to the internal client.
413
414 // Close closes the connection to the API service. The user should invoke this when
415 // the client is no longer required.
416 func (c *Client) Close() error {
417 return c.internalClient.Close()
418 }
419
420 // setGoogleClientInfo sets the name and version of the application in
421 // the `x-goog-api-client` header passed on each request. Intended for
422 // use by Google-written clients.
423 func (c *Client) setGoogleClientInfo(keyval ...string) {
424 c.internalClient.setGoogleClientInfo(keyval...)
425 }
426
427 // Connection returns a connection to the API service.
428 //
429 // Deprecated: Connections are now pooled so this method does not always
430 // return the same resource.
431 func (c *Client) Connection() *grpc.ClientConn {
432 return c.internalClient.Connection()
433 }
434
435 // ListReportConfigs lists ReportConfigs in a given project and location.
436 func (c *Client) ListReportConfigs(ctx context.Context, req *storageinsightspb.ListReportConfigsRequest, opts ...gax.CallOption) *ReportConfigIterator {
437 return c.internalClient.ListReportConfigs(ctx, req, opts...)
438 }
439
440 // GetReportConfig gets details of a single ReportConfig.
441 func (c *Client) GetReportConfig(ctx context.Context, req *storageinsightspb.GetReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
442 return c.internalClient.GetReportConfig(ctx, req, opts...)
443 }
444
445 // CreateReportConfig creates a new ReportConfig in a given project and location.
446 func (c *Client) CreateReportConfig(ctx context.Context, req *storageinsightspb.CreateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
447 return c.internalClient.CreateReportConfig(ctx, req, opts...)
448 }
449
450 // UpdateReportConfig updates the parameters of a single ReportConfig.
451 func (c *Client) UpdateReportConfig(ctx context.Context, req *storageinsightspb.UpdateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
452 return c.internalClient.UpdateReportConfig(ctx, req, opts...)
453 }
454
455 // DeleteReportConfig deletes a single ReportConfig.
456 func (c *Client) DeleteReportConfig(ctx context.Context, req *storageinsightspb.DeleteReportConfigRequest, opts ...gax.CallOption) error {
457 return c.internalClient.DeleteReportConfig(ctx, req, opts...)
458 }
459
460 // ListReportDetails lists ReportDetails in a given project and location.
461 func (c *Client) ListReportDetails(ctx context.Context, req *storageinsightspb.ListReportDetailsRequest, opts ...gax.CallOption) *ReportDetailIterator {
462 return c.internalClient.ListReportDetails(ctx, req, opts...)
463 }
464
465 // GetReportDetail gets details of a single ReportDetail.
466 func (c *Client) GetReportDetail(ctx context.Context, req *storageinsightspb.GetReportDetailRequest, opts ...gax.CallOption) (*storageinsightspb.ReportDetail, error) {
467 return c.internalClient.GetReportDetail(ctx, req, opts...)
468 }
469
470 // ListDatasetConfigs lists the dataset configurations in a given project for a given location.
471 func (c *Client) ListDatasetConfigs(ctx context.Context, req *storageinsightspb.ListDatasetConfigsRequest, opts ...gax.CallOption) *DatasetConfigIterator {
472 return c.internalClient.ListDatasetConfigs(ctx, req, opts...)
473 }
474
475 // GetDatasetConfig gets the dataset configuration in a given project for a given location.
476 func (c *Client) GetDatasetConfig(ctx context.Context, req *storageinsightspb.GetDatasetConfigRequest, opts ...gax.CallOption) (*storageinsightspb.DatasetConfig, error) {
477 return c.internalClient.GetDatasetConfig(ctx, req, opts...)
478 }
479
480 // CreateDatasetConfig creates a dataset configuration in a given project for a given location.
481 func (c *Client) CreateDatasetConfig(ctx context.Context, req *storageinsightspb.CreateDatasetConfigRequest, opts ...gax.CallOption) (*CreateDatasetConfigOperation, error) {
482 return c.internalClient.CreateDatasetConfig(ctx, req, opts...)
483 }
484
485 // CreateDatasetConfigOperation returns a new CreateDatasetConfigOperation from a given name.
486 // The name must be that of a previously created CreateDatasetConfigOperation, possibly from a different process.
487 func (c *Client) CreateDatasetConfigOperation(name string) *CreateDatasetConfigOperation {
488 return c.internalClient.CreateDatasetConfigOperation(name)
489 }
490
491 // UpdateDatasetConfig updates a dataset configuration in a given project for a given location.
492 func (c *Client) UpdateDatasetConfig(ctx context.Context, req *storageinsightspb.UpdateDatasetConfigRequest, opts ...gax.CallOption) (*UpdateDatasetConfigOperation, error) {
493 return c.internalClient.UpdateDatasetConfig(ctx, req, opts...)
494 }
495
496 // UpdateDatasetConfigOperation returns a new UpdateDatasetConfigOperation from a given name.
497 // The name must be that of a previously created UpdateDatasetConfigOperation, possibly from a different process.
498 func (c *Client) UpdateDatasetConfigOperation(name string) *UpdateDatasetConfigOperation {
499 return c.internalClient.UpdateDatasetConfigOperation(name)
500 }
501
502 // DeleteDatasetConfig deletes a dataset configuration in a given project for a given location.
503 func (c *Client) DeleteDatasetConfig(ctx context.Context, req *storageinsightspb.DeleteDatasetConfigRequest, opts ...gax.CallOption) (*DeleteDatasetConfigOperation, error) {
504 return c.internalClient.DeleteDatasetConfig(ctx, req, opts...)
505 }
506
507 // DeleteDatasetConfigOperation returns a new DeleteDatasetConfigOperation from a given name.
508 // The name must be that of a previously created DeleteDatasetConfigOperation, possibly from a different process.
509 func (c *Client) DeleteDatasetConfigOperation(name string) *DeleteDatasetConfigOperation {
510 return c.internalClient.DeleteDatasetConfigOperation(name)
511 }
512
513 // LinkDataset links a dataset to BigQuery in a given project for a given location.
514 func (c *Client) LinkDataset(ctx context.Context, req *storageinsightspb.LinkDatasetRequest, opts ...gax.CallOption) (*LinkDatasetOperation, error) {
515 return c.internalClient.LinkDataset(ctx, req, opts...)
516 }
517
518 // LinkDatasetOperation returns a new LinkDatasetOperation from a given name.
519 // The name must be that of a previously created LinkDatasetOperation, possibly from a different process.
520 func (c *Client) LinkDatasetOperation(name string) *LinkDatasetOperation {
521 return c.internalClient.LinkDatasetOperation(name)
522 }
523
524 // UnlinkDataset unlinks a dataset from BigQuery in a given project
525 // for a given location.
526 func (c *Client) UnlinkDataset(ctx context.Context, req *storageinsightspb.UnlinkDatasetRequest, opts ...gax.CallOption) (*UnlinkDatasetOperation, error) {
527 return c.internalClient.UnlinkDataset(ctx, req, opts...)
528 }
529
530 // UnlinkDatasetOperation returns a new UnlinkDatasetOperation from a given name.
531 // The name must be that of a previously created UnlinkDatasetOperation, possibly from a different process.
532 func (c *Client) UnlinkDatasetOperation(name string) *UnlinkDatasetOperation {
533 return c.internalClient.UnlinkDatasetOperation(name)
534 }
535
536 // GetLocation gets information about a location.
537 func (c *Client) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
538 return c.internalClient.GetLocation(ctx, req, opts...)
539 }
540
541 // ListLocations lists information about the supported locations for this service.
542 func (c *Client) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
543 return c.internalClient.ListLocations(ctx, req, opts...)
544 }
545
546 // CancelOperation is a utility method from google.longrunning.Operations.
547 func (c *Client) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
548 return c.internalClient.CancelOperation(ctx, req, opts...)
549 }
550
551 // DeleteOperation is a utility method from google.longrunning.Operations.
552 func (c *Client) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
553 return c.internalClient.DeleteOperation(ctx, req, opts...)
554 }
555
556 // GetOperation is a utility method from google.longrunning.Operations.
557 func (c *Client) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
558 return c.internalClient.GetOperation(ctx, req, opts...)
559 }
560
561 // ListOperations is a utility method from google.longrunning.Operations.
562 func (c *Client) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
563 return c.internalClient.ListOperations(ctx, req, opts...)
564 }
565
566 // gRPCClient is a client for interacting with Storage Insights API over gRPC transport.
567 //
568 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
569 type gRPCClient struct {
570 // Connection pool of gRPC connections to the service.
571 connPool gtransport.ConnPool
572
573 // Points back to the CallOptions field of the containing Client
574 CallOptions **CallOptions
575
576 // The gRPC API client.
577 client storageinsightspb.StorageInsightsClient
578
579 // LROClient is used internally to handle long-running operations.
580 // It is exposed so that its CallOptions can be modified if required.
581 // Users should not Close this client.
582 LROClient **lroauto.OperationsClient
583
584 operationsClient longrunningpb.OperationsClient
585
586 locationsClient locationpb.LocationsClient
587
588 // The x-goog-* metadata to be sent with each request.
589 xGoogHeaders []string
590
591 logger *slog.Logger
592 }
593
594 // NewClient creates a new storage insights client based on gRPC.
595 // The returned client must be Closed when it is done being used to clean up its underlying connections.
596 //
597 // Service describing handlers for resources
598 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
599 clientOpts := defaultGRPCClientOptions()
600 if newClientHook != nil {
601 hookOpts, err := newClientHook(ctx, clientHookParams{})
602 if err != nil {
603 return nil, err
604 }
605 clientOpts = append(clientOpts, hookOpts...)
606 }
607
608 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
609 if err != nil {
610 return nil, err
611 }
612 client := Client{CallOptions: defaultCallOptions()}
613
614 c := &gRPCClient{
615 connPool: connPool,
616 client: storageinsightspb.NewStorageInsightsClient(connPool),
617 CallOptions: &client.CallOptions,
618 logger: internaloption.GetLogger(opts),
619 operationsClient: longrunningpb.NewOperationsClient(connPool),
620 locationsClient: locationpb.NewLocationsClient(connPool),
621 }
622 c.setGoogleClientInfo()
623
624 client.internalClient = c
625
626 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
627 if err != nil {
628 // This error "should not happen", since we are just reusing old connection pool
629 // and never actually need to dial.
630 // If this does happen, we could leak connp. However, we cannot close conn:
631 // If the user invoked the constructor with option.WithGRPCConn,
632 // we would close a connection that's still in use.
633 // TODO: investigate error conditions.
634 return nil, err
635 }
636 c.LROClient = &client.LROClient
637 return &client, nil
638 }
639
640 // Connection returns a connection to the API service.
641 //
642 // Deprecated: Connections are now pooled so this method does not always
643 // return the same resource.
644 func (c *gRPCClient) Connection() *grpc.ClientConn {
645 return c.connPool.Conn()
646 }
647
648 // setGoogleClientInfo sets the name and version of the application in
649 // the `x-goog-api-client` header passed on each request. Intended for
650 // use by Google-written clients.
651 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
652 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
653 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
654 c.xGoogHeaders = []string{
655 "x-goog-api-client", gax.XGoogHeader(kv...),
656 }
657 }
658
659 // Close closes the connection to the API service. The user should invoke this when
660 // the client is no longer required.
661 func (c *gRPCClient) Close() error {
662 return c.connPool.Close()
663 }
664
665 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
666 type restClient struct {
667 // The http endpoint to connect to.
668 endpoint string
669
670 // The http client.
671 httpClient *http.Client
672
673 // LROClient is used internally to handle long-running operations.
674 // It is exposed so that its CallOptions can be modified if required.
675 // Users should not Close this client.
676 LROClient **lroauto.OperationsClient
677
678 // The x-goog-* headers to be sent with each request.
679 xGoogHeaders []string
680
681 // Points back to the CallOptions field of the containing Client
682 CallOptions **CallOptions
683
684 logger *slog.Logger
685 }
686
687 // NewRESTClient creates a new storage insights rest client.
688 //
689 // Service describing handlers for resources
690 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
691 clientOpts := append(defaultRESTClientOptions(), opts...)
692 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
693 if err != nil {
694 return nil, err
695 }
696
697 callOpts := defaultRESTCallOptions()
698 c := &restClient{
699 endpoint: endpoint,
700 httpClient: httpClient,
701 CallOptions: &callOpts,
702 logger: internaloption.GetLogger(opts),
703 }
704 c.setGoogleClientInfo()
705
706 lroOpts := []option.ClientOption{
707 option.WithHTTPClient(httpClient),
708 option.WithEndpoint(endpoint),
709 }
710 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
711 if err != nil {
712 return nil, err
713 }
714 c.LROClient = &opClient
715
716 return &Client{internalClient: c, CallOptions: callOpts}, nil
717 }
718
719 func defaultRESTClientOptions() []option.ClientOption {
720 return []option.ClientOption{
721 internaloption.WithDefaultEndpoint("https://storageinsights.googleapis.com"),
722 internaloption.WithDefaultEndpointTemplate("https://storageinsights.UNIVERSE_DOMAIN"),
723 internaloption.WithDefaultMTLSEndpoint("https://storageinsights.mtls.googleapis.com"),
724 internaloption.WithDefaultUniverseDomain("googleapis.com"),
725 internaloption.WithDefaultAudience("https://storageinsights.googleapis.com/"),
726 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
727 internaloption.EnableNewAuthLibrary(),
728 }
729 }
730
731 // setGoogleClientInfo sets the name and version of the application in
732 // the `x-goog-api-client` header passed on each request. Intended for
733 // use by Google-written clients.
734 func (c *restClient) setGoogleClientInfo(keyval ...string) {
735 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
736 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
737 c.xGoogHeaders = []string{
738 "x-goog-api-client", gax.XGoogHeader(kv...),
739 }
740 }
741
742 // Close closes the connection to the API service. The user should invoke this when
743 // the client is no longer required.
744 func (c *restClient) Close() error {
745 // Replace httpClient with nil to force cleanup.
746 c.httpClient = nil
747 return nil
748 }
749
750 // Connection returns a connection to the API service.
751 //
752 // Deprecated: This method always returns nil.
753 func (c *restClient) Connection() *grpc.ClientConn {
754 return nil
755 }
756 func (c *gRPCClient) ListReportConfigs(ctx context.Context, req *storageinsightspb.ListReportConfigsRequest, opts ...gax.CallOption) *ReportConfigIterator {
757 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
758
759 hds = append(c.xGoogHeaders, hds...)
760 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
761 opts = append((*c.CallOptions).ListReportConfigs[0:len((*c.CallOptions).ListReportConfigs):len((*c.CallOptions).ListReportConfigs)], opts...)
762 it := &ReportConfigIterator{}
763 req = proto.Clone(req).(*storageinsightspb.ListReportConfigsRequest)
764 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.ReportConfig, string, error) {
765 resp := &storageinsightspb.ListReportConfigsResponse{}
766 if pageToken != "" {
767 req.PageToken = pageToken
768 }
769 if pageSize > math.MaxInt32 {
770 req.PageSize = math.MaxInt32
771 } else if pageSize != 0 {
772 req.PageSize = int32(pageSize)
773 }
774 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
775 var err error
776 resp, err = executeRPC(ctx, c.client.ListReportConfigs, req, settings.GRPC, c.logger, "ListReportConfigs")
777 return err
778 }, opts...)
779 if err != nil {
780 return nil, "", err
781 }
782
783 it.Response = resp
784 return resp.GetReportConfigs(), resp.GetNextPageToken(), nil
785 }
786 fetch := func(pageSize int, pageToken string) (string, error) {
787 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
788 if err != nil {
789 return "", err
790 }
791 it.items = append(it.items, items...)
792 return nextPageToken, nil
793 }
794
795 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
796 it.pageInfo.MaxSize = int(req.GetPageSize())
797 it.pageInfo.Token = req.GetPageToken()
798
799 return it
800 }
801
802 func (c *gRPCClient) GetReportConfig(ctx context.Context, req *storageinsightspb.GetReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
803 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
804
805 hds = append(c.xGoogHeaders, hds...)
806 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
807 opts = append((*c.CallOptions).GetReportConfig[0:len((*c.CallOptions).GetReportConfig):len((*c.CallOptions).GetReportConfig)], opts...)
808 var resp *storageinsightspb.ReportConfig
809 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
810 var err error
811 resp, err = executeRPC(ctx, c.client.GetReportConfig, req, settings.GRPC, c.logger, "GetReportConfig")
812 return err
813 }, opts...)
814 if err != nil {
815 return nil, err
816 }
817 return resp, nil
818 }
819
820 func (c *gRPCClient) CreateReportConfig(ctx context.Context, req *storageinsightspb.CreateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
821 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
822
823 hds = append(c.xGoogHeaders, hds...)
824 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
825 opts = append((*c.CallOptions).CreateReportConfig[0:len((*c.CallOptions).CreateReportConfig):len((*c.CallOptions).CreateReportConfig)], opts...)
826 var resp *storageinsightspb.ReportConfig
827 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
828 var err error
829 resp, err = executeRPC(ctx, c.client.CreateReportConfig, req, settings.GRPC, c.logger, "CreateReportConfig")
830 return err
831 }, opts...)
832 if err != nil {
833 return nil, err
834 }
835 return resp, nil
836 }
837
838 func (c *gRPCClient) UpdateReportConfig(ctx context.Context, req *storageinsightspb.UpdateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
839 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "report_config.name", url.QueryEscape(req.GetReportConfig().GetName()))}
840
841 hds = append(c.xGoogHeaders, hds...)
842 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
843 opts = append((*c.CallOptions).UpdateReportConfig[0:len((*c.CallOptions).UpdateReportConfig):len((*c.CallOptions).UpdateReportConfig)], opts...)
844 var resp *storageinsightspb.ReportConfig
845 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
846 var err error
847 resp, err = executeRPC(ctx, c.client.UpdateReportConfig, req, settings.GRPC, c.logger, "UpdateReportConfig")
848 return err
849 }, opts...)
850 if err != nil {
851 return nil, err
852 }
853 return resp, nil
854 }
855
856 func (c *gRPCClient) DeleteReportConfig(ctx context.Context, req *storageinsightspb.DeleteReportConfigRequest, opts ...gax.CallOption) error {
857 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
858
859 hds = append(c.xGoogHeaders, hds...)
860 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
861 opts = append((*c.CallOptions).DeleteReportConfig[0:len((*c.CallOptions).DeleteReportConfig):len((*c.CallOptions).DeleteReportConfig)], opts...)
862 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
863 var err error
864 _, err = executeRPC(ctx, c.client.DeleteReportConfig, req, settings.GRPC, c.logger, "DeleteReportConfig")
865 return err
866 }, opts...)
867 return err
868 }
869
870 func (c *gRPCClient) ListReportDetails(ctx context.Context, req *storageinsightspb.ListReportDetailsRequest, opts ...gax.CallOption) *ReportDetailIterator {
871 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
872
873 hds = append(c.xGoogHeaders, hds...)
874 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
875 opts = append((*c.CallOptions).ListReportDetails[0:len((*c.CallOptions).ListReportDetails):len((*c.CallOptions).ListReportDetails)], opts...)
876 it := &ReportDetailIterator{}
877 req = proto.Clone(req).(*storageinsightspb.ListReportDetailsRequest)
878 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.ReportDetail, string, error) {
879 resp := &storageinsightspb.ListReportDetailsResponse{}
880 if pageToken != "" {
881 req.PageToken = pageToken
882 }
883 if pageSize > math.MaxInt32 {
884 req.PageSize = math.MaxInt32
885 } else if pageSize != 0 {
886 req.PageSize = int32(pageSize)
887 }
888 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
889 var err error
890 resp, err = executeRPC(ctx, c.client.ListReportDetails, req, settings.GRPC, c.logger, "ListReportDetails")
891 return err
892 }, opts...)
893 if err != nil {
894 return nil, "", err
895 }
896
897 it.Response = resp
898 return resp.GetReportDetails(), resp.GetNextPageToken(), nil
899 }
900 fetch := func(pageSize int, pageToken string) (string, error) {
901 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
902 if err != nil {
903 return "", err
904 }
905 it.items = append(it.items, items...)
906 return nextPageToken, nil
907 }
908
909 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
910 it.pageInfo.MaxSize = int(req.GetPageSize())
911 it.pageInfo.Token = req.GetPageToken()
912
913 return it
914 }
915
916 func (c *gRPCClient) GetReportDetail(ctx context.Context, req *storageinsightspb.GetReportDetailRequest, opts ...gax.CallOption) (*storageinsightspb.ReportDetail, error) {
917 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
918
919 hds = append(c.xGoogHeaders, hds...)
920 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
921 opts = append((*c.CallOptions).GetReportDetail[0:len((*c.CallOptions).GetReportDetail):len((*c.CallOptions).GetReportDetail)], opts...)
922 var resp *storageinsightspb.ReportDetail
923 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
924 var err error
925 resp, err = executeRPC(ctx, c.client.GetReportDetail, req, settings.GRPC, c.logger, "GetReportDetail")
926 return err
927 }, opts...)
928 if err != nil {
929 return nil, err
930 }
931 return resp, nil
932 }
933
934 func (c *gRPCClient) ListDatasetConfigs(ctx context.Context, req *storageinsightspb.ListDatasetConfigsRequest, opts ...gax.CallOption) *DatasetConfigIterator {
935 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
936
937 hds = append(c.xGoogHeaders, hds...)
938 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
939 opts = append((*c.CallOptions).ListDatasetConfigs[0:len((*c.CallOptions).ListDatasetConfigs):len((*c.CallOptions).ListDatasetConfigs)], opts...)
940 it := &DatasetConfigIterator{}
941 req = proto.Clone(req).(*storageinsightspb.ListDatasetConfigsRequest)
942 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.DatasetConfig, string, error) {
943 resp := &storageinsightspb.ListDatasetConfigsResponse{}
944 if pageToken != "" {
945 req.PageToken = pageToken
946 }
947 if pageSize > math.MaxInt32 {
948 req.PageSize = math.MaxInt32
949 } else if pageSize != 0 {
950 req.PageSize = int32(pageSize)
951 }
952 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
953 var err error
954 resp, err = executeRPC(ctx, c.client.ListDatasetConfigs, req, settings.GRPC, c.logger, "ListDatasetConfigs")
955 return err
956 }, opts...)
957 if err != nil {
958 return nil, "", err
959 }
960
961 it.Response = resp
962 return resp.GetDatasetConfigs(), resp.GetNextPageToken(), nil
963 }
964 fetch := func(pageSize int, pageToken string) (string, error) {
965 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
966 if err != nil {
967 return "", err
968 }
969 it.items = append(it.items, items...)
970 return nextPageToken, nil
971 }
972
973 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
974 it.pageInfo.MaxSize = int(req.GetPageSize())
975 it.pageInfo.Token = req.GetPageToken()
976
977 return it
978 }
979
980 func (c *gRPCClient) GetDatasetConfig(ctx context.Context, req *storageinsightspb.GetDatasetConfigRequest, opts ...gax.CallOption) (*storageinsightspb.DatasetConfig, error) {
981 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
982
983 hds = append(c.xGoogHeaders, hds...)
984 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
985 opts = append((*c.CallOptions).GetDatasetConfig[0:len((*c.CallOptions).GetDatasetConfig):len((*c.CallOptions).GetDatasetConfig)], opts...)
986 var resp *storageinsightspb.DatasetConfig
987 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
988 var err error
989 resp, err = executeRPC(ctx, c.client.GetDatasetConfig, req, settings.GRPC, c.logger, "GetDatasetConfig")
990 return err
991 }, opts...)
992 if err != nil {
993 return nil, err
994 }
995 return resp, nil
996 }
997
998 func (c *gRPCClient) CreateDatasetConfig(ctx context.Context, req *storageinsightspb.CreateDatasetConfigRequest, opts ...gax.CallOption) (*CreateDatasetConfigOperation, error) {
999 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1000
1001 hds = append(c.xGoogHeaders, hds...)
1002 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1003 opts = append((*c.CallOptions).CreateDatasetConfig[0:len((*c.CallOptions).CreateDatasetConfig):len((*c.CallOptions).CreateDatasetConfig)], opts...)
1004 var resp *longrunningpb.Operation
1005 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1006 var err error
1007 resp, err = executeRPC(ctx, c.client.CreateDatasetConfig, req, settings.GRPC, c.logger, "CreateDatasetConfig")
1008 return err
1009 }, opts...)
1010 if err != nil {
1011 return nil, err
1012 }
1013 return &CreateDatasetConfigOperation{
1014 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1015 }, nil
1016 }
1017
1018 func (c *gRPCClient) UpdateDatasetConfig(ctx context.Context, req *storageinsightspb.UpdateDatasetConfigRequest, opts ...gax.CallOption) (*UpdateDatasetConfigOperation, error) {
1019 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "dataset_config.name", url.QueryEscape(req.GetDatasetConfig().GetName()))}
1020
1021 hds = append(c.xGoogHeaders, hds...)
1022 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1023 opts = append((*c.CallOptions).UpdateDatasetConfig[0:len((*c.CallOptions).UpdateDatasetConfig):len((*c.CallOptions).UpdateDatasetConfig)], opts...)
1024 var resp *longrunningpb.Operation
1025 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1026 var err error
1027 resp, err = executeRPC(ctx, c.client.UpdateDatasetConfig, req, settings.GRPC, c.logger, "UpdateDatasetConfig")
1028 return err
1029 }, opts...)
1030 if err != nil {
1031 return nil, err
1032 }
1033 return &UpdateDatasetConfigOperation{
1034 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1035 }, nil
1036 }
1037
1038 func (c *gRPCClient) DeleteDatasetConfig(ctx context.Context, req *storageinsightspb.DeleteDatasetConfigRequest, opts ...gax.CallOption) (*DeleteDatasetConfigOperation, error) {
1039 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1040
1041 hds = append(c.xGoogHeaders, hds...)
1042 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1043 opts = append((*c.CallOptions).DeleteDatasetConfig[0:len((*c.CallOptions).DeleteDatasetConfig):len((*c.CallOptions).DeleteDatasetConfig)], opts...)
1044 var resp *longrunningpb.Operation
1045 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1046 var err error
1047 resp, err = executeRPC(ctx, c.client.DeleteDatasetConfig, req, settings.GRPC, c.logger, "DeleteDatasetConfig")
1048 return err
1049 }, opts...)
1050 if err != nil {
1051 return nil, err
1052 }
1053 return &DeleteDatasetConfigOperation{
1054 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1055 }, nil
1056 }
1057
1058 func (c *gRPCClient) LinkDataset(ctx context.Context, req *storageinsightspb.LinkDatasetRequest, opts ...gax.CallOption) (*LinkDatasetOperation, error) {
1059 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1060
1061 hds = append(c.xGoogHeaders, hds...)
1062 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1063 opts = append((*c.CallOptions).LinkDataset[0:len((*c.CallOptions).LinkDataset):len((*c.CallOptions).LinkDataset)], opts...)
1064 var resp *longrunningpb.Operation
1065 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1066 var err error
1067 resp, err = executeRPC(ctx, c.client.LinkDataset, req, settings.GRPC, c.logger, "LinkDataset")
1068 return err
1069 }, opts...)
1070 if err != nil {
1071 return nil, err
1072 }
1073 return &LinkDatasetOperation{
1074 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1075 }, nil
1076 }
1077
1078 func (c *gRPCClient) UnlinkDataset(ctx context.Context, req *storageinsightspb.UnlinkDatasetRequest, opts ...gax.CallOption) (*UnlinkDatasetOperation, error) {
1079 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1080
1081 hds = append(c.xGoogHeaders, hds...)
1082 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1083 opts = append((*c.CallOptions).UnlinkDataset[0:len((*c.CallOptions).UnlinkDataset):len((*c.CallOptions).UnlinkDataset)], opts...)
1084 var resp *longrunningpb.Operation
1085 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1086 var err error
1087 resp, err = executeRPC(ctx, c.client.UnlinkDataset, req, settings.GRPC, c.logger, "UnlinkDataset")
1088 return err
1089 }, opts...)
1090 if err != nil {
1091 return nil, err
1092 }
1093 return &UnlinkDatasetOperation{
1094 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1095 }, nil
1096 }
1097
1098 func (c *gRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1099 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1100
1101 hds = append(c.xGoogHeaders, hds...)
1102 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1103 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1104 var resp *locationpb.Location
1105 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1106 var err error
1107 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
1108 return err
1109 }, opts...)
1110 if err != nil {
1111 return nil, err
1112 }
1113 return resp, nil
1114 }
1115
1116 func (c *gRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1117 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1118
1119 hds = append(c.xGoogHeaders, hds...)
1120 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1121 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1122 it := &LocationIterator{}
1123 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1124 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1125 resp := &locationpb.ListLocationsResponse{}
1126 if pageToken != "" {
1127 req.PageToken = pageToken
1128 }
1129 if pageSize > math.MaxInt32 {
1130 req.PageSize = math.MaxInt32
1131 } else if pageSize != 0 {
1132 req.PageSize = int32(pageSize)
1133 }
1134 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1135 var err error
1136 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
1137 return err
1138 }, opts...)
1139 if err != nil {
1140 return nil, "", err
1141 }
1142
1143 it.Response = resp
1144 return resp.GetLocations(), resp.GetNextPageToken(), nil
1145 }
1146 fetch := func(pageSize int, pageToken string) (string, error) {
1147 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1148 if err != nil {
1149 return "", err
1150 }
1151 it.items = append(it.items, items...)
1152 return nextPageToken, nil
1153 }
1154
1155 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1156 it.pageInfo.MaxSize = int(req.GetPageSize())
1157 it.pageInfo.Token = req.GetPageToken()
1158
1159 return it
1160 }
1161
1162 func (c *gRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1163 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1164
1165 hds = append(c.xGoogHeaders, hds...)
1166 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1167 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
1168 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1169 var err error
1170 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
1171 return err
1172 }, opts...)
1173 return err
1174 }
1175
1176 func (c *gRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1177 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1178
1179 hds = append(c.xGoogHeaders, hds...)
1180 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1181 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
1182 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1183 var err error
1184 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
1185 return err
1186 }, opts...)
1187 return err
1188 }
1189
1190 func (c *gRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1191 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1192
1193 hds = append(c.xGoogHeaders, hds...)
1194 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1195 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1196 var resp *longrunningpb.Operation
1197 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1198 var err error
1199 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1200 return err
1201 }, opts...)
1202 if err != nil {
1203 return nil, err
1204 }
1205 return resp, nil
1206 }
1207
1208 func (c *gRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1209 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1210
1211 hds = append(c.xGoogHeaders, hds...)
1212 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1213 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
1214 it := &OperationIterator{}
1215 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1216 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1217 resp := &longrunningpb.ListOperationsResponse{}
1218 if pageToken != "" {
1219 req.PageToken = pageToken
1220 }
1221 if pageSize > math.MaxInt32 {
1222 req.PageSize = math.MaxInt32
1223 } else if pageSize != 0 {
1224 req.PageSize = int32(pageSize)
1225 }
1226 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1227 var err error
1228 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
1229 return err
1230 }, opts...)
1231 if err != nil {
1232 return nil, "", err
1233 }
1234
1235 it.Response = resp
1236 return resp.GetOperations(), resp.GetNextPageToken(), nil
1237 }
1238 fetch := func(pageSize int, pageToken string) (string, error) {
1239 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1240 if err != nil {
1241 return "", err
1242 }
1243 it.items = append(it.items, items...)
1244 return nextPageToken, nil
1245 }
1246
1247 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1248 it.pageInfo.MaxSize = int(req.GetPageSize())
1249 it.pageInfo.Token = req.GetPageToken()
1250
1251 return it
1252 }
1253
1254 // ListReportConfigs lists ReportConfigs in a given project and location.
1255 func (c *restClient) ListReportConfigs(ctx context.Context, req *storageinsightspb.ListReportConfigsRequest, opts ...gax.CallOption) *ReportConfigIterator {
1256 it := &ReportConfigIterator{}
1257 req = proto.Clone(req).(*storageinsightspb.ListReportConfigsRequest)
1258 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1259 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.ReportConfig, string, error) {
1260 resp := &storageinsightspb.ListReportConfigsResponse{}
1261 if pageToken != "" {
1262 req.PageToken = pageToken
1263 }
1264 if pageSize > math.MaxInt32 {
1265 req.PageSize = math.MaxInt32
1266 } else if pageSize != 0 {
1267 req.PageSize = int32(pageSize)
1268 }
1269 baseUrl, err := url.Parse(c.endpoint)
1270 if err != nil {
1271 return nil, "", err
1272 }
1273 baseUrl.Path += fmt.Sprintf("/v1/%v/reportConfigs", req.GetParent())
1274
1275 params := url.Values{}
1276 params.Add("$alt", "json;enum-encoding=int")
1277 if req.GetFilter() != "" {
1278 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1279 }
1280 if req.GetOrderBy() != "" {
1281 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1282 }
1283 if req.GetPageSize() != 0 {
1284 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1285 }
1286 if req.GetPageToken() != "" {
1287 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1288 }
1289
1290 baseUrl.RawQuery = params.Encode()
1291
1292 // Build HTTP headers from client and context metadata.
1293 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1294 headers := gax.BuildHeaders(ctx, hds...)
1295 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1296 if settings.Path != "" {
1297 baseUrl.Path = settings.Path
1298 }
1299 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1300 if err != nil {
1301 return err
1302 }
1303 httpReq.Header = headers
1304
1305 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListReportConfigs")
1306 if err != nil {
1307 return err
1308 }
1309 if err := unm.Unmarshal(buf, resp); err != nil {
1310 return err
1311 }
1312
1313 return nil
1314 }, opts...)
1315 if e != nil {
1316 return nil, "", e
1317 }
1318 it.Response = resp
1319 return resp.GetReportConfigs(), resp.GetNextPageToken(), nil
1320 }
1321
1322 fetch := func(pageSize int, pageToken string) (string, error) {
1323 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1324 if err != nil {
1325 return "", err
1326 }
1327 it.items = append(it.items, items...)
1328 return nextPageToken, nil
1329 }
1330
1331 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1332 it.pageInfo.MaxSize = int(req.GetPageSize())
1333 it.pageInfo.Token = req.GetPageToken()
1334
1335 return it
1336 }
1337
1338 // GetReportConfig gets details of a single ReportConfig.
1339 func (c *restClient) GetReportConfig(ctx context.Context, req *storageinsightspb.GetReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
1340 baseUrl, err := url.Parse(c.endpoint)
1341 if err != nil {
1342 return nil, err
1343 }
1344 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1345
1346 params := url.Values{}
1347 params.Add("$alt", "json;enum-encoding=int")
1348
1349 baseUrl.RawQuery = params.Encode()
1350
1351 // Build HTTP headers from client and context metadata.
1352 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1353
1354 hds = append(c.xGoogHeaders, hds...)
1355 hds = append(hds, "Content-Type", "application/json")
1356 headers := gax.BuildHeaders(ctx, hds...)
1357 opts = append((*c.CallOptions).GetReportConfig[0:len((*c.CallOptions).GetReportConfig):len((*c.CallOptions).GetReportConfig)], opts...)
1358 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1359 resp := &storageinsightspb.ReportConfig{}
1360 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1361 if settings.Path != "" {
1362 baseUrl.Path = settings.Path
1363 }
1364 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1365 if err != nil {
1366 return err
1367 }
1368 httpReq = httpReq.WithContext(ctx)
1369 httpReq.Header = headers
1370
1371 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetReportConfig")
1372 if err != nil {
1373 return err
1374 }
1375
1376 if err := unm.Unmarshal(buf, resp); err != nil {
1377 return err
1378 }
1379
1380 return nil
1381 }, opts...)
1382 if e != nil {
1383 return nil, e
1384 }
1385 return resp, nil
1386 }
1387
1388 // CreateReportConfig creates a new ReportConfig in a given project and location.
1389 func (c *restClient) CreateReportConfig(ctx context.Context, req *storageinsightspb.CreateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
1390 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1391 body := req.GetReportConfig()
1392 jsonReq, err := m.Marshal(body)
1393 if err != nil {
1394 return nil, err
1395 }
1396
1397 baseUrl, err := url.Parse(c.endpoint)
1398 if err != nil {
1399 return nil, err
1400 }
1401 baseUrl.Path += fmt.Sprintf("/v1/%v/reportConfigs", req.GetParent())
1402
1403 params := url.Values{}
1404 params.Add("$alt", "json;enum-encoding=int")
1405 if req.GetRequestId() != "" {
1406 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1407 }
1408
1409 baseUrl.RawQuery = params.Encode()
1410
1411 // Build HTTP headers from client and context metadata.
1412 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1413
1414 hds = append(c.xGoogHeaders, hds...)
1415 hds = append(hds, "Content-Type", "application/json")
1416 headers := gax.BuildHeaders(ctx, hds...)
1417 opts = append((*c.CallOptions).CreateReportConfig[0:len((*c.CallOptions).CreateReportConfig):len((*c.CallOptions).CreateReportConfig)], opts...)
1418 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1419 resp := &storageinsightspb.ReportConfig{}
1420 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1421 if settings.Path != "" {
1422 baseUrl.Path = settings.Path
1423 }
1424 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1425 if err != nil {
1426 return err
1427 }
1428 httpReq = httpReq.WithContext(ctx)
1429 httpReq.Header = headers
1430
1431 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateReportConfig")
1432 if err != nil {
1433 return err
1434 }
1435
1436 if err := unm.Unmarshal(buf, resp); err != nil {
1437 return err
1438 }
1439
1440 return nil
1441 }, opts...)
1442 if e != nil {
1443 return nil, e
1444 }
1445 return resp, nil
1446 }
1447
1448 // UpdateReportConfig updates the parameters of a single ReportConfig.
1449 func (c *restClient) UpdateReportConfig(ctx context.Context, req *storageinsightspb.UpdateReportConfigRequest, opts ...gax.CallOption) (*storageinsightspb.ReportConfig, error) {
1450 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1451 body := req.GetReportConfig()
1452 jsonReq, err := m.Marshal(body)
1453 if err != nil {
1454 return nil, err
1455 }
1456
1457 baseUrl, err := url.Parse(c.endpoint)
1458 if err != nil {
1459 return nil, err
1460 }
1461 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetReportConfig().GetName())
1462
1463 params := url.Values{}
1464 params.Add("$alt", "json;enum-encoding=int")
1465 if req.GetRequestId() != "" {
1466 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1467 }
1468 if req.GetUpdateMask() != nil {
1469 field, err := protojson.Marshal(req.GetUpdateMask())
1470 if err != nil {
1471 return nil, err
1472 }
1473 params.Add("updateMask", string(field[1:len(field)-1]))
1474 }
1475
1476 baseUrl.RawQuery = params.Encode()
1477
1478 // Build HTTP headers from client and context metadata.
1479 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "report_config.name", url.QueryEscape(req.GetReportConfig().GetName()))}
1480
1481 hds = append(c.xGoogHeaders, hds...)
1482 hds = append(hds, "Content-Type", "application/json")
1483 headers := gax.BuildHeaders(ctx, hds...)
1484 opts = append((*c.CallOptions).UpdateReportConfig[0:len((*c.CallOptions).UpdateReportConfig):len((*c.CallOptions).UpdateReportConfig)], opts...)
1485 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1486 resp := &storageinsightspb.ReportConfig{}
1487 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1488 if settings.Path != "" {
1489 baseUrl.Path = settings.Path
1490 }
1491 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1492 if err != nil {
1493 return err
1494 }
1495 httpReq = httpReq.WithContext(ctx)
1496 httpReq.Header = headers
1497
1498 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateReportConfig")
1499 if err != nil {
1500 return err
1501 }
1502
1503 if err := unm.Unmarshal(buf, resp); err != nil {
1504 return err
1505 }
1506
1507 return nil
1508 }, opts...)
1509 if e != nil {
1510 return nil, e
1511 }
1512 return resp, nil
1513 }
1514
1515 // DeleteReportConfig deletes a single ReportConfig.
1516 func (c *restClient) DeleteReportConfig(ctx context.Context, req *storageinsightspb.DeleteReportConfigRequest, opts ...gax.CallOption) error {
1517 baseUrl, err := url.Parse(c.endpoint)
1518 if err != nil {
1519 return err
1520 }
1521 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1522
1523 params := url.Values{}
1524 params.Add("$alt", "json;enum-encoding=int")
1525 if req.GetForce() {
1526 params.Add("force", fmt.Sprintf("%v", req.GetForce()))
1527 }
1528 if req.GetRequestId() != "" {
1529 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1530 }
1531
1532 baseUrl.RawQuery = params.Encode()
1533
1534 // Build HTTP headers from client and context metadata.
1535 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1536
1537 hds = append(c.xGoogHeaders, hds...)
1538 hds = append(hds, "Content-Type", "application/json")
1539 headers := gax.BuildHeaders(ctx, hds...)
1540 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1541 if settings.Path != "" {
1542 baseUrl.Path = settings.Path
1543 }
1544 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1545 if err != nil {
1546 return err
1547 }
1548 httpReq = httpReq.WithContext(ctx)
1549 httpReq.Header = headers
1550
1551 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteReportConfig")
1552 return err
1553 }, opts...)
1554 }
1555
1556 // ListReportDetails lists ReportDetails in a given project and location.
1557 func (c *restClient) ListReportDetails(ctx context.Context, req *storageinsightspb.ListReportDetailsRequest, opts ...gax.CallOption) *ReportDetailIterator {
1558 it := &ReportDetailIterator{}
1559 req = proto.Clone(req).(*storageinsightspb.ListReportDetailsRequest)
1560 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1561 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.ReportDetail, string, error) {
1562 resp := &storageinsightspb.ListReportDetailsResponse{}
1563 if pageToken != "" {
1564 req.PageToken = pageToken
1565 }
1566 if pageSize > math.MaxInt32 {
1567 req.PageSize = math.MaxInt32
1568 } else if pageSize != 0 {
1569 req.PageSize = int32(pageSize)
1570 }
1571 baseUrl, err := url.Parse(c.endpoint)
1572 if err != nil {
1573 return nil, "", err
1574 }
1575 baseUrl.Path += fmt.Sprintf("/v1/%v/reportDetails", req.GetParent())
1576
1577 params := url.Values{}
1578 params.Add("$alt", "json;enum-encoding=int")
1579 if req.GetFilter() != "" {
1580 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1581 }
1582 if req.GetOrderBy() != "" {
1583 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1584 }
1585 if req.GetPageSize() != 0 {
1586 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1587 }
1588 if req.GetPageToken() != "" {
1589 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1590 }
1591
1592 baseUrl.RawQuery = params.Encode()
1593
1594 // Build HTTP headers from client and context metadata.
1595 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1596 headers := gax.BuildHeaders(ctx, hds...)
1597 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1598 if settings.Path != "" {
1599 baseUrl.Path = settings.Path
1600 }
1601 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1602 if err != nil {
1603 return err
1604 }
1605 httpReq.Header = headers
1606
1607 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListReportDetails")
1608 if err != nil {
1609 return err
1610 }
1611 if err := unm.Unmarshal(buf, resp); err != nil {
1612 return err
1613 }
1614
1615 return nil
1616 }, opts...)
1617 if e != nil {
1618 return nil, "", e
1619 }
1620 it.Response = resp
1621 return resp.GetReportDetails(), resp.GetNextPageToken(), nil
1622 }
1623
1624 fetch := func(pageSize int, pageToken string) (string, error) {
1625 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1626 if err != nil {
1627 return "", err
1628 }
1629 it.items = append(it.items, items...)
1630 return nextPageToken, nil
1631 }
1632
1633 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1634 it.pageInfo.MaxSize = int(req.GetPageSize())
1635 it.pageInfo.Token = req.GetPageToken()
1636
1637 return it
1638 }
1639
1640 // GetReportDetail gets details of a single ReportDetail.
1641 func (c *restClient) GetReportDetail(ctx context.Context, req *storageinsightspb.GetReportDetailRequest, opts ...gax.CallOption) (*storageinsightspb.ReportDetail, error) {
1642 baseUrl, err := url.Parse(c.endpoint)
1643 if err != nil {
1644 return nil, err
1645 }
1646 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1647
1648 params := url.Values{}
1649 params.Add("$alt", "json;enum-encoding=int")
1650
1651 baseUrl.RawQuery = params.Encode()
1652
1653 // Build HTTP headers from client and context metadata.
1654 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1655
1656 hds = append(c.xGoogHeaders, hds...)
1657 hds = append(hds, "Content-Type", "application/json")
1658 headers := gax.BuildHeaders(ctx, hds...)
1659 opts = append((*c.CallOptions).GetReportDetail[0:len((*c.CallOptions).GetReportDetail):len((*c.CallOptions).GetReportDetail)], opts...)
1660 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1661 resp := &storageinsightspb.ReportDetail{}
1662 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1663 if settings.Path != "" {
1664 baseUrl.Path = settings.Path
1665 }
1666 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1667 if err != nil {
1668 return err
1669 }
1670 httpReq = httpReq.WithContext(ctx)
1671 httpReq.Header = headers
1672
1673 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetReportDetail")
1674 if err != nil {
1675 return err
1676 }
1677
1678 if err := unm.Unmarshal(buf, resp); err != nil {
1679 return err
1680 }
1681
1682 return nil
1683 }, opts...)
1684 if e != nil {
1685 return nil, e
1686 }
1687 return resp, nil
1688 }
1689
1690 // ListDatasetConfigs lists the dataset configurations in a given project for a given location.
1691 func (c *restClient) ListDatasetConfigs(ctx context.Context, req *storageinsightspb.ListDatasetConfigsRequest, opts ...gax.CallOption) *DatasetConfigIterator {
1692 it := &DatasetConfigIterator{}
1693 req = proto.Clone(req).(*storageinsightspb.ListDatasetConfigsRequest)
1694 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1695 it.InternalFetch = func(pageSize int, pageToken string) ([]*storageinsightspb.DatasetConfig, string, error) {
1696 resp := &storageinsightspb.ListDatasetConfigsResponse{}
1697 if pageToken != "" {
1698 req.PageToken = pageToken
1699 }
1700 if pageSize > math.MaxInt32 {
1701 req.PageSize = math.MaxInt32
1702 } else if pageSize != 0 {
1703 req.PageSize = int32(pageSize)
1704 }
1705 baseUrl, err := url.Parse(c.endpoint)
1706 if err != nil {
1707 return nil, "", err
1708 }
1709 baseUrl.Path += fmt.Sprintf("/v1/%v/datasetConfigs", req.GetParent())
1710
1711 params := url.Values{}
1712 params.Add("$alt", "json;enum-encoding=int")
1713 if req.GetFilter() != "" {
1714 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1715 }
1716 if req.GetOrderBy() != "" {
1717 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1718 }
1719 if req.GetPageSize() != 0 {
1720 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1721 }
1722 if req.GetPageToken() != "" {
1723 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1724 }
1725
1726 baseUrl.RawQuery = params.Encode()
1727
1728 // Build HTTP headers from client and context metadata.
1729 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1730 headers := gax.BuildHeaders(ctx, hds...)
1731 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1732 if settings.Path != "" {
1733 baseUrl.Path = settings.Path
1734 }
1735 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1736 if err != nil {
1737 return err
1738 }
1739 httpReq.Header = headers
1740
1741 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDatasetConfigs")
1742 if err != nil {
1743 return err
1744 }
1745 if err := unm.Unmarshal(buf, resp); err != nil {
1746 return err
1747 }
1748
1749 return nil
1750 }, opts...)
1751 if e != nil {
1752 return nil, "", e
1753 }
1754 it.Response = resp
1755 return resp.GetDatasetConfigs(), resp.GetNextPageToken(), nil
1756 }
1757
1758 fetch := func(pageSize int, pageToken string) (string, error) {
1759 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1760 if err != nil {
1761 return "", err
1762 }
1763 it.items = append(it.items, items...)
1764 return nextPageToken, nil
1765 }
1766
1767 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1768 it.pageInfo.MaxSize = int(req.GetPageSize())
1769 it.pageInfo.Token = req.GetPageToken()
1770
1771 return it
1772 }
1773
1774 // GetDatasetConfig gets the dataset configuration in a given project for a given location.
1775 func (c *restClient) GetDatasetConfig(ctx context.Context, req *storageinsightspb.GetDatasetConfigRequest, opts ...gax.CallOption) (*storageinsightspb.DatasetConfig, error) {
1776 baseUrl, err := url.Parse(c.endpoint)
1777 if err != nil {
1778 return nil, err
1779 }
1780 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1781
1782 params := url.Values{}
1783 params.Add("$alt", "json;enum-encoding=int")
1784
1785 baseUrl.RawQuery = params.Encode()
1786
1787 // Build HTTP headers from client and context metadata.
1788 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1789
1790 hds = append(c.xGoogHeaders, hds...)
1791 hds = append(hds, "Content-Type", "application/json")
1792 headers := gax.BuildHeaders(ctx, hds...)
1793 opts = append((*c.CallOptions).GetDatasetConfig[0:len((*c.CallOptions).GetDatasetConfig):len((*c.CallOptions).GetDatasetConfig)], opts...)
1794 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1795 resp := &storageinsightspb.DatasetConfig{}
1796 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1797 if settings.Path != "" {
1798 baseUrl.Path = settings.Path
1799 }
1800 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1801 if err != nil {
1802 return err
1803 }
1804 httpReq = httpReq.WithContext(ctx)
1805 httpReq.Header = headers
1806
1807 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDatasetConfig")
1808 if err != nil {
1809 return err
1810 }
1811
1812 if err := unm.Unmarshal(buf, resp); err != nil {
1813 return err
1814 }
1815
1816 return nil
1817 }, opts...)
1818 if e != nil {
1819 return nil, e
1820 }
1821 return resp, nil
1822 }
1823
1824 // CreateDatasetConfig creates a dataset configuration in a given project for a given location.
1825 func (c *restClient) CreateDatasetConfig(ctx context.Context, req *storageinsightspb.CreateDatasetConfigRequest, opts ...gax.CallOption) (*CreateDatasetConfigOperation, error) {
1826 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1827 body := req.GetDatasetConfig()
1828 jsonReq, err := m.Marshal(body)
1829 if err != nil {
1830 return nil, err
1831 }
1832
1833 baseUrl, err := url.Parse(c.endpoint)
1834 if err != nil {
1835 return nil, err
1836 }
1837 baseUrl.Path += fmt.Sprintf("/v1/%v/datasetConfigs", req.GetParent())
1838
1839 params := url.Values{}
1840 params.Add("$alt", "json;enum-encoding=int")
1841 params.Add("datasetConfigId", fmt.Sprintf("%v", req.GetDatasetConfigId()))
1842 if req.GetRequestId() != "" {
1843 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1844 }
1845
1846 baseUrl.RawQuery = params.Encode()
1847
1848 // Build HTTP headers from client and context metadata.
1849 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1850
1851 hds = append(c.xGoogHeaders, hds...)
1852 hds = append(hds, "Content-Type", "application/json")
1853 headers := gax.BuildHeaders(ctx, hds...)
1854 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1855 resp := &longrunningpb.Operation{}
1856 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1857 if settings.Path != "" {
1858 baseUrl.Path = settings.Path
1859 }
1860 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1861 if err != nil {
1862 return err
1863 }
1864 httpReq = httpReq.WithContext(ctx)
1865 httpReq.Header = headers
1866
1867 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDatasetConfig")
1868 if err != nil {
1869 return err
1870 }
1871 if err := unm.Unmarshal(buf, resp); err != nil {
1872 return err
1873 }
1874
1875 return nil
1876 }, opts...)
1877 if e != nil {
1878 return nil, e
1879 }
1880
1881 override := fmt.Sprintf("/v1/%s", resp.GetName())
1882 return &CreateDatasetConfigOperation{
1883 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1884 pollPath: override,
1885 }, nil
1886 }
1887
1888 // UpdateDatasetConfig updates a dataset configuration in a given project for a given location.
1889 func (c *restClient) UpdateDatasetConfig(ctx context.Context, req *storageinsightspb.UpdateDatasetConfigRequest, opts ...gax.CallOption) (*UpdateDatasetConfigOperation, error) {
1890 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1891 body := req.GetDatasetConfig()
1892 jsonReq, err := m.Marshal(body)
1893 if err != nil {
1894 return nil, err
1895 }
1896
1897 baseUrl, err := url.Parse(c.endpoint)
1898 if err != nil {
1899 return nil, err
1900 }
1901 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetDatasetConfig().GetName())
1902
1903 params := url.Values{}
1904 params.Add("$alt", "json;enum-encoding=int")
1905 if req.GetRequestId() != "" {
1906 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1907 }
1908 if req.GetUpdateMask() != nil {
1909 field, err := protojson.Marshal(req.GetUpdateMask())
1910 if err != nil {
1911 return nil, err
1912 }
1913 params.Add("updateMask", string(field[1:len(field)-1]))
1914 }
1915
1916 baseUrl.RawQuery = params.Encode()
1917
1918 // Build HTTP headers from client and context metadata.
1919 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "dataset_config.name", url.QueryEscape(req.GetDatasetConfig().GetName()))}
1920
1921 hds = append(c.xGoogHeaders, hds...)
1922 hds = append(hds, "Content-Type", "application/json")
1923 headers := gax.BuildHeaders(ctx, hds...)
1924 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1925 resp := &longrunningpb.Operation{}
1926 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1927 if settings.Path != "" {
1928 baseUrl.Path = settings.Path
1929 }
1930 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1931 if err != nil {
1932 return err
1933 }
1934 httpReq = httpReq.WithContext(ctx)
1935 httpReq.Header = headers
1936
1937 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDatasetConfig")
1938 if err != nil {
1939 return err
1940 }
1941 if err := unm.Unmarshal(buf, resp); err != nil {
1942 return err
1943 }
1944
1945 return nil
1946 }, opts...)
1947 if e != nil {
1948 return nil, e
1949 }
1950
1951 override := fmt.Sprintf("/v1/%s", resp.GetName())
1952 return &UpdateDatasetConfigOperation{
1953 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1954 pollPath: override,
1955 }, nil
1956 }
1957
1958 // DeleteDatasetConfig deletes a dataset configuration in a given project for a given location.
1959 func (c *restClient) DeleteDatasetConfig(ctx context.Context, req *storageinsightspb.DeleteDatasetConfigRequest, opts ...gax.CallOption) (*DeleteDatasetConfigOperation, error) {
1960 baseUrl, err := url.Parse(c.endpoint)
1961 if err != nil {
1962 return nil, err
1963 }
1964 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1965
1966 params := url.Values{}
1967 params.Add("$alt", "json;enum-encoding=int")
1968 if req.GetRequestId() != "" {
1969 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1970 }
1971
1972 baseUrl.RawQuery = params.Encode()
1973
1974 // Build HTTP headers from client and context metadata.
1975 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1976
1977 hds = append(c.xGoogHeaders, hds...)
1978 hds = append(hds, "Content-Type", "application/json")
1979 headers := gax.BuildHeaders(ctx, hds...)
1980 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1981 resp := &longrunningpb.Operation{}
1982 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1983 if settings.Path != "" {
1984 baseUrl.Path = settings.Path
1985 }
1986 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1987 if err != nil {
1988 return err
1989 }
1990 httpReq = httpReq.WithContext(ctx)
1991 httpReq.Header = headers
1992
1993 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDatasetConfig")
1994 if err != nil {
1995 return err
1996 }
1997 if err := unm.Unmarshal(buf, resp); err != nil {
1998 return err
1999 }
2000
2001 return nil
2002 }, opts...)
2003 if e != nil {
2004 return nil, e
2005 }
2006
2007 override := fmt.Sprintf("/v1/%s", resp.GetName())
2008 return &DeleteDatasetConfigOperation{
2009 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2010 pollPath: override,
2011 }, nil
2012 }
2013
2014 // LinkDataset links a dataset to BigQuery in a given project for a given location.
2015 func (c *restClient) LinkDataset(ctx context.Context, req *storageinsightspb.LinkDatasetRequest, opts ...gax.CallOption) (*LinkDatasetOperation, error) {
2016 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2017 jsonReq, err := m.Marshal(req)
2018 if err != nil {
2019 return nil, err
2020 }
2021
2022 baseUrl, err := url.Parse(c.endpoint)
2023 if err != nil {
2024 return nil, err
2025 }
2026 baseUrl.Path += fmt.Sprintf("/v1/%v:linkDataset", req.GetName())
2027
2028 params := url.Values{}
2029 params.Add("$alt", "json;enum-encoding=int")
2030
2031 baseUrl.RawQuery = params.Encode()
2032
2033 // Build HTTP headers from client and context metadata.
2034 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2035
2036 hds = append(c.xGoogHeaders, hds...)
2037 hds = append(hds, "Content-Type", "application/json")
2038 headers := gax.BuildHeaders(ctx, hds...)
2039 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2040 resp := &longrunningpb.Operation{}
2041 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2042 if settings.Path != "" {
2043 baseUrl.Path = settings.Path
2044 }
2045 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2046 if err != nil {
2047 return err
2048 }
2049 httpReq = httpReq.WithContext(ctx)
2050 httpReq.Header = headers
2051
2052 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "LinkDataset")
2053 if err != nil {
2054 return err
2055 }
2056 if err := unm.Unmarshal(buf, resp); err != nil {
2057 return err
2058 }
2059
2060 return nil
2061 }, opts...)
2062 if e != nil {
2063 return nil, e
2064 }
2065
2066 override := fmt.Sprintf("/v1/%s", resp.GetName())
2067 return &LinkDatasetOperation{
2068 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2069 pollPath: override,
2070 }, nil
2071 }
2072
2073 // UnlinkDataset unlinks a dataset from BigQuery in a given project
2074 // for a given location.
2075 func (c *restClient) UnlinkDataset(ctx context.Context, req *storageinsightspb.UnlinkDatasetRequest, opts ...gax.CallOption) (*UnlinkDatasetOperation, error) {
2076 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2077 jsonReq, err := m.Marshal(req)
2078 if err != nil {
2079 return nil, err
2080 }
2081
2082 baseUrl, err := url.Parse(c.endpoint)
2083 if err != nil {
2084 return nil, err
2085 }
2086 baseUrl.Path += fmt.Sprintf("/v1/%v:unlinkDataset", req.GetName())
2087
2088 params := url.Values{}
2089 params.Add("$alt", "json;enum-encoding=int")
2090
2091 baseUrl.RawQuery = params.Encode()
2092
2093 // Build HTTP headers from client and context metadata.
2094 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2095
2096 hds = append(c.xGoogHeaders, hds...)
2097 hds = append(hds, "Content-Type", "application/json")
2098 headers := gax.BuildHeaders(ctx, hds...)
2099 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2100 resp := &longrunningpb.Operation{}
2101 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2102 if settings.Path != "" {
2103 baseUrl.Path = settings.Path
2104 }
2105 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2106 if err != nil {
2107 return err
2108 }
2109 httpReq = httpReq.WithContext(ctx)
2110 httpReq.Header = headers
2111
2112 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UnlinkDataset")
2113 if err != nil {
2114 return err
2115 }
2116 if err := unm.Unmarshal(buf, resp); err != nil {
2117 return err
2118 }
2119
2120 return nil
2121 }, opts...)
2122 if e != nil {
2123 return nil, e
2124 }
2125
2126 override := fmt.Sprintf("/v1/%s", resp.GetName())
2127 return &UnlinkDatasetOperation{
2128 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2129 pollPath: override,
2130 }, nil
2131 }
2132
2133 // GetLocation gets information about a location.
2134 func (c *restClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2135 baseUrl, err := url.Parse(c.endpoint)
2136 if err != nil {
2137 return nil, err
2138 }
2139 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2140
2141 params := url.Values{}
2142 params.Add("$alt", "json;enum-encoding=int")
2143
2144 baseUrl.RawQuery = params.Encode()
2145
2146 // Build HTTP headers from client and context metadata.
2147 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2148
2149 hds = append(c.xGoogHeaders, hds...)
2150 hds = append(hds, "Content-Type", "application/json")
2151 headers := gax.BuildHeaders(ctx, hds...)
2152 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2153 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2154 resp := &locationpb.Location{}
2155 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2156 if settings.Path != "" {
2157 baseUrl.Path = settings.Path
2158 }
2159 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2160 if err != nil {
2161 return err
2162 }
2163 httpReq = httpReq.WithContext(ctx)
2164 httpReq.Header = headers
2165
2166 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
2167 if err != nil {
2168 return err
2169 }
2170
2171 if err := unm.Unmarshal(buf, resp); err != nil {
2172 return err
2173 }
2174
2175 return nil
2176 }, opts...)
2177 if e != nil {
2178 return nil, e
2179 }
2180 return resp, nil
2181 }
2182
2183 // ListLocations lists information about the supported locations for this service.
2184 func (c *restClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2185 it := &LocationIterator{}
2186 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2187 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2188 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2189 resp := &locationpb.ListLocationsResponse{}
2190 if pageToken != "" {
2191 req.PageToken = pageToken
2192 }
2193 if pageSize > math.MaxInt32 {
2194 req.PageSize = math.MaxInt32
2195 } else if pageSize != 0 {
2196 req.PageSize = int32(pageSize)
2197 }
2198 baseUrl, err := url.Parse(c.endpoint)
2199 if err != nil {
2200 return nil, "", err
2201 }
2202 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
2203
2204 params := url.Values{}
2205 params.Add("$alt", "json;enum-encoding=int")
2206 if req.GetFilter() != "" {
2207 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2208 }
2209 if req.GetPageSize() != 0 {
2210 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2211 }
2212 if req.GetPageToken() != "" {
2213 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2214 }
2215
2216 baseUrl.RawQuery = params.Encode()
2217
2218 // Build HTTP headers from client and context metadata.
2219 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2220 headers := gax.BuildHeaders(ctx, hds...)
2221 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2222 if settings.Path != "" {
2223 baseUrl.Path = settings.Path
2224 }
2225 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2226 if err != nil {
2227 return err
2228 }
2229 httpReq.Header = headers
2230
2231 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
2232 if err != nil {
2233 return err
2234 }
2235 if err := unm.Unmarshal(buf, resp); err != nil {
2236 return err
2237 }
2238
2239 return nil
2240 }, opts...)
2241 if e != nil {
2242 return nil, "", e
2243 }
2244 it.Response = resp
2245 return resp.GetLocations(), resp.GetNextPageToken(), nil
2246 }
2247
2248 fetch := func(pageSize int, pageToken string) (string, error) {
2249 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2250 if err != nil {
2251 return "", err
2252 }
2253 it.items = append(it.items, items...)
2254 return nextPageToken, nil
2255 }
2256
2257 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2258 it.pageInfo.MaxSize = int(req.GetPageSize())
2259 it.pageInfo.Token = req.GetPageToken()
2260
2261 return it
2262 }
2263
2264 // CancelOperation is a utility method from google.longrunning.Operations.
2265 func (c *restClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2266 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2267 jsonReq, err := m.Marshal(req)
2268 if err != nil {
2269 return err
2270 }
2271
2272 baseUrl, err := url.Parse(c.endpoint)
2273 if err != nil {
2274 return err
2275 }
2276 baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName())
2277
2278 params := url.Values{}
2279 params.Add("$alt", "json;enum-encoding=int")
2280
2281 baseUrl.RawQuery = params.Encode()
2282
2283 // Build HTTP headers from client and context metadata.
2284 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2285
2286 hds = append(c.xGoogHeaders, hds...)
2287 hds = append(hds, "Content-Type", "application/json")
2288 headers := gax.BuildHeaders(ctx, hds...)
2289 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2290 if settings.Path != "" {
2291 baseUrl.Path = settings.Path
2292 }
2293 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2294 if err != nil {
2295 return err
2296 }
2297 httpReq = httpReq.WithContext(ctx)
2298 httpReq.Header = headers
2299
2300 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
2301 return err
2302 }, opts...)
2303 }
2304
2305 // DeleteOperation is a utility method from google.longrunning.Operations.
2306 func (c *restClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
2307 baseUrl, err := url.Parse(c.endpoint)
2308 if err != nil {
2309 return err
2310 }
2311 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2312
2313 params := url.Values{}
2314 params.Add("$alt", "json;enum-encoding=int")
2315
2316 baseUrl.RawQuery = params.Encode()
2317
2318 // Build HTTP headers from client and context metadata.
2319 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2320
2321 hds = append(c.xGoogHeaders, hds...)
2322 hds = append(hds, "Content-Type", "application/json")
2323 headers := gax.BuildHeaders(ctx, hds...)
2324 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2325 if settings.Path != "" {
2326 baseUrl.Path = settings.Path
2327 }
2328 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2329 if err != nil {
2330 return err
2331 }
2332 httpReq = httpReq.WithContext(ctx)
2333 httpReq.Header = headers
2334
2335 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
2336 return err
2337 }, opts...)
2338 }
2339
2340 // GetOperation is a utility method from google.longrunning.Operations.
2341 func (c *restClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2342 baseUrl, err := url.Parse(c.endpoint)
2343 if err != nil {
2344 return nil, err
2345 }
2346 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2347
2348 params := url.Values{}
2349 params.Add("$alt", "json;enum-encoding=int")
2350
2351 baseUrl.RawQuery = params.Encode()
2352
2353 // Build HTTP headers from client and context metadata.
2354 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2355
2356 hds = append(c.xGoogHeaders, hds...)
2357 hds = append(hds, "Content-Type", "application/json")
2358 headers := gax.BuildHeaders(ctx, hds...)
2359 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2360 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2361 resp := &longrunningpb.Operation{}
2362 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2363 if settings.Path != "" {
2364 baseUrl.Path = settings.Path
2365 }
2366 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2367 if err != nil {
2368 return err
2369 }
2370 httpReq = httpReq.WithContext(ctx)
2371 httpReq.Header = headers
2372
2373 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
2374 if err != nil {
2375 return err
2376 }
2377
2378 if err := unm.Unmarshal(buf, resp); err != nil {
2379 return err
2380 }
2381
2382 return nil
2383 }, opts...)
2384 if e != nil {
2385 return nil, e
2386 }
2387 return resp, nil
2388 }
2389
2390 // ListOperations is a utility method from google.longrunning.Operations.
2391 func (c *restClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
2392 it := &OperationIterator{}
2393 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
2394 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2395 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
2396 resp := &longrunningpb.ListOperationsResponse{}
2397 if pageToken != "" {
2398 req.PageToken = pageToken
2399 }
2400 if pageSize > math.MaxInt32 {
2401 req.PageSize = math.MaxInt32
2402 } else if pageSize != 0 {
2403 req.PageSize = int32(pageSize)
2404 }
2405 baseUrl, err := url.Parse(c.endpoint)
2406 if err != nil {
2407 return nil, "", err
2408 }
2409 baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName())
2410
2411 params := url.Values{}
2412 params.Add("$alt", "json;enum-encoding=int")
2413 if req.GetFilter() != "" {
2414 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2415 }
2416 if req.GetPageSize() != 0 {
2417 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2418 }
2419 if req.GetPageToken() != "" {
2420 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2421 }
2422
2423 baseUrl.RawQuery = params.Encode()
2424
2425 // Build HTTP headers from client and context metadata.
2426 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2427 headers := gax.BuildHeaders(ctx, hds...)
2428 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2429 if settings.Path != "" {
2430 baseUrl.Path = settings.Path
2431 }
2432 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2433 if err != nil {
2434 return err
2435 }
2436 httpReq.Header = headers
2437
2438 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
2439 if err != nil {
2440 return err
2441 }
2442 if err := unm.Unmarshal(buf, resp); err != nil {
2443 return err
2444 }
2445
2446 return nil
2447 }, opts...)
2448 if e != nil {
2449 return nil, "", e
2450 }
2451 it.Response = resp
2452 return resp.GetOperations(), resp.GetNextPageToken(), nil
2453 }
2454
2455 fetch := func(pageSize int, pageToken string) (string, error) {
2456 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2457 if err != nil {
2458 return "", err
2459 }
2460 it.items = append(it.items, items...)
2461 return nextPageToken, nil
2462 }
2463
2464 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2465 it.pageInfo.MaxSize = int(req.GetPageSize())
2466 it.pageInfo.Token = req.GetPageToken()
2467
2468 return it
2469 }
2470
2471 // CreateDatasetConfigOperation returns a new CreateDatasetConfigOperation from a given name.
2472 // The name must be that of a previously created CreateDatasetConfigOperation, possibly from a different process.
2473 func (c *gRPCClient) CreateDatasetConfigOperation(name string) *CreateDatasetConfigOperation {
2474 return &CreateDatasetConfigOperation{
2475 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2476 }
2477 }
2478
2479 // CreateDatasetConfigOperation returns a new CreateDatasetConfigOperation from a given name.
2480 // The name must be that of a previously created CreateDatasetConfigOperation, possibly from a different process.
2481 func (c *restClient) CreateDatasetConfigOperation(name string) *CreateDatasetConfigOperation {
2482 override := fmt.Sprintf("/v1/%s", name)
2483 return &CreateDatasetConfigOperation{
2484 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2485 pollPath: override,
2486 }
2487 }
2488
2489 // DeleteDatasetConfigOperation returns a new DeleteDatasetConfigOperation from a given name.
2490 // The name must be that of a previously created DeleteDatasetConfigOperation, possibly from a different process.
2491 func (c *gRPCClient) DeleteDatasetConfigOperation(name string) *DeleteDatasetConfigOperation {
2492 return &DeleteDatasetConfigOperation{
2493 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2494 }
2495 }
2496
2497 // DeleteDatasetConfigOperation returns a new DeleteDatasetConfigOperation from a given name.
2498 // The name must be that of a previously created DeleteDatasetConfigOperation, possibly from a different process.
2499 func (c *restClient) DeleteDatasetConfigOperation(name string) *DeleteDatasetConfigOperation {
2500 override := fmt.Sprintf("/v1/%s", name)
2501 return &DeleteDatasetConfigOperation{
2502 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2503 pollPath: override,
2504 }
2505 }
2506
2507 // LinkDatasetOperation returns a new LinkDatasetOperation from a given name.
2508 // The name must be that of a previously created LinkDatasetOperation, possibly from a different process.
2509 func (c *gRPCClient) LinkDatasetOperation(name string) *LinkDatasetOperation {
2510 return &LinkDatasetOperation{
2511 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2512 }
2513 }
2514
2515 // LinkDatasetOperation returns a new LinkDatasetOperation from a given name.
2516 // The name must be that of a previously created LinkDatasetOperation, possibly from a different process.
2517 func (c *restClient) LinkDatasetOperation(name string) *LinkDatasetOperation {
2518 override := fmt.Sprintf("/v1/%s", name)
2519 return &LinkDatasetOperation{
2520 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2521 pollPath: override,
2522 }
2523 }
2524
2525 // UnlinkDatasetOperation returns a new UnlinkDatasetOperation from a given name.
2526 // The name must be that of a previously created UnlinkDatasetOperation, possibly from a different process.
2527 func (c *gRPCClient) UnlinkDatasetOperation(name string) *UnlinkDatasetOperation {
2528 return &UnlinkDatasetOperation{
2529 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2530 }
2531 }
2532
2533 // UnlinkDatasetOperation returns a new UnlinkDatasetOperation from a given name.
2534 // The name must be that of a previously created UnlinkDatasetOperation, possibly from a different process.
2535 func (c *restClient) UnlinkDatasetOperation(name string) *UnlinkDatasetOperation {
2536 override := fmt.Sprintf("/v1/%s", name)
2537 return &UnlinkDatasetOperation{
2538 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2539 pollPath: override,
2540 }
2541 }
2542
2543 // UpdateDatasetConfigOperation returns a new UpdateDatasetConfigOperation from a given name.
2544 // The name must be that of a previously created UpdateDatasetConfigOperation, possibly from a different process.
2545 func (c *gRPCClient) UpdateDatasetConfigOperation(name string) *UpdateDatasetConfigOperation {
2546 return &UpdateDatasetConfigOperation{
2547 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2548 }
2549 }
2550
2551 // UpdateDatasetConfigOperation returns a new UpdateDatasetConfigOperation from a given name.
2552 // The name must be that of a previously created UpdateDatasetConfigOperation, possibly from a different process.
2553 func (c *restClient) UpdateDatasetConfigOperation(name string) *UpdateDatasetConfigOperation {
2554 override := fmt.Sprintf("/v1/%s", name)
2555 return &UpdateDatasetConfigOperation{
2556 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
2557 pollPath: override,
2558 }
2559 }