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 binaryauthorization 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 gax "github.com/googleapis/gax-go/v2" 27 "google.golang.org/api/iterator" 28 "google.golang.org/api/option" 29 "google.golang.org/api/option/internaloption" 30 gtransport "google.golang.org/api/transport/grpc" 31 binaryauthorizationpb "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1" 32 "google.golang.org/grpc" 33 "google.golang.org/grpc/codes" 34 "google.golang.org/grpc/metadata" 35 "google.golang.org/protobuf/proto" 36) 37 38var newBinauthzManagementServiceV1Beta1ClientHook clientHook 39 40// BinauthzManagementServiceV1Beta1CallOptions contains the retry settings for each method of BinauthzManagementServiceV1Beta1Client. 41type BinauthzManagementServiceV1Beta1CallOptions struct { 42 GetPolicy []gax.CallOption 43 UpdatePolicy []gax.CallOption 44 CreateAttestor []gax.CallOption 45 GetAttestor []gax.CallOption 46 UpdateAttestor []gax.CallOption 47 ListAttestors []gax.CallOption 48 DeleteAttestor []gax.CallOption 49} 50 51func defaultBinauthzManagementServiceV1Beta1GRPCClientOptions() []option.ClientOption { 52 return []option.ClientOption{ 53 internaloption.WithDefaultEndpoint("binaryauthorization.googleapis.com:443"), 54 internaloption.WithDefaultMTLSEndpoint("binaryauthorization.mtls.googleapis.com:443"), 55 internaloption.WithDefaultAudience("https://binaryauthorization.googleapis.com/"), 56 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 57 internaloption.EnableJwtWithScope(), 58 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 59 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 60 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 61 } 62} 63 64func defaultBinauthzManagementServiceV1Beta1CallOptions() *BinauthzManagementServiceV1Beta1CallOptions { 65 return &BinauthzManagementServiceV1Beta1CallOptions{ 66 GetPolicy: []gax.CallOption{ 67 gax.WithRetry(func() gax.Retryer { 68 return gax.OnCodes([]codes.Code{ 69 codes.DeadlineExceeded, 70 codes.Unavailable, 71 }, gax.Backoff{ 72 Initial: 100 * time.Millisecond, 73 Max: 60000 * time.Millisecond, 74 Multiplier: 1.30, 75 }) 76 }), 77 }, 78 UpdatePolicy: []gax.CallOption{ 79 gax.WithRetry(func() gax.Retryer { 80 return gax.OnCodes([]codes.Code{ 81 codes.DeadlineExceeded, 82 codes.Unavailable, 83 }, gax.Backoff{ 84 Initial: 100 * time.Millisecond, 85 Max: 60000 * time.Millisecond, 86 Multiplier: 1.30, 87 }) 88 }), 89 }, 90 CreateAttestor: []gax.CallOption{}, 91 GetAttestor: []gax.CallOption{ 92 gax.WithRetry(func() gax.Retryer { 93 return gax.OnCodes([]codes.Code{ 94 codes.DeadlineExceeded, 95 codes.Unavailable, 96 }, gax.Backoff{ 97 Initial: 100 * time.Millisecond, 98 Max: 60000 * time.Millisecond, 99 Multiplier: 1.30, 100 }) 101 }), 102 }, 103 UpdateAttestor: []gax.CallOption{ 104 gax.WithRetry(func() gax.Retryer { 105 return gax.OnCodes([]codes.Code{ 106 codes.DeadlineExceeded, 107 codes.Unavailable, 108 }, gax.Backoff{ 109 Initial: 100 * time.Millisecond, 110 Max: 60000 * time.Millisecond, 111 Multiplier: 1.30, 112 }) 113 }), 114 }, 115 ListAttestors: []gax.CallOption{ 116 gax.WithRetry(func() gax.Retryer { 117 return gax.OnCodes([]codes.Code{ 118 codes.DeadlineExceeded, 119 codes.Unavailable, 120 }, gax.Backoff{ 121 Initial: 100 * time.Millisecond, 122 Max: 60000 * time.Millisecond, 123 Multiplier: 1.30, 124 }) 125 }), 126 }, 127 DeleteAttestor: []gax.CallOption{ 128 gax.WithRetry(func() gax.Retryer { 129 return gax.OnCodes([]codes.Code{ 130 codes.DeadlineExceeded, 131 codes.Unavailable, 132 }, gax.Backoff{ 133 Initial: 100 * time.Millisecond, 134 Max: 60000 * time.Millisecond, 135 Multiplier: 1.30, 136 }) 137 }), 138 }, 139 } 140} 141 142// internalBinauthzManagementServiceV1Beta1Client is an interface that defines the methods availaible from Binary Authorization API. 143type internalBinauthzManagementServiceV1Beta1Client interface { 144 Close() error 145 setGoogleClientInfo(...string) 146 Connection() *grpc.ClientConn 147 GetPolicy(context.Context, *binaryauthorizationpb.GetPolicyRequest, ...gax.CallOption) (*binaryauthorizationpb.Policy, error) 148 UpdatePolicy(context.Context, *binaryauthorizationpb.UpdatePolicyRequest, ...gax.CallOption) (*binaryauthorizationpb.Policy, error) 149 CreateAttestor(context.Context, *binaryauthorizationpb.CreateAttestorRequest, ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) 150 GetAttestor(context.Context, *binaryauthorizationpb.GetAttestorRequest, ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) 151 UpdateAttestor(context.Context, *binaryauthorizationpb.UpdateAttestorRequest, ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) 152 ListAttestors(context.Context, *binaryauthorizationpb.ListAttestorsRequest, ...gax.CallOption) *AttestorIterator 153 DeleteAttestor(context.Context, *binaryauthorizationpb.DeleteAttestorRequest, ...gax.CallOption) error 154} 155 156// BinauthzManagementServiceV1Beta1Client is a client for interacting with Binary Authorization API. 157// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 158// 159// Google Cloud Management Service for Binary Authorization admission policies 160// and attestation authorities. 161// 162// This API implements a REST model with the following objects: 163// 164// Policy 165// 166// Attestor 167type BinauthzManagementServiceV1Beta1Client struct { 168 // The internal transport-dependent client. 169 internalClient internalBinauthzManagementServiceV1Beta1Client 170 171 // The call options for this service. 172 CallOptions *BinauthzManagementServiceV1Beta1CallOptions 173} 174 175// Wrapper methods routed to the internal client. 176 177// Close closes the connection to the API service. The user should invoke this when 178// the client is no longer required. 179func (c *BinauthzManagementServiceV1Beta1Client) Close() error { 180 return c.internalClient.Close() 181} 182 183// setGoogleClientInfo sets the name and version of the application in 184// the `x-goog-api-client` header passed on each request. Intended for 185// use by Google-written clients. 186func (c *BinauthzManagementServiceV1Beta1Client) setGoogleClientInfo(keyval ...string) { 187 c.internalClient.setGoogleClientInfo(keyval...) 188} 189 190// Connection returns a connection to the API service. 191// 192// Deprecated. 193func (c *BinauthzManagementServiceV1Beta1Client) Connection() *grpc.ClientConn { 194 return c.internalClient.Connection() 195} 196 197// GetPolicy a policy specifies the 198// attestors that must 199// attest to a container image, before the project is allowed to deploy that 200// image. There is at most one policy per project. All image admission 201// requests are permitted if a project has no policy. 202// 203// Gets the policy for this 204// project. Returns a default 205// policy if the project 206// does not have one. 207func (c *BinauthzManagementServiceV1Beta1Client) GetPolicy(ctx context.Context, req *binaryauthorizationpb.GetPolicyRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Policy, error) { 208 return c.internalClient.GetPolicy(ctx, req, opts...) 209} 210 211// UpdatePolicy creates or updates a project’s 212// policy, and returns a 213// copy of the new policy. 214// A policy is always updated as a whole, to avoid race conditions with 215// concurrent policy enforcement (or management!) requests. Returns NOT_FOUND 216// if the project does not exist, INVALID_ARGUMENT if the request is 217// malformed. 218func (c *BinauthzManagementServiceV1Beta1Client) UpdatePolicy(ctx context.Context, req *binaryauthorizationpb.UpdatePolicyRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Policy, error) { 219 return c.internalClient.UpdatePolicy(ctx, req, opts...) 220} 221 222// CreateAttestor creates an attestor, 223// and returns a copy of the new 224// attestor. Returns 225// NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is 226// malformed, ALREADY_EXISTS if the 227// attestor already 228// exists. 229func (c *BinauthzManagementServiceV1Beta1Client) CreateAttestor(ctx context.Context, req *binaryauthorizationpb.CreateAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 230 return c.internalClient.CreateAttestor(ctx, req, opts...) 231} 232 233// GetAttestor gets an attestor. 234// Returns NOT_FOUND if the 235// attestor does not 236// exist. 237func (c *BinauthzManagementServiceV1Beta1Client) GetAttestor(ctx context.Context, req *binaryauthorizationpb.GetAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 238 return c.internalClient.GetAttestor(ctx, req, opts...) 239} 240 241// UpdateAttestor updates an attestor. 242// Returns NOT_FOUND if the 243// attestor does not 244// exist. 245func (c *BinauthzManagementServiceV1Beta1Client) UpdateAttestor(ctx context.Context, req *binaryauthorizationpb.UpdateAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 246 return c.internalClient.UpdateAttestor(ctx, req, opts...) 247} 248 249// ListAttestors lists attestors. 250// Returns INVALID_ARGUMENT if the project does not exist. 251func (c *BinauthzManagementServiceV1Beta1Client) ListAttestors(ctx context.Context, req *binaryauthorizationpb.ListAttestorsRequest, opts ...gax.CallOption) *AttestorIterator { 252 return c.internalClient.ListAttestors(ctx, req, opts...) 253} 254 255// DeleteAttestor deletes an attestor. 256// Returns NOT_FOUND if the 257// attestor does not 258// exist. 259func (c *BinauthzManagementServiceV1Beta1Client) DeleteAttestor(ctx context.Context, req *binaryauthorizationpb.DeleteAttestorRequest, opts ...gax.CallOption) error { 260 return c.internalClient.DeleteAttestor(ctx, req, opts...) 261} 262 263// binauthzManagementServiceV1Beta1GRPCClient is a client for interacting with Binary Authorization API over gRPC transport. 264// 265// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 266type binauthzManagementServiceV1Beta1GRPCClient struct { 267 // Connection pool of gRPC connections to the service. 268 connPool gtransport.ConnPool 269 270 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 271 disableDeadlines bool 272 273 // Points back to the CallOptions field of the containing BinauthzManagementServiceV1Beta1Client 274 CallOptions **BinauthzManagementServiceV1Beta1CallOptions 275 276 // The gRPC API client. 277 binauthzManagementServiceV1Beta1Client binaryauthorizationpb.BinauthzManagementServiceV1Beta1Client 278 279 // The x-goog-* metadata to be sent with each request. 280 xGoogMetadata metadata.MD 281} 282 283// NewBinauthzManagementServiceV1Beta1Client creates a new binauthz management service v1 beta1 client based on gRPC. 284// The returned client must be Closed when it is done being used to clean up its underlying connections. 285// 286// Google Cloud Management Service for Binary Authorization admission policies 287// and attestation authorities. 288// 289// This API implements a REST model with the following objects: 290// 291// Policy 292// 293// Attestor 294func NewBinauthzManagementServiceV1Beta1Client(ctx context.Context, opts ...option.ClientOption) (*BinauthzManagementServiceV1Beta1Client, error) { 295 clientOpts := defaultBinauthzManagementServiceV1Beta1GRPCClientOptions() 296 if newBinauthzManagementServiceV1Beta1ClientHook != nil { 297 hookOpts, err := newBinauthzManagementServiceV1Beta1ClientHook(ctx, clientHookParams{}) 298 if err != nil { 299 return nil, err 300 } 301 clientOpts = append(clientOpts, hookOpts...) 302 } 303 304 disableDeadlines, err := checkDisableDeadlines() 305 if err != nil { 306 return nil, err 307 } 308 309 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 310 if err != nil { 311 return nil, err 312 } 313 client := BinauthzManagementServiceV1Beta1Client{CallOptions: defaultBinauthzManagementServiceV1Beta1CallOptions()} 314 315 c := &binauthzManagementServiceV1Beta1GRPCClient{ 316 connPool: connPool, 317 disableDeadlines: disableDeadlines, 318 binauthzManagementServiceV1Beta1Client: binaryauthorizationpb.NewBinauthzManagementServiceV1Beta1Client(connPool), 319 CallOptions: &client.CallOptions, 320 } 321 c.setGoogleClientInfo() 322 323 client.internalClient = c 324 325 return &client, nil 326} 327 328// Connection returns a connection to the API service. 329// 330// Deprecated. 331func (c *binauthzManagementServiceV1Beta1GRPCClient) Connection() *grpc.ClientConn { 332 return c.connPool.Conn() 333} 334 335// setGoogleClientInfo sets the name and version of the application in 336// the `x-goog-api-client` header passed on each request. Intended for 337// use by Google-written clients. 338func (c *binauthzManagementServiceV1Beta1GRPCClient) setGoogleClientInfo(keyval ...string) { 339 kv := append([]string{"gl-go", versionGo()}, keyval...) 340 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 341 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 342} 343 344// Close closes the connection to the API service. The user should invoke this when 345// the client is no longer required. 346func (c *binauthzManagementServiceV1Beta1GRPCClient) Close() error { 347 return c.connPool.Close() 348} 349 350func (c *binauthzManagementServiceV1Beta1GRPCClient) GetPolicy(ctx context.Context, req *binaryauthorizationpb.GetPolicyRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Policy, error) { 351 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 352 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 353 defer cancel() 354 ctx = cctx 355 } 356 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 357 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 358 opts = append((*c.CallOptions).GetPolicy[0:len((*c.CallOptions).GetPolicy):len((*c.CallOptions).GetPolicy)], opts...) 359 var resp *binaryauthorizationpb.Policy 360 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 361 var err error 362 resp, err = c.binauthzManagementServiceV1Beta1Client.GetPolicy(ctx, req, settings.GRPC...) 363 return err 364 }, opts...) 365 if err != nil { 366 return nil, err 367 } 368 return resp, nil 369} 370 371func (c *binauthzManagementServiceV1Beta1GRPCClient) UpdatePolicy(ctx context.Context, req *binaryauthorizationpb.UpdatePolicyRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Policy, error) { 372 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 373 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 374 defer cancel() 375 ctx = cctx 376 } 377 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "policy.name", url.QueryEscape(req.GetPolicy().GetName()))) 378 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 379 opts = append((*c.CallOptions).UpdatePolicy[0:len((*c.CallOptions).UpdatePolicy):len((*c.CallOptions).UpdatePolicy)], opts...) 380 var resp *binaryauthorizationpb.Policy 381 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 382 var err error 383 resp, err = c.binauthzManagementServiceV1Beta1Client.UpdatePolicy(ctx, req, settings.GRPC...) 384 return err 385 }, opts...) 386 if err != nil { 387 return nil, err 388 } 389 return resp, nil 390} 391 392func (c *binauthzManagementServiceV1Beta1GRPCClient) CreateAttestor(ctx context.Context, req *binaryauthorizationpb.CreateAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 393 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 394 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 395 defer cancel() 396 ctx = cctx 397 } 398 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 399 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 400 opts = append((*c.CallOptions).CreateAttestor[0:len((*c.CallOptions).CreateAttestor):len((*c.CallOptions).CreateAttestor)], opts...) 401 var resp *binaryauthorizationpb.Attestor 402 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 403 var err error 404 resp, err = c.binauthzManagementServiceV1Beta1Client.CreateAttestor(ctx, req, settings.GRPC...) 405 return err 406 }, opts...) 407 if err != nil { 408 return nil, err 409 } 410 return resp, nil 411} 412 413func (c *binauthzManagementServiceV1Beta1GRPCClient) GetAttestor(ctx context.Context, req *binaryauthorizationpb.GetAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 414 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 415 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 416 defer cancel() 417 ctx = cctx 418 } 419 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 420 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 421 opts = append((*c.CallOptions).GetAttestor[0:len((*c.CallOptions).GetAttestor):len((*c.CallOptions).GetAttestor)], opts...) 422 var resp *binaryauthorizationpb.Attestor 423 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 424 var err error 425 resp, err = c.binauthzManagementServiceV1Beta1Client.GetAttestor(ctx, req, settings.GRPC...) 426 return err 427 }, opts...) 428 if err != nil { 429 return nil, err 430 } 431 return resp, nil 432} 433 434func (c *binauthzManagementServiceV1Beta1GRPCClient) UpdateAttestor(ctx context.Context, req *binaryauthorizationpb.UpdateAttestorRequest, opts ...gax.CallOption) (*binaryauthorizationpb.Attestor, error) { 435 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 436 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 437 defer cancel() 438 ctx = cctx 439 } 440 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "attestor.name", url.QueryEscape(req.GetAttestor().GetName()))) 441 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 442 opts = append((*c.CallOptions).UpdateAttestor[0:len((*c.CallOptions).UpdateAttestor):len((*c.CallOptions).UpdateAttestor)], opts...) 443 var resp *binaryauthorizationpb.Attestor 444 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 445 var err error 446 resp, err = c.binauthzManagementServiceV1Beta1Client.UpdateAttestor(ctx, req, settings.GRPC...) 447 return err 448 }, opts...) 449 if err != nil { 450 return nil, err 451 } 452 return resp, nil 453} 454 455func (c *binauthzManagementServiceV1Beta1GRPCClient) ListAttestors(ctx context.Context, req *binaryauthorizationpb.ListAttestorsRequest, opts ...gax.CallOption) *AttestorIterator { 456 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 457 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 458 opts = append((*c.CallOptions).ListAttestors[0:len((*c.CallOptions).ListAttestors):len((*c.CallOptions).ListAttestors)], opts...) 459 it := &AttestorIterator{} 460 req = proto.Clone(req).(*binaryauthorizationpb.ListAttestorsRequest) 461 it.InternalFetch = func(pageSize int, pageToken string) ([]*binaryauthorizationpb.Attestor, string, error) { 462 resp := &binaryauthorizationpb.ListAttestorsResponse{} 463 if pageToken != "" { 464 req.PageToken = pageToken 465 } 466 if pageSize > math.MaxInt32 { 467 req.PageSize = math.MaxInt32 468 } else if pageSize != 0 { 469 req.PageSize = int32(pageSize) 470 } 471 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 472 var err error 473 resp, err = c.binauthzManagementServiceV1Beta1Client.ListAttestors(ctx, req, settings.GRPC...) 474 return err 475 }, opts...) 476 if err != nil { 477 return nil, "", err 478 } 479 480 it.Response = resp 481 return resp.GetAttestors(), resp.GetNextPageToken(), nil 482 } 483 fetch := func(pageSize int, pageToken string) (string, error) { 484 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 485 if err != nil { 486 return "", err 487 } 488 it.items = append(it.items, items...) 489 return nextPageToken, nil 490 } 491 492 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 493 it.pageInfo.MaxSize = int(req.GetPageSize()) 494 it.pageInfo.Token = req.GetPageToken() 495 496 return it 497} 498 499func (c *binauthzManagementServiceV1Beta1GRPCClient) DeleteAttestor(ctx context.Context, req *binaryauthorizationpb.DeleteAttestorRequest, opts ...gax.CallOption) error { 500 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 501 cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) 502 defer cancel() 503 ctx = cctx 504 } 505 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 506 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 507 opts = append((*c.CallOptions).DeleteAttestor[0:len((*c.CallOptions).DeleteAttestor):len((*c.CallOptions).DeleteAttestor)], opts...) 508 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 509 var err error 510 _, err = c.binauthzManagementServiceV1Beta1Client.DeleteAttestor(ctx, req, settings.GRPC...) 511 return err 512 }, opts...) 513 return err 514} 515 516// AttestorIterator manages a stream of *binaryauthorizationpb.Attestor. 517type AttestorIterator struct { 518 items []*binaryauthorizationpb.Attestor 519 pageInfo *iterator.PageInfo 520 nextFunc func() error 521 522 // Response is the raw response for the current page. 523 // It must be cast to the RPC response type. 524 // Calling Next() or InternalFetch() updates this value. 525 Response interface{} 526 527 // InternalFetch is for use by the Google Cloud Libraries only. 528 // It is not part of the stable interface of this package. 529 // 530 // InternalFetch returns results from a single call to the underlying RPC. 531 // The number of results is no greater than pageSize. 532 // If there are no more results, nextPageToken is empty and err is nil. 533 InternalFetch func(pageSize int, pageToken string) (results []*binaryauthorizationpb.Attestor, nextPageToken string, err error) 534} 535 536// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 537func (it *AttestorIterator) PageInfo() *iterator.PageInfo { 538 return it.pageInfo 539} 540 541// Next returns the next result. Its second return value is iterator.Done if there are no more 542// results. Once Next returns Done, all subsequent calls will return Done. 543func (it *AttestorIterator) Next() (*binaryauthorizationpb.Attestor, error) { 544 var item *binaryauthorizationpb.Attestor 545 if err := it.nextFunc(); err != nil { 546 return item, err 547 } 548 item = it.items[0] 549 it.items = it.items[1:] 550 return item, nil 551} 552 553func (it *AttestorIterator) bufLen() int { 554 return len(it.items) 555} 556 557func (it *AttestorIterator) takeBuf() interface{} { 558 b := it.items 559 it.items = nil 560 return b 561} 562