1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17package dlp 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 "github.com/golang/protobuf/proto" 27 gax "github.com/googleapis/gax-go/v2" 28 "google.golang.org/api/iterator" 29 "google.golang.org/api/option" 30 "google.golang.org/api/option/internaloption" 31 gtransport "google.golang.org/api/transport/grpc" 32 dlppb "google.golang.org/genproto/googleapis/privacy/dlp/v2" 33 "google.golang.org/grpc" 34 "google.golang.org/grpc/codes" 35 "google.golang.org/grpc/metadata" 36) 37 38var newClientHook clientHook 39 40// CallOptions contains the retry settings for each method of Client. 41type CallOptions struct { 42 InspectContent []gax.CallOption 43 RedactImage []gax.CallOption 44 DeidentifyContent []gax.CallOption 45 ReidentifyContent []gax.CallOption 46 ListInfoTypes []gax.CallOption 47 CreateInspectTemplate []gax.CallOption 48 UpdateInspectTemplate []gax.CallOption 49 GetInspectTemplate []gax.CallOption 50 ListInspectTemplates []gax.CallOption 51 DeleteInspectTemplate []gax.CallOption 52 CreateDeidentifyTemplate []gax.CallOption 53 UpdateDeidentifyTemplate []gax.CallOption 54 GetDeidentifyTemplate []gax.CallOption 55 ListDeidentifyTemplates []gax.CallOption 56 DeleteDeidentifyTemplate []gax.CallOption 57 CreateJobTrigger []gax.CallOption 58 UpdateJobTrigger []gax.CallOption 59 HybridInspectJobTrigger []gax.CallOption 60 GetJobTrigger []gax.CallOption 61 ListJobTriggers []gax.CallOption 62 DeleteJobTrigger []gax.CallOption 63 ActivateJobTrigger []gax.CallOption 64 CreateDlpJob []gax.CallOption 65 ListDlpJobs []gax.CallOption 66 GetDlpJob []gax.CallOption 67 DeleteDlpJob []gax.CallOption 68 CancelDlpJob []gax.CallOption 69 CreateStoredInfoType []gax.CallOption 70 UpdateStoredInfoType []gax.CallOption 71 GetStoredInfoType []gax.CallOption 72 ListStoredInfoTypes []gax.CallOption 73 DeleteStoredInfoType []gax.CallOption 74 HybridInspectDlpJob []gax.CallOption 75 FinishDlpJob []gax.CallOption 76} 77 78func defaultClientOptions() []option.ClientOption { 79 return []option.ClientOption{ 80 internaloption.WithDefaultEndpoint("dlp.googleapis.com:443"), 81 internaloption.WithDefaultMTLSEndpoint("dlp.mtls.googleapis.com:443"), 82 internaloption.WithDefaultAudience("https://dlp.googleapis.com/"), 83 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 84 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 85 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 86 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 87 } 88} 89 90func defaultCallOptions() *CallOptions { 91 return &CallOptions{ 92 InspectContent: []gax.CallOption{ 93 gax.WithRetry(func() gax.Retryer { 94 return gax.OnCodes([]codes.Code{ 95 codes.Unavailable, 96 codes.DeadlineExceeded, 97 }, gax.Backoff{ 98 Initial: 100 * time.Millisecond, 99 Max: 60000 * time.Millisecond, 100 Multiplier: 1.30, 101 }) 102 }), 103 }, 104 RedactImage: []gax.CallOption{ 105 gax.WithRetry(func() gax.Retryer { 106 return gax.OnCodes([]codes.Code{ 107 codes.Unavailable, 108 codes.DeadlineExceeded, 109 }, gax.Backoff{ 110 Initial: 100 * time.Millisecond, 111 Max: 60000 * time.Millisecond, 112 Multiplier: 1.30, 113 }) 114 }), 115 }, 116 DeidentifyContent: []gax.CallOption{ 117 gax.WithRetry(func() gax.Retryer { 118 return gax.OnCodes([]codes.Code{ 119 codes.Unavailable, 120 codes.DeadlineExceeded, 121 }, gax.Backoff{ 122 Initial: 100 * time.Millisecond, 123 Max: 60000 * time.Millisecond, 124 Multiplier: 1.30, 125 }) 126 }), 127 }, 128 ReidentifyContent: []gax.CallOption{ 129 gax.WithRetry(func() gax.Retryer { 130 return gax.OnCodes([]codes.Code{ 131 codes.Unavailable, 132 codes.DeadlineExceeded, 133 }, gax.Backoff{ 134 Initial: 100 * time.Millisecond, 135 Max: 60000 * time.Millisecond, 136 Multiplier: 1.30, 137 }) 138 }), 139 }, 140 ListInfoTypes: []gax.CallOption{ 141 gax.WithRetry(func() gax.Retryer { 142 return gax.OnCodes([]codes.Code{ 143 codes.Unavailable, 144 codes.DeadlineExceeded, 145 }, gax.Backoff{ 146 Initial: 100 * time.Millisecond, 147 Max: 60000 * time.Millisecond, 148 Multiplier: 1.30, 149 }) 150 }), 151 }, 152 CreateInspectTemplate: []gax.CallOption{}, 153 UpdateInspectTemplate: []gax.CallOption{}, 154 GetInspectTemplate: []gax.CallOption{ 155 gax.WithRetry(func() gax.Retryer { 156 return gax.OnCodes([]codes.Code{ 157 codes.Unavailable, 158 codes.DeadlineExceeded, 159 }, gax.Backoff{ 160 Initial: 100 * time.Millisecond, 161 Max: 60000 * time.Millisecond, 162 Multiplier: 1.30, 163 }) 164 }), 165 }, 166 ListInspectTemplates: []gax.CallOption{ 167 gax.WithRetry(func() gax.Retryer { 168 return gax.OnCodes([]codes.Code{ 169 codes.Unavailable, 170 codes.DeadlineExceeded, 171 }, gax.Backoff{ 172 Initial: 100 * time.Millisecond, 173 Max: 60000 * time.Millisecond, 174 Multiplier: 1.30, 175 }) 176 }), 177 }, 178 DeleteInspectTemplate: []gax.CallOption{ 179 gax.WithRetry(func() gax.Retryer { 180 return gax.OnCodes([]codes.Code{ 181 codes.Unavailable, 182 codes.DeadlineExceeded, 183 }, gax.Backoff{ 184 Initial: 100 * time.Millisecond, 185 Max: 60000 * time.Millisecond, 186 Multiplier: 1.30, 187 }) 188 }), 189 }, 190 CreateDeidentifyTemplate: []gax.CallOption{}, 191 UpdateDeidentifyTemplate: []gax.CallOption{}, 192 GetDeidentifyTemplate: []gax.CallOption{ 193 gax.WithRetry(func() gax.Retryer { 194 return gax.OnCodes([]codes.Code{ 195 codes.Unavailable, 196 codes.DeadlineExceeded, 197 }, gax.Backoff{ 198 Initial: 100 * time.Millisecond, 199 Max: 60000 * time.Millisecond, 200 Multiplier: 1.30, 201 }) 202 }), 203 }, 204 ListDeidentifyTemplates: []gax.CallOption{ 205 gax.WithRetry(func() gax.Retryer { 206 return gax.OnCodes([]codes.Code{ 207 codes.Unavailable, 208 codes.DeadlineExceeded, 209 }, gax.Backoff{ 210 Initial: 100 * time.Millisecond, 211 Max: 60000 * time.Millisecond, 212 Multiplier: 1.30, 213 }) 214 }), 215 }, 216 DeleteDeidentifyTemplate: []gax.CallOption{ 217 gax.WithRetry(func() gax.Retryer { 218 return gax.OnCodes([]codes.Code{ 219 codes.Unavailable, 220 codes.DeadlineExceeded, 221 }, gax.Backoff{ 222 Initial: 100 * time.Millisecond, 223 Max: 60000 * time.Millisecond, 224 Multiplier: 1.30, 225 }) 226 }), 227 }, 228 CreateJobTrigger: []gax.CallOption{}, 229 UpdateJobTrigger: []gax.CallOption{}, 230 HybridInspectJobTrigger: []gax.CallOption{}, 231 GetJobTrigger: []gax.CallOption{ 232 gax.WithRetry(func() gax.Retryer { 233 return gax.OnCodes([]codes.Code{ 234 codes.Unavailable, 235 codes.DeadlineExceeded, 236 }, gax.Backoff{ 237 Initial: 100 * time.Millisecond, 238 Max: 60000 * time.Millisecond, 239 Multiplier: 1.30, 240 }) 241 }), 242 }, 243 ListJobTriggers: []gax.CallOption{ 244 gax.WithRetry(func() gax.Retryer { 245 return gax.OnCodes([]codes.Code{ 246 codes.Unavailable, 247 codes.DeadlineExceeded, 248 }, gax.Backoff{ 249 Initial: 100 * time.Millisecond, 250 Max: 60000 * time.Millisecond, 251 Multiplier: 1.30, 252 }) 253 }), 254 }, 255 DeleteJobTrigger: []gax.CallOption{ 256 gax.WithRetry(func() gax.Retryer { 257 return gax.OnCodes([]codes.Code{ 258 codes.Unavailable, 259 codes.DeadlineExceeded, 260 }, gax.Backoff{ 261 Initial: 100 * time.Millisecond, 262 Max: 60000 * time.Millisecond, 263 Multiplier: 1.30, 264 }) 265 }), 266 }, 267 ActivateJobTrigger: []gax.CallOption{}, 268 CreateDlpJob: []gax.CallOption{}, 269 ListDlpJobs: []gax.CallOption{ 270 gax.WithRetry(func() gax.Retryer { 271 return gax.OnCodes([]codes.Code{ 272 codes.Unavailable, 273 codes.DeadlineExceeded, 274 }, gax.Backoff{ 275 Initial: 100 * time.Millisecond, 276 Max: 60000 * time.Millisecond, 277 Multiplier: 1.30, 278 }) 279 }), 280 }, 281 GetDlpJob: []gax.CallOption{ 282 gax.WithRetry(func() gax.Retryer { 283 return gax.OnCodes([]codes.Code{ 284 codes.Unavailable, 285 codes.DeadlineExceeded, 286 }, gax.Backoff{ 287 Initial: 100 * time.Millisecond, 288 Max: 60000 * time.Millisecond, 289 Multiplier: 1.30, 290 }) 291 }), 292 }, 293 DeleteDlpJob: []gax.CallOption{ 294 gax.WithRetry(func() gax.Retryer { 295 return gax.OnCodes([]codes.Code{ 296 codes.Unavailable, 297 codes.DeadlineExceeded, 298 }, gax.Backoff{ 299 Initial: 100 * time.Millisecond, 300 Max: 60000 * time.Millisecond, 301 Multiplier: 1.30, 302 }) 303 }), 304 }, 305 CancelDlpJob: []gax.CallOption{}, 306 CreateStoredInfoType: []gax.CallOption{}, 307 UpdateStoredInfoType: []gax.CallOption{}, 308 GetStoredInfoType: []gax.CallOption{ 309 gax.WithRetry(func() gax.Retryer { 310 return gax.OnCodes([]codes.Code{ 311 codes.Unavailable, 312 codes.DeadlineExceeded, 313 }, gax.Backoff{ 314 Initial: 100 * time.Millisecond, 315 Max: 60000 * time.Millisecond, 316 Multiplier: 1.30, 317 }) 318 }), 319 }, 320 ListStoredInfoTypes: []gax.CallOption{ 321 gax.WithRetry(func() gax.Retryer { 322 return gax.OnCodes([]codes.Code{ 323 codes.Unavailable, 324 codes.DeadlineExceeded, 325 }, gax.Backoff{ 326 Initial: 100 * time.Millisecond, 327 Max: 60000 * time.Millisecond, 328 Multiplier: 1.30, 329 }) 330 }), 331 }, 332 DeleteStoredInfoType: []gax.CallOption{ 333 gax.WithRetry(func() gax.Retryer { 334 return gax.OnCodes([]codes.Code{ 335 codes.Unavailable, 336 codes.DeadlineExceeded, 337 }, gax.Backoff{ 338 Initial: 100 * time.Millisecond, 339 Max: 60000 * time.Millisecond, 340 Multiplier: 1.30, 341 }) 342 }), 343 }, 344 HybridInspectDlpJob: []gax.CallOption{}, 345 FinishDlpJob: []gax.CallOption{}, 346 } 347} 348 349// Client is a client for interacting with Cloud Data Loss Prevention (DLP) API. 350// 351// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 352type Client struct { 353 // Connection pool of gRPC connections to the service. 354 connPool gtransport.ConnPool 355 356 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 357 disableDeadlines bool 358 359 // The gRPC API client. 360 client dlppb.DlpServiceClient 361 362 // The call options for this service. 363 CallOptions *CallOptions 364 365 // The x-goog-* metadata to be sent with each request. 366 xGoogMetadata metadata.MD 367} 368 369// NewClient creates a new dlp service client. 370// 371// The Cloud Data Loss Prevention (DLP) API is a service that allows clients 372// to detect the presence of Personally Identifiable Information (PII) and other 373// privacy-sensitive data in user-supplied, unstructured data streams, like text 374// blocks or images. 375// The service also includes methods for sensitive data redaction and 376// scheduling of data scans on Google Cloud Platform based data sets. 377// 378// To learn more about concepts and find how-to guides see 379// https://cloud.google.com/dlp/docs/ (at https://cloud.google.com/dlp/docs/). 380func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { 381 clientOpts := defaultClientOptions() 382 383 if newClientHook != nil { 384 hookOpts, err := newClientHook(ctx, clientHookParams{}) 385 if err != nil { 386 return nil, err 387 } 388 clientOpts = append(clientOpts, hookOpts...) 389 } 390 391 disableDeadlines, err := checkDisableDeadlines() 392 if err != nil { 393 return nil, err 394 } 395 396 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 397 if err != nil { 398 return nil, err 399 } 400 c := &Client{ 401 connPool: connPool, 402 disableDeadlines: disableDeadlines, 403 CallOptions: defaultCallOptions(), 404 405 client: dlppb.NewDlpServiceClient(connPool), 406 } 407 c.setGoogleClientInfo() 408 409 return c, nil 410} 411 412// Connection returns a connection to the API service. 413// 414// Deprecated. 415func (c *Client) Connection() *grpc.ClientConn { 416 return c.connPool.Conn() 417} 418 419// Close closes the connection to the API service. The user should invoke this when 420// the client is no longer required. 421func (c *Client) Close() error { 422 return c.connPool.Close() 423} 424 425// setGoogleClientInfo sets the name and version of the application in 426// the `x-goog-api-client` header passed on each request. Intended for 427// use by Google-written clients. 428func (c *Client) setGoogleClientInfo(keyval ...string) { 429 kv := append([]string{"gl-go", versionGo()}, keyval...) 430 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 431 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 432} 433 434// InspectContent finds potentially sensitive info in content. 435// This method has limits on input size, processing time, and output size. 436// 437// When no InfoTypes or CustomInfoTypes are specified in this request, the 438// system will automatically choose what detectors to run. By default this may 439// be all types, but may change over time as detectors are updated. 440// 441// For how to guides, see https://cloud.google.com/dlp/docs/inspecting-images (at https://cloud.google.com/dlp/docs/inspecting-images) 442// and https://cloud.google.com/dlp/docs/inspecting-text (at https://cloud.google.com/dlp/docs/inspecting-text), 443func (c *Client) InspectContent(ctx context.Context, req *dlppb.InspectContentRequest, opts ...gax.CallOption) (*dlppb.InspectContentResponse, error) { 444 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 445 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 446 defer cancel() 447 ctx = cctx 448 } 449 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 450 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 451 opts = append(c.CallOptions.InspectContent[0:len(c.CallOptions.InspectContent):len(c.CallOptions.InspectContent)], opts...) 452 var resp *dlppb.InspectContentResponse 453 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 454 var err error 455 resp, err = c.client.InspectContent(ctx, req, settings.GRPC...) 456 return err 457 }, opts...) 458 if err != nil { 459 return nil, err 460 } 461 return resp, nil 462} 463 464// RedactImage redacts potentially sensitive info from an image. 465// This method has limits on input size, processing time, and output size. 466// See https://cloud.google.com/dlp/docs/redacting-sensitive-data-images (at https://cloud.google.com/dlp/docs/redacting-sensitive-data-images) to 467// learn more. 468// 469// When no InfoTypes or CustomInfoTypes are specified in this request, the 470// system will automatically choose what detectors to run. By default this may 471// be all types, but may change over time as detectors are updated. 472func (c *Client) RedactImage(ctx context.Context, req *dlppb.RedactImageRequest, opts ...gax.CallOption) (*dlppb.RedactImageResponse, error) { 473 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 474 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 475 defer cancel() 476 ctx = cctx 477 } 478 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 479 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 480 opts = append(c.CallOptions.RedactImage[0:len(c.CallOptions.RedactImage):len(c.CallOptions.RedactImage)], opts...) 481 var resp *dlppb.RedactImageResponse 482 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 483 var err error 484 resp, err = c.client.RedactImage(ctx, req, settings.GRPC...) 485 return err 486 }, opts...) 487 if err != nil { 488 return nil, err 489 } 490 return resp, nil 491} 492 493// DeidentifyContent de-identifies potentially sensitive info from a ContentItem. 494// This method has limits on input size and output size. 495// See https://cloud.google.com/dlp/docs/deidentify-sensitive-data (at https://cloud.google.com/dlp/docs/deidentify-sensitive-data) to 496// learn more. 497// 498// When no InfoTypes or CustomInfoTypes are specified in this request, the 499// system will automatically choose what detectors to run. By default this may 500// be all types, but may change over time as detectors are updated. 501func (c *Client) DeidentifyContent(ctx context.Context, req *dlppb.DeidentifyContentRequest, opts ...gax.CallOption) (*dlppb.DeidentifyContentResponse, error) { 502 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 503 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 504 defer cancel() 505 ctx = cctx 506 } 507 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 508 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 509 opts = append(c.CallOptions.DeidentifyContent[0:len(c.CallOptions.DeidentifyContent):len(c.CallOptions.DeidentifyContent)], opts...) 510 var resp *dlppb.DeidentifyContentResponse 511 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 512 var err error 513 resp, err = c.client.DeidentifyContent(ctx, req, settings.GRPC...) 514 return err 515 }, opts...) 516 if err != nil { 517 return nil, err 518 } 519 return resp, nil 520} 521 522// ReidentifyContent re-identifies content that has been de-identified. 523// See 524// https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example (at https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example) 525// to learn more. 526func (c *Client) ReidentifyContent(ctx context.Context, req *dlppb.ReidentifyContentRequest, opts ...gax.CallOption) (*dlppb.ReidentifyContentResponse, error) { 527 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 528 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 529 defer cancel() 530 ctx = cctx 531 } 532 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 533 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 534 opts = append(c.CallOptions.ReidentifyContent[0:len(c.CallOptions.ReidentifyContent):len(c.CallOptions.ReidentifyContent)], opts...) 535 var resp *dlppb.ReidentifyContentResponse 536 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 537 var err error 538 resp, err = c.client.ReidentifyContent(ctx, req, settings.GRPC...) 539 return err 540 }, opts...) 541 if err != nil { 542 return nil, err 543 } 544 return resp, nil 545} 546 547// ListInfoTypes returns a list of the sensitive information types that the DLP API 548// supports. See https://cloud.google.com/dlp/docs/infotypes-reference (at https://cloud.google.com/dlp/docs/infotypes-reference) to 549// learn more. 550func (c *Client) ListInfoTypes(ctx context.Context, req *dlppb.ListInfoTypesRequest, opts ...gax.CallOption) (*dlppb.ListInfoTypesResponse, error) { 551 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 552 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 553 defer cancel() 554 ctx = cctx 555 } 556 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 557 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 558 opts = append(c.CallOptions.ListInfoTypes[0:len(c.CallOptions.ListInfoTypes):len(c.CallOptions.ListInfoTypes)], opts...) 559 var resp *dlppb.ListInfoTypesResponse 560 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 561 var err error 562 resp, err = c.client.ListInfoTypes(ctx, req, settings.GRPC...) 563 return err 564 }, opts...) 565 if err != nil { 566 return nil, err 567 } 568 return resp, nil 569} 570 571// CreateInspectTemplate creates an InspectTemplate for re-using frequently used configuration 572// for inspecting content, images, and storage. 573// See https://cloud.google.com/dlp/docs/creating-templates (at https://cloud.google.com/dlp/docs/creating-templates) to learn more. 574func (c *Client) CreateInspectTemplate(ctx context.Context, req *dlppb.CreateInspectTemplateRequest, opts ...gax.CallOption) (*dlppb.InspectTemplate, error) { 575 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 576 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 577 defer cancel() 578 ctx = cctx 579 } 580 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 581 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 582 opts = append(c.CallOptions.CreateInspectTemplate[0:len(c.CallOptions.CreateInspectTemplate):len(c.CallOptions.CreateInspectTemplate)], opts...) 583 var resp *dlppb.InspectTemplate 584 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 585 var err error 586 resp, err = c.client.CreateInspectTemplate(ctx, req, settings.GRPC...) 587 return err 588 }, opts...) 589 if err != nil { 590 return nil, err 591 } 592 return resp, nil 593} 594 595// UpdateInspectTemplate updates the InspectTemplate. 596// See https://cloud.google.com/dlp/docs/creating-templates (at https://cloud.google.com/dlp/docs/creating-templates) to learn more. 597func (c *Client) UpdateInspectTemplate(ctx context.Context, req *dlppb.UpdateInspectTemplateRequest, opts ...gax.CallOption) (*dlppb.InspectTemplate, error) { 598 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 599 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 600 defer cancel() 601 ctx = cctx 602 } 603 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 604 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 605 opts = append(c.CallOptions.UpdateInspectTemplate[0:len(c.CallOptions.UpdateInspectTemplate):len(c.CallOptions.UpdateInspectTemplate)], opts...) 606 var resp *dlppb.InspectTemplate 607 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 608 var err error 609 resp, err = c.client.UpdateInspectTemplate(ctx, req, settings.GRPC...) 610 return err 611 }, opts...) 612 if err != nil { 613 return nil, err 614 } 615 return resp, nil 616} 617 618// GetInspectTemplate gets an InspectTemplate. 619// See https://cloud.google.com/dlp/docs/creating-templates (at https://cloud.google.com/dlp/docs/creating-templates) to learn more. 620func (c *Client) GetInspectTemplate(ctx context.Context, req *dlppb.GetInspectTemplateRequest, opts ...gax.CallOption) (*dlppb.InspectTemplate, error) { 621 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 622 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 623 defer cancel() 624 ctx = cctx 625 } 626 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 627 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 628 opts = append(c.CallOptions.GetInspectTemplate[0:len(c.CallOptions.GetInspectTemplate):len(c.CallOptions.GetInspectTemplate)], opts...) 629 var resp *dlppb.InspectTemplate 630 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 631 var err error 632 resp, err = c.client.GetInspectTemplate(ctx, req, settings.GRPC...) 633 return err 634 }, opts...) 635 if err != nil { 636 return nil, err 637 } 638 return resp, nil 639} 640 641// ListInspectTemplates lists InspectTemplates. 642// See https://cloud.google.com/dlp/docs/creating-templates (at https://cloud.google.com/dlp/docs/creating-templates) to learn more. 643func (c *Client) ListInspectTemplates(ctx context.Context, req *dlppb.ListInspectTemplatesRequest, opts ...gax.CallOption) *InspectTemplateIterator { 644 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 645 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 646 opts = append(c.CallOptions.ListInspectTemplates[0:len(c.CallOptions.ListInspectTemplates):len(c.CallOptions.ListInspectTemplates)], opts...) 647 it := &InspectTemplateIterator{} 648 req = proto.Clone(req).(*dlppb.ListInspectTemplatesRequest) 649 it.InternalFetch = func(pageSize int, pageToken string) ([]*dlppb.InspectTemplate, string, error) { 650 var resp *dlppb.ListInspectTemplatesResponse 651 req.PageToken = pageToken 652 if pageSize > math.MaxInt32 { 653 req.PageSize = math.MaxInt32 654 } else { 655 req.PageSize = int32(pageSize) 656 } 657 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 658 var err error 659 resp, err = c.client.ListInspectTemplates(ctx, req, settings.GRPC...) 660 return err 661 }, opts...) 662 if err != nil { 663 return nil, "", err 664 } 665 666 it.Response = resp 667 return resp.GetInspectTemplates(), resp.GetNextPageToken(), nil 668 } 669 fetch := func(pageSize int, pageToken string) (string, error) { 670 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 671 if err != nil { 672 return "", err 673 } 674 it.items = append(it.items, items...) 675 return nextPageToken, nil 676 } 677 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 678 it.pageInfo.MaxSize = int(req.GetPageSize()) 679 it.pageInfo.Token = req.GetPageToken() 680 return it 681} 682 683// DeleteInspectTemplate deletes an InspectTemplate. 684// See https://cloud.google.com/dlp/docs/creating-templates (at https://cloud.google.com/dlp/docs/creating-templates) to learn more. 685func (c *Client) DeleteInspectTemplate(ctx context.Context, req *dlppb.DeleteInspectTemplateRequest, opts ...gax.CallOption) error { 686 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 687 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 688 defer cancel() 689 ctx = cctx 690 } 691 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 692 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 693 opts = append(c.CallOptions.DeleteInspectTemplate[0:len(c.CallOptions.DeleteInspectTemplate):len(c.CallOptions.DeleteInspectTemplate)], opts...) 694 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 695 var err error 696 _, err = c.client.DeleteInspectTemplate(ctx, req, settings.GRPC...) 697 return err 698 }, opts...) 699 return err 700} 701 702// CreateDeidentifyTemplate creates a DeidentifyTemplate for re-using frequently used configuration 703// for de-identifying content, images, and storage. 704// See https://cloud.google.com/dlp/docs/creating-templates-deid (at https://cloud.google.com/dlp/docs/creating-templates-deid) to learn 705// more. 706func (c *Client) CreateDeidentifyTemplate(ctx context.Context, req *dlppb.CreateDeidentifyTemplateRequest, opts ...gax.CallOption) (*dlppb.DeidentifyTemplate, error) { 707 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 708 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 709 defer cancel() 710 ctx = cctx 711 } 712 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 713 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 714 opts = append(c.CallOptions.CreateDeidentifyTemplate[0:len(c.CallOptions.CreateDeidentifyTemplate):len(c.CallOptions.CreateDeidentifyTemplate)], opts...) 715 var resp *dlppb.DeidentifyTemplate 716 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 717 var err error 718 resp, err = c.client.CreateDeidentifyTemplate(ctx, req, settings.GRPC...) 719 return err 720 }, opts...) 721 if err != nil { 722 return nil, err 723 } 724 return resp, nil 725} 726 727// UpdateDeidentifyTemplate updates the DeidentifyTemplate. 728// See https://cloud.google.com/dlp/docs/creating-templates-deid (at https://cloud.google.com/dlp/docs/creating-templates-deid) to learn 729// more. 730func (c *Client) UpdateDeidentifyTemplate(ctx context.Context, req *dlppb.UpdateDeidentifyTemplateRequest, opts ...gax.CallOption) (*dlppb.DeidentifyTemplate, error) { 731 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 732 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 733 defer cancel() 734 ctx = cctx 735 } 736 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 737 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 738 opts = append(c.CallOptions.UpdateDeidentifyTemplate[0:len(c.CallOptions.UpdateDeidentifyTemplate):len(c.CallOptions.UpdateDeidentifyTemplate)], opts...) 739 var resp *dlppb.DeidentifyTemplate 740 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 741 var err error 742 resp, err = c.client.UpdateDeidentifyTemplate(ctx, req, settings.GRPC...) 743 return err 744 }, opts...) 745 if err != nil { 746 return nil, err 747 } 748 return resp, nil 749} 750 751// GetDeidentifyTemplate gets a DeidentifyTemplate. 752// See https://cloud.google.com/dlp/docs/creating-templates-deid (at https://cloud.google.com/dlp/docs/creating-templates-deid) to learn 753// more. 754func (c *Client) GetDeidentifyTemplate(ctx context.Context, req *dlppb.GetDeidentifyTemplateRequest, opts ...gax.CallOption) (*dlppb.DeidentifyTemplate, error) { 755 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 756 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 757 defer cancel() 758 ctx = cctx 759 } 760 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 761 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 762 opts = append(c.CallOptions.GetDeidentifyTemplate[0:len(c.CallOptions.GetDeidentifyTemplate):len(c.CallOptions.GetDeidentifyTemplate)], opts...) 763 var resp *dlppb.DeidentifyTemplate 764 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 765 var err error 766 resp, err = c.client.GetDeidentifyTemplate(ctx, req, settings.GRPC...) 767 return err 768 }, opts...) 769 if err != nil { 770 return nil, err 771 } 772 return resp, nil 773} 774 775// ListDeidentifyTemplates lists DeidentifyTemplates. 776// See https://cloud.google.com/dlp/docs/creating-templates-deid (at https://cloud.google.com/dlp/docs/creating-templates-deid) to learn 777// more. 778func (c *Client) ListDeidentifyTemplates(ctx context.Context, req *dlppb.ListDeidentifyTemplatesRequest, opts ...gax.CallOption) *DeidentifyTemplateIterator { 779 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 780 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 781 opts = append(c.CallOptions.ListDeidentifyTemplates[0:len(c.CallOptions.ListDeidentifyTemplates):len(c.CallOptions.ListDeidentifyTemplates)], opts...) 782 it := &DeidentifyTemplateIterator{} 783 req = proto.Clone(req).(*dlppb.ListDeidentifyTemplatesRequest) 784 it.InternalFetch = func(pageSize int, pageToken string) ([]*dlppb.DeidentifyTemplate, string, error) { 785 var resp *dlppb.ListDeidentifyTemplatesResponse 786 req.PageToken = pageToken 787 if pageSize > math.MaxInt32 { 788 req.PageSize = math.MaxInt32 789 } else { 790 req.PageSize = int32(pageSize) 791 } 792 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 793 var err error 794 resp, err = c.client.ListDeidentifyTemplates(ctx, req, settings.GRPC...) 795 return err 796 }, opts...) 797 if err != nil { 798 return nil, "", err 799 } 800 801 it.Response = resp 802 return resp.GetDeidentifyTemplates(), resp.GetNextPageToken(), nil 803 } 804 fetch := func(pageSize int, pageToken string) (string, error) { 805 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 806 if err != nil { 807 return "", err 808 } 809 it.items = append(it.items, items...) 810 return nextPageToken, nil 811 } 812 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 813 it.pageInfo.MaxSize = int(req.GetPageSize()) 814 it.pageInfo.Token = req.GetPageToken() 815 return it 816} 817 818// DeleteDeidentifyTemplate deletes a DeidentifyTemplate. 819// See https://cloud.google.com/dlp/docs/creating-templates-deid (at https://cloud.google.com/dlp/docs/creating-templates-deid) to learn 820// more. 821func (c *Client) DeleteDeidentifyTemplate(ctx context.Context, req *dlppb.DeleteDeidentifyTemplateRequest, opts ...gax.CallOption) error { 822 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 823 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 824 defer cancel() 825 ctx = cctx 826 } 827 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 828 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 829 opts = append(c.CallOptions.DeleteDeidentifyTemplate[0:len(c.CallOptions.DeleteDeidentifyTemplate):len(c.CallOptions.DeleteDeidentifyTemplate)], opts...) 830 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 831 var err error 832 _, err = c.client.DeleteDeidentifyTemplate(ctx, req, settings.GRPC...) 833 return err 834 }, opts...) 835 return err 836} 837 838// CreateJobTrigger creates a job trigger to run DLP actions such as scanning storage for 839// sensitive information on a set schedule. 840// See https://cloud.google.com/dlp/docs/creating-job-triggers (at https://cloud.google.com/dlp/docs/creating-job-triggers) to learn more. 841func (c *Client) CreateJobTrigger(ctx context.Context, req *dlppb.CreateJobTriggerRequest, opts ...gax.CallOption) (*dlppb.JobTrigger, error) { 842 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 843 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 844 defer cancel() 845 ctx = cctx 846 } 847 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 848 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 849 opts = append(c.CallOptions.CreateJobTrigger[0:len(c.CallOptions.CreateJobTrigger):len(c.CallOptions.CreateJobTrigger)], opts...) 850 var resp *dlppb.JobTrigger 851 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 852 var err error 853 resp, err = c.client.CreateJobTrigger(ctx, req, settings.GRPC...) 854 return err 855 }, opts...) 856 if err != nil { 857 return nil, err 858 } 859 return resp, nil 860} 861 862// UpdateJobTrigger updates a job trigger. 863// See https://cloud.google.com/dlp/docs/creating-job-triggers (at https://cloud.google.com/dlp/docs/creating-job-triggers) to learn more. 864func (c *Client) UpdateJobTrigger(ctx context.Context, req *dlppb.UpdateJobTriggerRequest, opts ...gax.CallOption) (*dlppb.JobTrigger, error) { 865 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 866 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 867 defer cancel() 868 ctx = cctx 869 } 870 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 871 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 872 opts = append(c.CallOptions.UpdateJobTrigger[0:len(c.CallOptions.UpdateJobTrigger):len(c.CallOptions.UpdateJobTrigger)], opts...) 873 var resp *dlppb.JobTrigger 874 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 875 var err error 876 resp, err = c.client.UpdateJobTrigger(ctx, req, settings.GRPC...) 877 return err 878 }, opts...) 879 if err != nil { 880 return nil, err 881 } 882 return resp, nil 883} 884 885// HybridInspectJobTrigger inspect hybrid content and store findings to a trigger. The inspection 886// will be processed asynchronously. To review the findings monitor the 887// jobs within the trigger. 888// Early access feature is in a pre-release state and might change or have 889// limited support. For more information, see 890// https://cloud.google.com/products#product-launch-stages (at https://cloud.google.com/products#product-launch-stages). 891func (c *Client) HybridInspectJobTrigger(ctx context.Context, req *dlppb.HybridInspectJobTriggerRequest, opts ...gax.CallOption) (*dlppb.HybridInspectResponse, error) { 892 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 893 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 894 defer cancel() 895 ctx = cctx 896 } 897 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 898 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 899 opts = append(c.CallOptions.HybridInspectJobTrigger[0:len(c.CallOptions.HybridInspectJobTrigger):len(c.CallOptions.HybridInspectJobTrigger)], opts...) 900 var resp *dlppb.HybridInspectResponse 901 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 902 var err error 903 resp, err = c.client.HybridInspectJobTrigger(ctx, req, settings.GRPC...) 904 return err 905 }, opts...) 906 if err != nil { 907 return nil, err 908 } 909 return resp, nil 910} 911 912// GetJobTrigger gets a job trigger. 913// See https://cloud.google.com/dlp/docs/creating-job-triggers (at https://cloud.google.com/dlp/docs/creating-job-triggers) to learn more. 914func (c *Client) GetJobTrigger(ctx context.Context, req *dlppb.GetJobTriggerRequest, opts ...gax.CallOption) (*dlppb.JobTrigger, error) { 915 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 916 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 917 defer cancel() 918 ctx = cctx 919 } 920 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 921 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 922 opts = append(c.CallOptions.GetJobTrigger[0:len(c.CallOptions.GetJobTrigger):len(c.CallOptions.GetJobTrigger)], opts...) 923 var resp *dlppb.JobTrigger 924 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 925 var err error 926 resp, err = c.client.GetJobTrigger(ctx, req, settings.GRPC...) 927 return err 928 }, opts...) 929 if err != nil { 930 return nil, err 931 } 932 return resp, nil 933} 934 935// ListJobTriggers lists job triggers. 936// See https://cloud.google.com/dlp/docs/creating-job-triggers (at https://cloud.google.com/dlp/docs/creating-job-triggers) to learn more. 937func (c *Client) ListJobTriggers(ctx context.Context, req *dlppb.ListJobTriggersRequest, opts ...gax.CallOption) *JobTriggerIterator { 938 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 939 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 940 opts = append(c.CallOptions.ListJobTriggers[0:len(c.CallOptions.ListJobTriggers):len(c.CallOptions.ListJobTriggers)], opts...) 941 it := &JobTriggerIterator{} 942 req = proto.Clone(req).(*dlppb.ListJobTriggersRequest) 943 it.InternalFetch = func(pageSize int, pageToken string) ([]*dlppb.JobTrigger, string, error) { 944 var resp *dlppb.ListJobTriggersResponse 945 req.PageToken = pageToken 946 if pageSize > math.MaxInt32 { 947 req.PageSize = math.MaxInt32 948 } else { 949 req.PageSize = int32(pageSize) 950 } 951 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 952 var err error 953 resp, err = c.client.ListJobTriggers(ctx, req, settings.GRPC...) 954 return err 955 }, opts...) 956 if err != nil { 957 return nil, "", err 958 } 959 960 it.Response = resp 961 return resp.GetJobTriggers(), resp.GetNextPageToken(), nil 962 } 963 fetch := func(pageSize int, pageToken string) (string, error) { 964 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 965 if err != nil { 966 return "", err 967 } 968 it.items = append(it.items, items...) 969 return nextPageToken, nil 970 } 971 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 972 it.pageInfo.MaxSize = int(req.GetPageSize()) 973 it.pageInfo.Token = req.GetPageToken() 974 return it 975} 976 977// DeleteJobTrigger deletes a job trigger. 978// See https://cloud.google.com/dlp/docs/creating-job-triggers (at https://cloud.google.com/dlp/docs/creating-job-triggers) to learn more. 979func (c *Client) DeleteJobTrigger(ctx context.Context, req *dlppb.DeleteJobTriggerRequest, opts ...gax.CallOption) error { 980 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 981 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 982 defer cancel() 983 ctx = cctx 984 } 985 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 986 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 987 opts = append(c.CallOptions.DeleteJobTrigger[0:len(c.CallOptions.DeleteJobTrigger):len(c.CallOptions.DeleteJobTrigger)], opts...) 988 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 989 var err error 990 _, err = c.client.DeleteJobTrigger(ctx, req, settings.GRPC...) 991 return err 992 }, opts...) 993 return err 994} 995 996// ActivateJobTrigger activate a job trigger. Causes the immediate execute of a trigger 997// instead of waiting on the trigger event to occur. 998func (c *Client) ActivateJobTrigger(ctx context.Context, req *dlppb.ActivateJobTriggerRequest, opts ...gax.CallOption) (*dlppb.DlpJob, error) { 999 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1000 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1001 defer cancel() 1002 ctx = cctx 1003 } 1004 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1005 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1006 opts = append(c.CallOptions.ActivateJobTrigger[0:len(c.CallOptions.ActivateJobTrigger):len(c.CallOptions.ActivateJobTrigger)], opts...) 1007 var resp *dlppb.DlpJob 1008 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1009 var err error 1010 resp, err = c.client.ActivateJobTrigger(ctx, req, settings.GRPC...) 1011 return err 1012 }, opts...) 1013 if err != nil { 1014 return nil, err 1015 } 1016 return resp, nil 1017} 1018 1019// CreateDlpJob creates a new job to inspect storage or calculate risk metrics. 1020// See https://cloud.google.com/dlp/docs/inspecting-storage (at https://cloud.google.com/dlp/docs/inspecting-storage) and 1021// https://cloud.google.com/dlp/docs/compute-risk-analysis (at https://cloud.google.com/dlp/docs/compute-risk-analysis) to learn more. 1022// 1023// When no InfoTypes or CustomInfoTypes are specified in inspect jobs, the 1024// system will automatically choose what detectors to run. By default this may 1025// be all types, but may change over time as detectors are updated. 1026func (c *Client) CreateDlpJob(ctx context.Context, req *dlppb.CreateDlpJobRequest, opts ...gax.CallOption) (*dlppb.DlpJob, error) { 1027 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1028 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1029 defer cancel() 1030 ctx = cctx 1031 } 1032 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1033 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1034 opts = append(c.CallOptions.CreateDlpJob[0:len(c.CallOptions.CreateDlpJob):len(c.CallOptions.CreateDlpJob)], opts...) 1035 var resp *dlppb.DlpJob 1036 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1037 var err error 1038 resp, err = c.client.CreateDlpJob(ctx, req, settings.GRPC...) 1039 return err 1040 }, opts...) 1041 if err != nil { 1042 return nil, err 1043 } 1044 return resp, nil 1045} 1046 1047// ListDlpJobs lists DlpJobs that match the specified filter in the request. 1048// See https://cloud.google.com/dlp/docs/inspecting-storage (at https://cloud.google.com/dlp/docs/inspecting-storage) and 1049// https://cloud.google.com/dlp/docs/compute-risk-analysis (at https://cloud.google.com/dlp/docs/compute-risk-analysis) to learn more. 1050func (c *Client) ListDlpJobs(ctx context.Context, req *dlppb.ListDlpJobsRequest, opts ...gax.CallOption) *DlpJobIterator { 1051 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1052 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1053 opts = append(c.CallOptions.ListDlpJobs[0:len(c.CallOptions.ListDlpJobs):len(c.CallOptions.ListDlpJobs)], opts...) 1054 it := &DlpJobIterator{} 1055 req = proto.Clone(req).(*dlppb.ListDlpJobsRequest) 1056 it.InternalFetch = func(pageSize int, pageToken string) ([]*dlppb.DlpJob, string, error) { 1057 var resp *dlppb.ListDlpJobsResponse 1058 req.PageToken = pageToken 1059 if pageSize > math.MaxInt32 { 1060 req.PageSize = math.MaxInt32 1061 } else { 1062 req.PageSize = int32(pageSize) 1063 } 1064 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1065 var err error 1066 resp, err = c.client.ListDlpJobs(ctx, req, settings.GRPC...) 1067 return err 1068 }, opts...) 1069 if err != nil { 1070 return nil, "", err 1071 } 1072 1073 it.Response = resp 1074 return resp.GetJobs(), resp.GetNextPageToken(), nil 1075 } 1076 fetch := func(pageSize int, pageToken string) (string, error) { 1077 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1078 if err != nil { 1079 return "", err 1080 } 1081 it.items = append(it.items, items...) 1082 return nextPageToken, nil 1083 } 1084 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1085 it.pageInfo.MaxSize = int(req.GetPageSize()) 1086 it.pageInfo.Token = req.GetPageToken() 1087 return it 1088} 1089 1090// GetDlpJob gets the latest state of a long-running DlpJob. 1091// See https://cloud.google.com/dlp/docs/inspecting-storage (at https://cloud.google.com/dlp/docs/inspecting-storage) and 1092// https://cloud.google.com/dlp/docs/compute-risk-analysis (at https://cloud.google.com/dlp/docs/compute-risk-analysis) to learn more. 1093func (c *Client) GetDlpJob(ctx context.Context, req *dlppb.GetDlpJobRequest, opts ...gax.CallOption) (*dlppb.DlpJob, error) { 1094 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1095 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1096 defer cancel() 1097 ctx = cctx 1098 } 1099 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1100 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1101 opts = append(c.CallOptions.GetDlpJob[0:len(c.CallOptions.GetDlpJob):len(c.CallOptions.GetDlpJob)], opts...) 1102 var resp *dlppb.DlpJob 1103 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1104 var err error 1105 resp, err = c.client.GetDlpJob(ctx, req, settings.GRPC...) 1106 return err 1107 }, opts...) 1108 if err != nil { 1109 return nil, err 1110 } 1111 return resp, nil 1112} 1113 1114// DeleteDlpJob deletes a long-running DlpJob. This method indicates that the client is 1115// no longer interested in the DlpJob result. The job will be cancelled if 1116// possible. 1117// See https://cloud.google.com/dlp/docs/inspecting-storage (at https://cloud.google.com/dlp/docs/inspecting-storage) and 1118// https://cloud.google.com/dlp/docs/compute-risk-analysis (at https://cloud.google.com/dlp/docs/compute-risk-analysis) to learn more. 1119func (c *Client) DeleteDlpJob(ctx context.Context, req *dlppb.DeleteDlpJobRequest, opts ...gax.CallOption) error { 1120 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1121 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1122 defer cancel() 1123 ctx = cctx 1124 } 1125 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1126 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1127 opts = append(c.CallOptions.DeleteDlpJob[0:len(c.CallOptions.DeleteDlpJob):len(c.CallOptions.DeleteDlpJob)], opts...) 1128 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1129 var err error 1130 _, err = c.client.DeleteDlpJob(ctx, req, settings.GRPC...) 1131 return err 1132 }, opts...) 1133 return err 1134} 1135 1136// CancelDlpJob starts asynchronous cancellation on a long-running DlpJob. The server 1137// makes a best effort to cancel the DlpJob, but success is not 1138// guaranteed. 1139// See https://cloud.google.com/dlp/docs/inspecting-storage (at https://cloud.google.com/dlp/docs/inspecting-storage) and 1140// https://cloud.google.com/dlp/docs/compute-risk-analysis (at https://cloud.google.com/dlp/docs/compute-risk-analysis) to learn more. 1141func (c *Client) CancelDlpJob(ctx context.Context, req *dlppb.CancelDlpJobRequest, opts ...gax.CallOption) error { 1142 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1143 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1144 defer cancel() 1145 ctx = cctx 1146 } 1147 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1148 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1149 opts = append(c.CallOptions.CancelDlpJob[0:len(c.CallOptions.CancelDlpJob):len(c.CallOptions.CancelDlpJob)], opts...) 1150 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1151 var err error 1152 _, err = c.client.CancelDlpJob(ctx, req, settings.GRPC...) 1153 return err 1154 }, opts...) 1155 return err 1156} 1157 1158// CreateStoredInfoType creates a pre-built stored infoType to be used for inspection. 1159// See https://cloud.google.com/dlp/docs/creating-stored-infotypes (at https://cloud.google.com/dlp/docs/creating-stored-infotypes) to 1160// learn more. 1161func (c *Client) CreateStoredInfoType(ctx context.Context, req *dlppb.CreateStoredInfoTypeRequest, opts ...gax.CallOption) (*dlppb.StoredInfoType, error) { 1162 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1163 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1164 defer cancel() 1165 ctx = cctx 1166 } 1167 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1168 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1169 opts = append(c.CallOptions.CreateStoredInfoType[0:len(c.CallOptions.CreateStoredInfoType):len(c.CallOptions.CreateStoredInfoType)], opts...) 1170 var resp *dlppb.StoredInfoType 1171 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1172 var err error 1173 resp, err = c.client.CreateStoredInfoType(ctx, req, settings.GRPC...) 1174 return err 1175 }, opts...) 1176 if err != nil { 1177 return nil, err 1178 } 1179 return resp, nil 1180} 1181 1182// UpdateStoredInfoType updates the stored infoType by creating a new version. The existing version 1183// will continue to be used until the new version is ready. 1184// See https://cloud.google.com/dlp/docs/creating-stored-infotypes (at https://cloud.google.com/dlp/docs/creating-stored-infotypes) to 1185// learn more. 1186func (c *Client) UpdateStoredInfoType(ctx context.Context, req *dlppb.UpdateStoredInfoTypeRequest, opts ...gax.CallOption) (*dlppb.StoredInfoType, error) { 1187 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1188 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1189 defer cancel() 1190 ctx = cctx 1191 } 1192 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1193 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1194 opts = append(c.CallOptions.UpdateStoredInfoType[0:len(c.CallOptions.UpdateStoredInfoType):len(c.CallOptions.UpdateStoredInfoType)], opts...) 1195 var resp *dlppb.StoredInfoType 1196 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1197 var err error 1198 resp, err = c.client.UpdateStoredInfoType(ctx, req, settings.GRPC...) 1199 return err 1200 }, opts...) 1201 if err != nil { 1202 return nil, err 1203 } 1204 return resp, nil 1205} 1206 1207// GetStoredInfoType gets a stored infoType. 1208// See https://cloud.google.com/dlp/docs/creating-stored-infotypes (at https://cloud.google.com/dlp/docs/creating-stored-infotypes) to 1209// learn more. 1210func (c *Client) GetStoredInfoType(ctx context.Context, req *dlppb.GetStoredInfoTypeRequest, opts ...gax.CallOption) (*dlppb.StoredInfoType, error) { 1211 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1212 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1213 defer cancel() 1214 ctx = cctx 1215 } 1216 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1217 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1218 opts = append(c.CallOptions.GetStoredInfoType[0:len(c.CallOptions.GetStoredInfoType):len(c.CallOptions.GetStoredInfoType)], opts...) 1219 var resp *dlppb.StoredInfoType 1220 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1221 var err error 1222 resp, err = c.client.GetStoredInfoType(ctx, req, settings.GRPC...) 1223 return err 1224 }, opts...) 1225 if err != nil { 1226 return nil, err 1227 } 1228 return resp, nil 1229} 1230 1231// ListStoredInfoTypes lists stored infoTypes. 1232// See https://cloud.google.com/dlp/docs/creating-stored-infotypes (at https://cloud.google.com/dlp/docs/creating-stored-infotypes) to 1233// learn more. 1234func (c *Client) ListStoredInfoTypes(ctx context.Context, req *dlppb.ListStoredInfoTypesRequest, opts ...gax.CallOption) *StoredInfoTypeIterator { 1235 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1236 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1237 opts = append(c.CallOptions.ListStoredInfoTypes[0:len(c.CallOptions.ListStoredInfoTypes):len(c.CallOptions.ListStoredInfoTypes)], opts...) 1238 it := &StoredInfoTypeIterator{} 1239 req = proto.Clone(req).(*dlppb.ListStoredInfoTypesRequest) 1240 it.InternalFetch = func(pageSize int, pageToken string) ([]*dlppb.StoredInfoType, string, error) { 1241 var resp *dlppb.ListStoredInfoTypesResponse 1242 req.PageToken = pageToken 1243 if pageSize > math.MaxInt32 { 1244 req.PageSize = math.MaxInt32 1245 } else { 1246 req.PageSize = int32(pageSize) 1247 } 1248 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1249 var err error 1250 resp, err = c.client.ListStoredInfoTypes(ctx, req, settings.GRPC...) 1251 return err 1252 }, opts...) 1253 if err != nil { 1254 return nil, "", err 1255 } 1256 1257 it.Response = resp 1258 return resp.GetStoredInfoTypes(), resp.GetNextPageToken(), nil 1259 } 1260 fetch := func(pageSize int, pageToken string) (string, error) { 1261 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1262 if err != nil { 1263 return "", err 1264 } 1265 it.items = append(it.items, items...) 1266 return nextPageToken, nil 1267 } 1268 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1269 it.pageInfo.MaxSize = int(req.GetPageSize()) 1270 it.pageInfo.Token = req.GetPageToken() 1271 return it 1272} 1273 1274// DeleteStoredInfoType deletes a stored infoType. 1275// See https://cloud.google.com/dlp/docs/creating-stored-infotypes (at https://cloud.google.com/dlp/docs/creating-stored-infotypes) to 1276// learn more. 1277func (c *Client) DeleteStoredInfoType(ctx context.Context, req *dlppb.DeleteStoredInfoTypeRequest, opts ...gax.CallOption) error { 1278 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1279 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1280 defer cancel() 1281 ctx = cctx 1282 } 1283 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1284 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1285 opts = append(c.CallOptions.DeleteStoredInfoType[0:len(c.CallOptions.DeleteStoredInfoType):len(c.CallOptions.DeleteStoredInfoType)], opts...) 1286 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1287 var err error 1288 _, err = c.client.DeleteStoredInfoType(ctx, req, settings.GRPC...) 1289 return err 1290 }, opts...) 1291 return err 1292} 1293 1294// HybridInspectDlpJob inspect hybrid content and store findings to a job. 1295// To review the findings inspect the job. Inspection will occur 1296// asynchronously. 1297// Early access feature is in a pre-release state and might change or have 1298// limited support. For more information, see 1299// https://cloud.google.com/products#product-launch-stages (at https://cloud.google.com/products#product-launch-stages). 1300func (c *Client) HybridInspectDlpJob(ctx context.Context, req *dlppb.HybridInspectDlpJobRequest, opts ...gax.CallOption) (*dlppb.HybridInspectResponse, error) { 1301 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1302 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1303 defer cancel() 1304 ctx = cctx 1305 } 1306 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1307 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1308 opts = append(c.CallOptions.HybridInspectDlpJob[0:len(c.CallOptions.HybridInspectDlpJob):len(c.CallOptions.HybridInspectDlpJob)], opts...) 1309 var resp *dlppb.HybridInspectResponse 1310 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1311 var err error 1312 resp, err = c.client.HybridInspectDlpJob(ctx, req, settings.GRPC...) 1313 return err 1314 }, opts...) 1315 if err != nil { 1316 return nil, err 1317 } 1318 return resp, nil 1319} 1320 1321// FinishDlpJob finish a running hybrid DlpJob. Triggers the finalization steps and running 1322// of any enabled actions that have not yet run. 1323// Early access feature is in a pre-release state and might change or have 1324// limited support. For more information, see 1325// https://cloud.google.com/products#product-launch-stages (at https://cloud.google.com/products#product-launch-stages). 1326func (c *Client) FinishDlpJob(ctx context.Context, req *dlppb.FinishDlpJobRequest, opts ...gax.CallOption) error { 1327 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1328 cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) 1329 defer cancel() 1330 ctx = cctx 1331 } 1332 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1333 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1334 opts = append(c.CallOptions.FinishDlpJob[0:len(c.CallOptions.FinishDlpJob):len(c.CallOptions.FinishDlpJob)], opts...) 1335 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1336 var err error 1337 _, err = c.client.FinishDlpJob(ctx, req, settings.GRPC...) 1338 return err 1339 }, opts...) 1340 return err 1341} 1342 1343// DeidentifyTemplateIterator manages a stream of *dlppb.DeidentifyTemplate. 1344type DeidentifyTemplateIterator struct { 1345 items []*dlppb.DeidentifyTemplate 1346 pageInfo *iterator.PageInfo 1347 nextFunc func() error 1348 1349 // Response is the raw response for the current page. 1350 // It must be cast to the RPC response type. 1351 // Calling Next() or InternalFetch() updates this value. 1352 Response interface{} 1353 1354 // InternalFetch is for use by the Google Cloud Libraries only. 1355 // It is not part of the stable interface of this package. 1356 // 1357 // InternalFetch returns results from a single call to the underlying RPC. 1358 // The number of results is no greater than pageSize. 1359 // If there are no more results, nextPageToken is empty and err is nil. 1360 InternalFetch func(pageSize int, pageToken string) (results []*dlppb.DeidentifyTemplate, nextPageToken string, err error) 1361} 1362 1363// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1364func (it *DeidentifyTemplateIterator) PageInfo() *iterator.PageInfo { 1365 return it.pageInfo 1366} 1367 1368// Next returns the next result. Its second return value is iterator.Done if there are no more 1369// results. Once Next returns Done, all subsequent calls will return Done. 1370func (it *DeidentifyTemplateIterator) Next() (*dlppb.DeidentifyTemplate, error) { 1371 var item *dlppb.DeidentifyTemplate 1372 if err := it.nextFunc(); err != nil { 1373 return item, err 1374 } 1375 item = it.items[0] 1376 it.items = it.items[1:] 1377 return item, nil 1378} 1379 1380func (it *DeidentifyTemplateIterator) bufLen() int { 1381 return len(it.items) 1382} 1383 1384func (it *DeidentifyTemplateIterator) takeBuf() interface{} { 1385 b := it.items 1386 it.items = nil 1387 return b 1388} 1389 1390// DlpJobIterator manages a stream of *dlppb.DlpJob. 1391type DlpJobIterator struct { 1392 items []*dlppb.DlpJob 1393 pageInfo *iterator.PageInfo 1394 nextFunc func() error 1395 1396 // Response is the raw response for the current page. 1397 // It must be cast to the RPC response type. 1398 // Calling Next() or InternalFetch() updates this value. 1399 Response interface{} 1400 1401 // InternalFetch is for use by the Google Cloud Libraries only. 1402 // It is not part of the stable interface of this package. 1403 // 1404 // InternalFetch returns results from a single call to the underlying RPC. 1405 // The number of results is no greater than pageSize. 1406 // If there are no more results, nextPageToken is empty and err is nil. 1407 InternalFetch func(pageSize int, pageToken string) (results []*dlppb.DlpJob, nextPageToken string, err error) 1408} 1409 1410// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1411func (it *DlpJobIterator) PageInfo() *iterator.PageInfo { 1412 return it.pageInfo 1413} 1414 1415// Next returns the next result. Its second return value is iterator.Done if there are no more 1416// results. Once Next returns Done, all subsequent calls will return Done. 1417func (it *DlpJobIterator) Next() (*dlppb.DlpJob, error) { 1418 var item *dlppb.DlpJob 1419 if err := it.nextFunc(); err != nil { 1420 return item, err 1421 } 1422 item = it.items[0] 1423 it.items = it.items[1:] 1424 return item, nil 1425} 1426 1427func (it *DlpJobIterator) bufLen() int { 1428 return len(it.items) 1429} 1430 1431func (it *DlpJobIterator) takeBuf() interface{} { 1432 b := it.items 1433 it.items = nil 1434 return b 1435} 1436 1437// InspectTemplateIterator manages a stream of *dlppb.InspectTemplate. 1438type InspectTemplateIterator struct { 1439 items []*dlppb.InspectTemplate 1440 pageInfo *iterator.PageInfo 1441 nextFunc func() error 1442 1443 // Response is the raw response for the current page. 1444 // It must be cast to the RPC response type. 1445 // Calling Next() or InternalFetch() updates this value. 1446 Response interface{} 1447 1448 // InternalFetch is for use by the Google Cloud Libraries only. 1449 // It is not part of the stable interface of this package. 1450 // 1451 // InternalFetch returns results from a single call to the underlying RPC. 1452 // The number of results is no greater than pageSize. 1453 // If there are no more results, nextPageToken is empty and err is nil. 1454 InternalFetch func(pageSize int, pageToken string) (results []*dlppb.InspectTemplate, nextPageToken string, err error) 1455} 1456 1457// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1458func (it *InspectTemplateIterator) PageInfo() *iterator.PageInfo { 1459 return it.pageInfo 1460} 1461 1462// Next returns the next result. Its second return value is iterator.Done if there are no more 1463// results. Once Next returns Done, all subsequent calls will return Done. 1464func (it *InspectTemplateIterator) Next() (*dlppb.InspectTemplate, error) { 1465 var item *dlppb.InspectTemplate 1466 if err := it.nextFunc(); err != nil { 1467 return item, err 1468 } 1469 item = it.items[0] 1470 it.items = it.items[1:] 1471 return item, nil 1472} 1473 1474func (it *InspectTemplateIterator) bufLen() int { 1475 return len(it.items) 1476} 1477 1478func (it *InspectTemplateIterator) takeBuf() interface{} { 1479 b := it.items 1480 it.items = nil 1481 return b 1482} 1483 1484// JobTriggerIterator manages a stream of *dlppb.JobTrigger. 1485type JobTriggerIterator struct { 1486 items []*dlppb.JobTrigger 1487 pageInfo *iterator.PageInfo 1488 nextFunc func() error 1489 1490 // Response is the raw response for the current page. 1491 // It must be cast to the RPC response type. 1492 // Calling Next() or InternalFetch() updates this value. 1493 Response interface{} 1494 1495 // InternalFetch is for use by the Google Cloud Libraries only. 1496 // It is not part of the stable interface of this package. 1497 // 1498 // InternalFetch returns results from a single call to the underlying RPC. 1499 // The number of results is no greater than pageSize. 1500 // If there are no more results, nextPageToken is empty and err is nil. 1501 InternalFetch func(pageSize int, pageToken string) (results []*dlppb.JobTrigger, nextPageToken string, err error) 1502} 1503 1504// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1505func (it *JobTriggerIterator) PageInfo() *iterator.PageInfo { 1506 return it.pageInfo 1507} 1508 1509// Next returns the next result. Its second return value is iterator.Done if there are no more 1510// results. Once Next returns Done, all subsequent calls will return Done. 1511func (it *JobTriggerIterator) Next() (*dlppb.JobTrigger, error) { 1512 var item *dlppb.JobTrigger 1513 if err := it.nextFunc(); err != nil { 1514 return item, err 1515 } 1516 item = it.items[0] 1517 it.items = it.items[1:] 1518 return item, nil 1519} 1520 1521func (it *JobTriggerIterator) bufLen() int { 1522 return len(it.items) 1523} 1524 1525func (it *JobTriggerIterator) takeBuf() interface{} { 1526 b := it.items 1527 it.items = nil 1528 return b 1529} 1530 1531// StoredInfoTypeIterator manages a stream of *dlppb.StoredInfoType. 1532type StoredInfoTypeIterator struct { 1533 items []*dlppb.StoredInfoType 1534 pageInfo *iterator.PageInfo 1535 nextFunc func() error 1536 1537 // Response is the raw response for the current page. 1538 // It must be cast to the RPC response type. 1539 // Calling Next() or InternalFetch() updates this value. 1540 Response interface{} 1541 1542 // InternalFetch is for use by the Google Cloud Libraries only. 1543 // It is not part of the stable interface of this package. 1544 // 1545 // InternalFetch returns results from a single call to the underlying RPC. 1546 // The number of results is no greater than pageSize. 1547 // If there are no more results, nextPageToken is empty and err is nil. 1548 InternalFetch func(pageSize int, pageToken string) (results []*dlppb.StoredInfoType, nextPageToken string, err error) 1549} 1550 1551// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1552func (it *StoredInfoTypeIterator) PageInfo() *iterator.PageInfo { 1553 return it.pageInfo 1554} 1555 1556// Next returns the next result. Its second return value is iterator.Done if there are no more 1557// results. Once Next returns Done, all subsequent calls will return Done. 1558func (it *StoredInfoTypeIterator) Next() (*dlppb.StoredInfoType, error) { 1559 var item *dlppb.StoredInfoType 1560 if err := it.nextFunc(); err != nil { 1561 return item, err 1562 } 1563 item = it.items[0] 1564 it.items = it.items[1:] 1565 return item, nil 1566} 1567 1568func (it *StoredInfoTypeIterator) bufLen() int { 1569 return len(it.items) 1570} 1571 1572func (it *StoredInfoTypeIterator) takeBuf() interface{} { 1573 b := it.items 1574 it.items = nil 1575 return b 1576} 1577