...

Source file src/cloud.google.com/go/pubsub/apiv1/subscriber_client.go

Documentation: cloud.google.com/go/pubsub/apiv1

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

View as plain text