...

Source file src/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/analytics_hub_client.go

Documentation: cloud.google.com/go/bigquery/dataexchange/apiv1beta1

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

View as plain text