| 1 |
// Copyright 2025 Google LLC |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
// Code generated by protoc-gen-go_gapic. DO NOT EDIT. |
| 16 |
|
| 17 |
package datasources |
| 18 |
|
| 19 |
import ( |
| 20 |
"bytes" |
| 21 |
"context" |
| 22 |
"fmt" |
| 23 |
"log/slog" |
| 24 |
"math" |
| 25 |
"net/http" |
| 26 |
"net/url" |
| 27 |
"time" |
| 28 |
|
| 29 |
datasourcespb "cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb" |
| 30 |
gax "github.com/googleapis/gax-go/v2" |
| 31 |
"google.golang.org/api/iterator" |
| 32 |
"google.golang.org/api/option" |
| 33 |
"google.golang.org/api/option/internaloption" |
| 34 |
gtransport "google.golang.org/api/transport/grpc" |
| 35 |
httptransport "google.golang.org/api/transport/http" |
| 36 |
"google.golang.org/grpc" |
| 37 |
"google.golang.org/grpc/codes" |
| 38 |
"google.golang.org/protobuf/encoding/protojson" |
| 39 |
"google.golang.org/protobuf/proto" |
| 40 |
) |
| 41 |
|
| 42 |
var newClientHook clientHook |
| 43 |
|
| 44 |
// CallOptions contains the retry settings for each method of Client. |
| 45 |
type CallOptions struct { |
| 46 |
GetDataSource []gax.CallOption |
| 47 |
ListDataSources []gax.CallOption |
| 48 |
CreateDataSource []gax.CallOption |
| 49 |
UpdateDataSource []gax.CallOption |
| 50 |
DeleteDataSource []gax.CallOption |
| 51 |
FetchDataSource []gax.CallOption |
| 52 |
} |
| 53 |
|
| 54 |
func defaultGRPCClientOptions() []option.ClientOption { |
| 55 |
return []option.ClientOption{ |
| 56 |
internaloption.WithDefaultEndpoint("merchantapi.googleapis.com:443"), |
| 57 |
internaloption.WithDefaultEndpointTemplate("merchantapi.UNIVERSE_DOMAIN:443"), |
| 58 |
internaloption.WithDefaultMTLSEndpoint("merchantapi.mtls.googleapis.com:443"), |
| 59 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 60 |
internaloption.WithDefaultAudience("https://merchantapi.googleapis.com/"), |
| 61 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 62 |
internaloption.EnableJwtWithScope(), |
| 63 |
internaloption.EnableNewAuthLibrary(), |
| 64 |
option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| 65 |
grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
func defaultCallOptions() *CallOptions { |
| 70 |
return &CallOptions{ |
| 71 |
GetDataSource: []gax.CallOption{ |
| 72 |
gax.WithTimeout(60000 * time.Millisecond), |
| 73 |
gax.WithRetry(func() gax.Retryer { |
| 74 |
return gax.OnCodes([]codes.Code{ |
| 75 |
codes.Unavailable, |
| 76 |
}, gax.Backoff{ |
| 77 |
Initial: 1000 * time.Millisecond, |
| 78 |
Max: 10000 * time.Millisecond, |
| 79 |
Multiplier: 1.30, |
| 80 |
}) |
| 81 |
}), |
| 82 |
}, |
| 83 |
ListDataSources: []gax.CallOption{ |
| 84 |
gax.WithTimeout(60000 * time.Millisecond), |
| 85 |
gax.WithRetry(func() gax.Retryer { |
| 86 |
return gax.OnCodes([]codes.Code{ |
| 87 |
codes.Unavailable, |
| 88 |
}, gax.Backoff{ |
| 89 |
Initial: 1000 * time.Millisecond, |
| 90 |
Max: 10000 * time.Millisecond, |
| 91 |
Multiplier: 1.30, |
| 92 |
}) |
| 93 |
}), |
| 94 |
}, |
| 95 |
CreateDataSource: []gax.CallOption{ |
| 96 |
gax.WithTimeout(60000 * time.Millisecond), |
| 97 |
gax.WithRetry(func() gax.Retryer { |
| 98 |
return gax.OnCodes([]codes.Code{ |
| 99 |
codes.Unavailable, |
| 100 |
}, gax.Backoff{ |
| 101 |
Initial: 1000 * time.Millisecond, |
| 102 |
Max: 10000 * time.Millisecond, |
| 103 |
Multiplier: 1.30, |
| 104 |
}) |
| 105 |
}), |
| 106 |
}, |
| 107 |
UpdateDataSource: []gax.CallOption{ |
| 108 |
gax.WithTimeout(60000 * time.Millisecond), |
| 109 |
gax.WithRetry(func() gax.Retryer { |
| 110 |
return gax.OnCodes([]codes.Code{ |
| 111 |
codes.Unavailable, |
| 112 |
}, gax.Backoff{ |
| 113 |
Initial: 1000 * time.Millisecond, |
| 114 |
Max: 10000 * time.Millisecond, |
| 115 |
Multiplier: 1.30, |
| 116 |
}) |
| 117 |
}), |
| 118 |
}, |
| 119 |
DeleteDataSource: []gax.CallOption{ |
| 120 |
gax.WithTimeout(60000 * time.Millisecond), |
| 121 |
gax.WithRetry(func() gax.Retryer { |
| 122 |
return gax.OnCodes([]codes.Code{ |
| 123 |
codes.Unavailable, |
| 124 |
}, gax.Backoff{ |
| 125 |
Initial: 1000 * time.Millisecond, |
| 126 |
Max: 10000 * time.Millisecond, |
| 127 |
Multiplier: 1.30, |
| 128 |
}) |
| 129 |
}), |
| 130 |
}, |
| 131 |
FetchDataSource: []gax.CallOption{ |
| 132 |
gax.WithTimeout(60000 * time.Millisecond), |
| 133 |
gax.WithRetry(func() gax.Retryer { |
| 134 |
return gax.OnCodes([]codes.Code{ |
| 135 |
codes.Unavailable, |
| 136 |
}, gax.Backoff{ |
| 137 |
Initial: 1000 * time.Millisecond, |
| 138 |
Max: 10000 * time.Millisecond, |
| 139 |
Multiplier: 1.30, |
| 140 |
}) |
| 141 |
}), |
| 142 |
}, |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
func defaultRESTCallOptions() *CallOptions { |
| 147 |
return &CallOptions{ |
| 148 |
GetDataSource: []gax.CallOption{ |
| 149 |
gax.WithTimeout(60000 * time.Millisecond), |
| 150 |
gax.WithRetry(func() gax.Retryer { |
| 151 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 152 |
Initial: 1000 * time.Millisecond, |
| 153 |
Max: 10000 * time.Millisecond, |
| 154 |
Multiplier: 1.30, |
| 155 |
}, |
| 156 |
http.StatusServiceUnavailable) |
| 157 |
}), |
| 158 |
}, |
| 159 |
ListDataSources: []gax.CallOption{ |
| 160 |
gax.WithTimeout(60000 * time.Millisecond), |
| 161 |
gax.WithRetry(func() gax.Retryer { |
| 162 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 163 |
Initial: 1000 * time.Millisecond, |
| 164 |
Max: 10000 * time.Millisecond, |
| 165 |
Multiplier: 1.30, |
| 166 |
}, |
| 167 |
http.StatusServiceUnavailable) |
| 168 |
}), |
| 169 |
}, |
| 170 |
CreateDataSource: []gax.CallOption{ |
| 171 |
gax.WithTimeout(60000 * time.Millisecond), |
| 172 |
gax.WithRetry(func() gax.Retryer { |
| 173 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 174 |
Initial: 1000 * time.Millisecond, |
| 175 |
Max: 10000 * time.Millisecond, |
| 176 |
Multiplier: 1.30, |
| 177 |
}, |
| 178 |
http.StatusServiceUnavailable) |
| 179 |
}), |
| 180 |
}, |
| 181 |
UpdateDataSource: []gax.CallOption{ |
| 182 |
gax.WithTimeout(60000 * time.Millisecond), |
| 183 |
gax.WithRetry(func() gax.Retryer { |
| 184 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 185 |
Initial: 1000 * time.Millisecond, |
| 186 |
Max: 10000 * time.Millisecond, |
| 187 |
Multiplier: 1.30, |
| 188 |
}, |
| 189 |
http.StatusServiceUnavailable) |
| 190 |
}), |
| 191 |
}, |
| 192 |
DeleteDataSource: []gax.CallOption{ |
| 193 |
gax.WithTimeout(60000 * time.Millisecond), |
| 194 |
gax.WithRetry(func() gax.Retryer { |
| 195 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 196 |
Initial: 1000 * time.Millisecond, |
| 197 |
Max: 10000 * time.Millisecond, |
| 198 |
Multiplier: 1.30, |
| 199 |
}, |
| 200 |
http.StatusServiceUnavailable) |
| 201 |
}), |
| 202 |
}, |
| 203 |
FetchDataSource: []gax.CallOption{ |
| 204 |
gax.WithTimeout(60000 * time.Millisecond), |
| 205 |
gax.WithRetry(func() gax.Retryer { |
| 206 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 207 |
Initial: 1000 * time.Millisecond, |
| 208 |
Max: 10000 * time.Millisecond, |
| 209 |
Multiplier: 1.30, |
| 210 |
}, |
| 211 |
http.StatusServiceUnavailable) |
| 212 |
}), |
| 213 |
}, |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
// internalClient is an interface that defines the methods available from Merchant API. |
| 218 |
type internalClient interface { |
| 219 |
Close() error |
| 220 |
setGoogleClientInfo(...string) |
| 221 |
Connection() *grpc.ClientConn |
| 222 |
GetDataSource(context.Context, *datasourcespb.GetDataSourceRequest, ...gax.CallOption) (*datasourcespb.DataSource, error) |
| 223 |
ListDataSources(context.Context, *datasourcespb.ListDataSourcesRequest, ...gax.CallOption) *DataSourceIterator |
| 224 |
CreateDataSource(context.Context, *datasourcespb.CreateDataSourceRequest, ...gax.CallOption) (*datasourcespb.DataSource, error) |
| 225 |
UpdateDataSource(context.Context, *datasourcespb.UpdateDataSourceRequest, ...gax.CallOption) (*datasourcespb.DataSource, error) |
| 226 |
DeleteDataSource(context.Context, *datasourcespb.DeleteDataSourceRequest, ...gax.CallOption) error |
| 227 |
FetchDataSource(context.Context, *datasourcespb.FetchDataSourceRequest, ...gax.CallOption) error |
| 228 |
} |
| 229 |
|
| 230 |
// Client is a client for interacting with Merchant API. |
| 231 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 232 |
// |
| 233 |
// Service to manage primary, supplemental, inventory and other data sources. |
| 234 |
// See more in the Merchant |
| 235 |
// Center (at https://support.google.com/merchants/answer/7439058) help article. |
| 236 |
type Client struct { |
| 237 |
// The internal transport-dependent client. |
| 238 |
internalClient internalClient |
| 239 |
|
| 240 |
// The call options for this service. |
| 241 |
CallOptions *CallOptions |
| 242 |
} |
| 243 |
|
| 244 |
// Wrapper methods routed to the internal client. |
| 245 |
|
| 246 |
// Close closes the connection to the API service. The user should invoke this when |
| 247 |
// the client is no longer required. |
| 248 |
func (c *Client) Close() error { |
| 249 |
return c.internalClient.Close() |
| 250 |
} |
| 251 |
|
| 252 |
// setGoogleClientInfo sets the name and version of the application in |
| 253 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 254 |
// use by Google-written clients. |
| 255 |
func (c *Client) setGoogleClientInfo(keyval ...string) { |
| 256 |
c.internalClient.setGoogleClientInfo(keyval...) |
| 257 |
} |
| 258 |
|
| 259 |
// Connection returns a connection to the API service. |
| 260 |
// |
| 261 |
// Deprecated: Connections are now pooled so this method does not always |
| 262 |
// return the same resource. |
| 263 |
func (c *Client) Connection() *grpc.ClientConn { |
| 264 |
return c.internalClient.Connection() |
| 265 |
} |
| 266 |
|
| 267 |
// GetDataSource retrieves the data source configuration for the given account. |
| 268 |
func (c *Client) GetDataSource(ctx context.Context, req *datasourcespb.GetDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 269 |
return c.internalClient.GetDataSource(ctx, req, opts...) |
| 270 |
} |
| 271 |
|
| 272 |
// ListDataSources lists the configurations for data sources for the given account. |
| 273 |
func (c *Client) ListDataSources(ctx context.Context, req *datasourcespb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator { |
| 274 |
return c.internalClient.ListDataSources(ctx, req, opts...) |
| 275 |
} |
| 276 |
|
| 277 |
// CreateDataSource creates the new data source configuration for the given account. |
| 278 |
// This method always creates a new data source. |
| 279 |
func (c *Client) CreateDataSource(ctx context.Context, req *datasourcespb.CreateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 280 |
return c.internalClient.CreateDataSource(ctx, req, opts...) |
| 281 |
} |
| 282 |
|
| 283 |
// UpdateDataSource updates the existing data source configuration. The fields that are |
| 284 |
// set in the update mask but not provided in the resource will be deleted. |
| 285 |
func (c *Client) UpdateDataSource(ctx context.Context, req *datasourcespb.UpdateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 286 |
return c.internalClient.UpdateDataSource(ctx, req, opts...) |
| 287 |
} |
| 288 |
|
| 289 |
// DeleteDataSource deletes a data source from your Merchant Center account. |
| 290 |
func (c *Client) DeleteDataSource(ctx context.Context, req *datasourcespb.DeleteDataSourceRequest, opts ...gax.CallOption) error { |
| 291 |
return c.internalClient.DeleteDataSource(ctx, req, opts...) |
| 292 |
} |
| 293 |
|
| 294 |
// FetchDataSource performs the data fetch immediately (even outside fetch schedule) on a |
| 295 |
// data source from your Merchant Center Account. If you need to call |
| 296 |
// this method more than once per day, you should use the Products service to |
| 297 |
// update your product data instead. |
| 298 |
// This method only works on data sources with a file input set. |
| 299 |
func (c *Client) FetchDataSource(ctx context.Context, req *datasourcespb.FetchDataSourceRequest, opts ...gax.CallOption) error { |
| 300 |
return c.internalClient.FetchDataSource(ctx, req, opts...) |
| 301 |
} |
| 302 |
|
| 303 |
// gRPCClient is a client for interacting with Merchant API over gRPC transport. |
| 304 |
// |
| 305 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 306 |
type gRPCClient struct { |
| 307 |
// Connection pool of gRPC connections to the service. |
| 308 |
connPool gtransport.ConnPool |
| 309 |
|
| 310 |
// Points back to the CallOptions field of the containing Client |
| 311 |
CallOptions **CallOptions |
| 312 |
|
| 313 |
// The gRPC API client. |
| 314 |
client datasourcespb.DataSourcesServiceClient |
| 315 |
|
| 316 |
// The x-goog-* metadata to be sent with each request. |
| 317 |
xGoogHeaders []string |
| 318 |
|
| 319 |
logger *slog.Logger |
| 320 |
} |
| 321 |
|
| 322 |
// NewClient creates a new data sources service client based on gRPC. |
| 323 |
// The returned client must be Closed when it is done being used to clean up its underlying connections. |
| 324 |
// |
| 325 |
// Service to manage primary, supplemental, inventory and other data sources. |
| 326 |
// See more in the Merchant |
| 327 |
// Center (at https://support.google.com/merchants/answer/7439058) help article. |
| 328 |
func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { |
| 329 |
clientOpts := defaultGRPCClientOptions() |
| 330 |
if newClientHook != nil { |
| 331 |
hookOpts, err := newClientHook(ctx, clientHookParams{}) |
| 332 |
if err != nil { |
| 333 |
return nil, err |
| 334 |
} |
| 335 |
clientOpts = append(clientOpts, hookOpts...) |
| 336 |
} |
| 337 |
|
| 338 |
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| 339 |
if err != nil { |
| 340 |
return nil, err |
| 341 |
} |
| 342 |
client := Client{CallOptions: defaultCallOptions()} |
| 343 |
|
| 344 |
c := &gRPCClient{ |
| 345 |
connPool: connPool, |
| 346 |
client: datasourcespb.NewDataSourcesServiceClient(connPool), |
| 347 |
CallOptions: &client.CallOptions, |
| 348 |
logger: internaloption.GetLogger(opts), |
| 349 |
} |
| 350 |
c.setGoogleClientInfo() |
| 351 |
|
| 352 |
client.internalClient = c |
| 353 |
|
| 354 |
return &client, nil |
| 355 |
} |
| 356 |
|
| 357 |
// Connection returns a connection to the API service. |
| 358 |
// |
| 359 |
// Deprecated: Connections are now pooled so this method does not always |
| 360 |
// return the same resource. |
| 361 |
func (c *gRPCClient) Connection() *grpc.ClientConn { |
| 362 |
return c.connPool.Conn() |
| 363 |
} |
| 364 |
|
| 365 |
// setGoogleClientInfo sets the name and version of the application in |
| 366 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 367 |
// use by Google-written clients. |
| 368 |
func (c *gRPCClient) setGoogleClientInfo(keyval ...string) { |
| 369 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 370 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) |
| 371 |
c.xGoogHeaders = []string{ |
| 372 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
// Close closes the connection to the API service. The user should invoke this when |
| 377 |
// the client is no longer required. |
| 378 |
func (c *gRPCClient) Close() error { |
| 379 |
return c.connPool.Close() |
| 380 |
} |
| 381 |
|
| 382 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 383 |
type restClient struct { |
| 384 |
// The http endpoint to connect to. |
| 385 |
endpoint string |
| 386 |
|
| 387 |
// The http client. |
| 388 |
httpClient *http.Client |
| 389 |
|
| 390 |
// The x-goog-* headers to be sent with each request. |
| 391 |
xGoogHeaders []string |
| 392 |
|
| 393 |
// Points back to the CallOptions field of the containing Client |
| 394 |
CallOptions **CallOptions |
| 395 |
|
| 396 |
logger *slog.Logger |
| 397 |
} |
| 398 |
|
| 399 |
// NewRESTClient creates a new data sources service rest client. |
| 400 |
// |
| 401 |
// Service to manage primary, supplemental, inventory and other data sources. |
| 402 |
// See more in the Merchant |
| 403 |
// Center (at https://support.google.com/merchants/answer/7439058) help article. |
| 404 |
func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { |
| 405 |
clientOpts := append(defaultRESTClientOptions(), opts...) |
| 406 |
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) |
| 407 |
if err != nil { |
| 408 |
return nil, err |
| 409 |
} |
| 410 |
|
| 411 |
callOpts := defaultRESTCallOptions() |
| 412 |
c := &restClient{ |
| 413 |
endpoint: endpoint, |
| 414 |
httpClient: httpClient, |
| 415 |
CallOptions: &callOpts, |
| 416 |
logger: internaloption.GetLogger(opts), |
| 417 |
} |
| 418 |
c.setGoogleClientInfo() |
| 419 |
|
| 420 |
return &Client{internalClient: c, CallOptions: callOpts}, nil |
| 421 |
} |
| 422 |
|
| 423 |
func defaultRESTClientOptions() []option.ClientOption { |
| 424 |
return []option.ClientOption{ |
| 425 |
internaloption.WithDefaultEndpoint("https://merchantapi.googleapis.com"), |
| 426 |
internaloption.WithDefaultEndpointTemplate("https://merchantapi.UNIVERSE_DOMAIN"), |
| 427 |
internaloption.WithDefaultMTLSEndpoint("https://merchantapi.mtls.googleapis.com"), |
| 428 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 429 |
internaloption.WithDefaultAudience("https://merchantapi.googleapis.com/"), |
| 430 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 431 |
internaloption.EnableNewAuthLibrary(), |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
// setGoogleClientInfo sets the name and version of the application in |
| 436 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 437 |
// use by Google-written clients. |
| 438 |
func (c *restClient) setGoogleClientInfo(keyval ...string) { |
| 439 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 440 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) |
| 441 |
c.xGoogHeaders = []string{ |
| 442 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 443 |
} |
| 444 |
} |
| 445 |
|
| 446 |
// Close closes the connection to the API service. The user should invoke this when |
| 447 |
// the client is no longer required. |
| 448 |
func (c *restClient) Close() error { |
| 449 |
// Replace httpClient with nil to force cleanup. |
| 450 |
c.httpClient = nil |
| 451 |
return nil |
| 452 |
} |
| 453 |
|
| 454 |
// Connection returns a connection to the API service. |
| 455 |
// |
| 456 |
// Deprecated: This method always returns nil. |
| 457 |
func (c *restClient) Connection() *grpc.ClientConn { |
| 458 |
return nil |
| 459 |
} |
| 460 |
func (c *gRPCClient) GetDataSource(ctx context.Context, req *datasourcespb.GetDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 461 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 462 |
|
| 463 |
hds = append(c.xGoogHeaders, hds...) |
| 464 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 465 |
opts = append((*c.CallOptions).GetDataSource[0:len((*c.CallOptions).GetDataSource):len((*c.CallOptions).GetDataSource)], opts...) |
| 466 |
var resp *datasourcespb.DataSource |
| 467 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 468 |
var err error |
| 469 |
resp, err = executeRPC(ctx, c.client.GetDataSource, req, settings.GRPC, c.logger, "GetDataSource") |
| 470 |
return err |
| 471 |
}, opts...) |
| 472 |
if err != nil { |
| 473 |
return nil, err |
| 474 |
} |
| 475 |
return resp, nil |
| 476 |
} |
| 477 |
|
| 478 |
func (c *gRPCClient) ListDataSources(ctx context.Context, req *datasourcespb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator { |
| 479 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 480 |
|
| 481 |
hds = append(c.xGoogHeaders, hds...) |
| 482 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 483 |
opts = append((*c.CallOptions).ListDataSources[0:len((*c.CallOptions).ListDataSources):len((*c.CallOptions).ListDataSources)], opts...) |
| 484 |
it := &DataSourceIterator{} |
| 485 |
req = proto.Clone(req).(*datasourcespb.ListDataSourcesRequest) |
| 486 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*datasourcespb.DataSource, string, error) { |
| 487 |
resp := &datasourcespb.ListDataSourcesResponse{} |
| 488 |
if pageToken != "" { |
| 489 |
req.PageToken = pageToken |
| 490 |
} |
| 491 |
if pageSize > math.MaxInt32 { |
| 492 |
req.PageSize = math.MaxInt32 |
| 493 |
} else if pageSize != 0 { |
| 494 |
req.PageSize = int32(pageSize) |
| 495 |
} |
| 496 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 497 |
var err error |
| 498 |
resp, err = executeRPC(ctx, c.client.ListDataSources, req, settings.GRPC, c.logger, "ListDataSources") |
| 499 |
return err |
| 500 |
}, opts...) |
| 501 |
if err != nil { |
| 502 |
return nil, "", err |
| 503 |
} |
| 504 |
|
| 505 |
it.Response = resp |
| 506 |
return resp.GetDataSources(), resp.GetNextPageToken(), nil |
| 507 |
} |
| 508 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 509 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 510 |
if err != nil { |
| 511 |
return "", err |
| 512 |
} |
| 513 |
it.items = append(it.items, items...) |
| 514 |
return nextPageToken, nil |
| 515 |
} |
| 516 |
|
| 517 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 518 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 519 |
it.pageInfo.Token = req.GetPageToken() |
| 520 |
|
| 521 |
return it |
| 522 |
} |
| 523 |
|
| 524 |
func (c *gRPCClient) CreateDataSource(ctx context.Context, req *datasourcespb.CreateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 525 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 526 |
|
| 527 |
hds = append(c.xGoogHeaders, hds...) |
| 528 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 529 |
opts = append((*c.CallOptions).CreateDataSource[0:len((*c.CallOptions).CreateDataSource):len((*c.CallOptions).CreateDataSource)], opts...) |
| 530 |
var resp *datasourcespb.DataSource |
| 531 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 532 |
var err error |
| 533 |
resp, err = executeRPC(ctx, c.client.CreateDataSource, req, settings.GRPC, c.logger, "CreateDataSource") |
| 534 |
return err |
| 535 |
}, opts...) |
| 536 |
if err != nil { |
| 537 |
return nil, err |
| 538 |
} |
| 539 |
return resp, nil |
| 540 |
} |
| 541 |
|
| 542 |
func (c *gRPCClient) UpdateDataSource(ctx context.Context, req *datasourcespb.UpdateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 543 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_source.name", url.QueryEscape(req.GetDataSource().GetName()))} |
| 544 |
|
| 545 |
hds = append(c.xGoogHeaders, hds...) |
| 546 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 547 |
opts = append((*c.CallOptions).UpdateDataSource[0:len((*c.CallOptions).UpdateDataSource):len((*c.CallOptions).UpdateDataSource)], opts...) |
| 548 |
var resp *datasourcespb.DataSource |
| 549 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 550 |
var err error |
| 551 |
resp, err = executeRPC(ctx, c.client.UpdateDataSource, req, settings.GRPC, c.logger, "UpdateDataSource") |
| 552 |
return err |
| 553 |
}, opts...) |
| 554 |
if err != nil { |
| 555 |
return nil, err |
| 556 |
} |
| 557 |
return resp, nil |
| 558 |
} |
| 559 |
|
| 560 |
func (c *gRPCClient) DeleteDataSource(ctx context.Context, req *datasourcespb.DeleteDataSourceRequest, opts ...gax.CallOption) error { |
| 561 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 562 |
|
| 563 |
hds = append(c.xGoogHeaders, hds...) |
| 564 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 565 |
opts = append((*c.CallOptions).DeleteDataSource[0:len((*c.CallOptions).DeleteDataSource):len((*c.CallOptions).DeleteDataSource)], opts...) |
| 566 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 567 |
var err error |
| 568 |
_, err = executeRPC(ctx, c.client.DeleteDataSource, req, settings.GRPC, c.logger, "DeleteDataSource") |
| 569 |
return err |
| 570 |
}, opts...) |
| 571 |
return err |
| 572 |
} |
| 573 |
|
| 574 |
func (c *gRPCClient) FetchDataSource(ctx context.Context, req *datasourcespb.FetchDataSourceRequest, opts ...gax.CallOption) error { |
| 575 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 576 |
|
| 577 |
hds = append(c.xGoogHeaders, hds...) |
| 578 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 579 |
opts = append((*c.CallOptions).FetchDataSource[0:len((*c.CallOptions).FetchDataSource):len((*c.CallOptions).FetchDataSource)], opts...) |
| 580 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 581 |
var err error |
| 582 |
_, err = executeRPC(ctx, c.client.FetchDataSource, req, settings.GRPC, c.logger, "FetchDataSource") |
| 583 |
return err |
| 584 |
}, opts...) |
| 585 |
return err |
| 586 |
} |
| 587 |
|
| 588 |
// GetDataSource retrieves the data source configuration for the given account. |
| 589 |
func (c *restClient) GetDataSource(ctx context.Context, req *datasourcespb.GetDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 590 |
baseUrl, err := url.Parse(c.endpoint) |
| 591 |
if err != nil { |
| 592 |
return nil, err |
| 593 |
} |
| 594 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v", req.GetName()) |
| 595 |
|
| 596 |
params := url.Values{} |
| 597 |
params.Add("$alt", "json;enum-encoding=int") |
| 598 |
|
| 599 |
baseUrl.RawQuery = params.Encode() |
| 600 |
|
| 601 |
// Build HTTP headers from client and context metadata. |
| 602 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 603 |
|
| 604 |
hds = append(c.xGoogHeaders, hds...) |
| 605 |
hds = append(hds, "Content-Type", "application/json") |
| 606 |
headers := gax.BuildHeaders(ctx, hds...) |
| 607 |
opts = append((*c.CallOptions).GetDataSource[0:len((*c.CallOptions).GetDataSource):len((*c.CallOptions).GetDataSource)], opts...) |
| 608 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 609 |
resp := &datasourcespb.DataSource{} |
| 610 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 611 |
if settings.Path != "" { |
| 612 |
baseUrl.Path = settings.Path |
| 613 |
} |
| 614 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 615 |
if err != nil { |
| 616 |
return err |
| 617 |
} |
| 618 |
httpReq = httpReq.WithContext(ctx) |
| 619 |
httpReq.Header = headers |
| 620 |
|
| 621 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDataSource") |
| 622 |
if err != nil { |
| 623 |
return err |
| 624 |
} |
| 625 |
|
| 626 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 627 |
return err |
| 628 |
} |
| 629 |
|
| 630 |
return nil |
| 631 |
}, opts...) |
| 632 |
if e != nil { |
| 633 |
return nil, e |
| 634 |
} |
| 635 |
return resp, nil |
| 636 |
} |
| 637 |
|
| 638 |
// ListDataSources lists the configurations for data sources for the given account. |
| 639 |
func (c *restClient) ListDataSources(ctx context.Context, req *datasourcespb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator { |
| 640 |
it := &DataSourceIterator{} |
| 641 |
req = proto.Clone(req).(*datasourcespb.ListDataSourcesRequest) |
| 642 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 643 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*datasourcespb.DataSource, string, error) { |
| 644 |
resp := &datasourcespb.ListDataSourcesResponse{} |
| 645 |
if pageToken != "" { |
| 646 |
req.PageToken = pageToken |
| 647 |
} |
| 648 |
if pageSize > math.MaxInt32 { |
| 649 |
req.PageSize = math.MaxInt32 |
| 650 |
} else if pageSize != 0 { |
| 651 |
req.PageSize = int32(pageSize) |
| 652 |
} |
| 653 |
baseUrl, err := url.Parse(c.endpoint) |
| 654 |
if err != nil { |
| 655 |
return nil, "", err |
| 656 |
} |
| 657 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v/dataSources", req.GetParent()) |
| 658 |
|
| 659 |
params := url.Values{} |
| 660 |
params.Add("$alt", "json;enum-encoding=int") |
| 661 |
if req.GetPageSize() != 0 { |
| 662 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 663 |
} |
| 664 |
if req.GetPageToken() != "" { |
| 665 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 666 |
} |
| 667 |
|
| 668 |
baseUrl.RawQuery = params.Encode() |
| 669 |
|
| 670 |
// Build HTTP headers from client and context metadata. |
| 671 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 672 |
headers := gax.BuildHeaders(ctx, hds...) |
| 673 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 674 |
if settings.Path != "" { |
| 675 |
baseUrl.Path = settings.Path |
| 676 |
} |
| 677 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 678 |
if err != nil { |
| 679 |
return err |
| 680 |
} |
| 681 |
httpReq.Header = headers |
| 682 |
|
| 683 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDataSources") |
| 684 |
if err != nil { |
| 685 |
return err |
| 686 |
} |
| 687 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 688 |
return err |
| 689 |
} |
| 690 |
|
| 691 |
return nil |
| 692 |
}, opts...) |
| 693 |
if e != nil { |
| 694 |
return nil, "", e |
| 695 |
} |
| 696 |
it.Response = resp |
| 697 |
return resp.GetDataSources(), resp.GetNextPageToken(), nil |
| 698 |
} |
| 699 |
|
| 700 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 701 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 702 |
if err != nil { |
| 703 |
return "", err |
| 704 |
} |
| 705 |
it.items = append(it.items, items...) |
| 706 |
return nextPageToken, nil |
| 707 |
} |
| 708 |
|
| 709 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 710 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 711 |
it.pageInfo.Token = req.GetPageToken() |
| 712 |
|
| 713 |
return it |
| 714 |
} |
| 715 |
|
| 716 |
// CreateDataSource creates the new data source configuration for the given account. |
| 717 |
// This method always creates a new data source. |
| 718 |
func (c *restClient) CreateDataSource(ctx context.Context, req *datasourcespb.CreateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 719 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 720 |
body := req.GetDataSource() |
| 721 |
jsonReq, err := m.Marshal(body) |
| 722 |
if err != nil { |
| 723 |
return nil, err |
| 724 |
} |
| 725 |
|
| 726 |
baseUrl, err := url.Parse(c.endpoint) |
| 727 |
if err != nil { |
| 728 |
return nil, err |
| 729 |
} |
| 730 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v/dataSources", req.GetParent()) |
| 731 |
|
| 732 |
params := url.Values{} |
| 733 |
params.Add("$alt", "json;enum-encoding=int") |
| 734 |
|
| 735 |
baseUrl.RawQuery = params.Encode() |
| 736 |
|
| 737 |
// Build HTTP headers from client and context metadata. |
| 738 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 739 |
|
| 740 |
hds = append(c.xGoogHeaders, hds...) |
| 741 |
hds = append(hds, "Content-Type", "application/json") |
| 742 |
headers := gax.BuildHeaders(ctx, hds...) |
| 743 |
opts = append((*c.CallOptions).CreateDataSource[0:len((*c.CallOptions).CreateDataSource):len((*c.CallOptions).CreateDataSource)], opts...) |
| 744 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 745 |
resp := &datasourcespb.DataSource{} |
| 746 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 747 |
if settings.Path != "" { |
| 748 |
baseUrl.Path = settings.Path |
| 749 |
} |
| 750 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 751 |
if err != nil { |
| 752 |
return err |
| 753 |
} |
| 754 |
httpReq = httpReq.WithContext(ctx) |
| 755 |
httpReq.Header = headers |
| 756 |
|
| 757 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDataSource") |
| 758 |
if err != nil { |
| 759 |
return err |
| 760 |
} |
| 761 |
|
| 762 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 763 |
return err |
| 764 |
} |
| 765 |
|
| 766 |
return nil |
| 767 |
}, opts...) |
| 768 |
if e != nil { |
| 769 |
return nil, e |
| 770 |
} |
| 771 |
return resp, nil |
| 772 |
} |
| 773 |
|
| 774 |
// UpdateDataSource updates the existing data source configuration. The fields that are |
| 775 |
// set in the update mask but not provided in the resource will be deleted. |
| 776 |
func (c *restClient) UpdateDataSource(ctx context.Context, req *datasourcespb.UpdateDataSourceRequest, opts ...gax.CallOption) (*datasourcespb.DataSource, error) { |
| 777 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 778 |
body := req.GetDataSource() |
| 779 |
jsonReq, err := m.Marshal(body) |
| 780 |
if err != nil { |
| 781 |
return nil, err |
| 782 |
} |
| 783 |
|
| 784 |
baseUrl, err := url.Parse(c.endpoint) |
| 785 |
if err != nil { |
| 786 |
return nil, err |
| 787 |
} |
| 788 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v", req.GetDataSource().GetName()) |
| 789 |
|
| 790 |
params := url.Values{} |
| 791 |
params.Add("$alt", "json;enum-encoding=int") |
| 792 |
if req.GetUpdateMask() != nil { |
| 793 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 794 |
if err != nil { |
| 795 |
return nil, err |
| 796 |
} |
| 797 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 798 |
} |
| 799 |
|
| 800 |
baseUrl.RawQuery = params.Encode() |
| 801 |
|
| 802 |
// Build HTTP headers from client and context metadata. |
| 803 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_source.name", url.QueryEscape(req.GetDataSource().GetName()))} |
| 804 |
|
| 805 |
hds = append(c.xGoogHeaders, hds...) |
| 806 |
hds = append(hds, "Content-Type", "application/json") |
| 807 |
headers := gax.BuildHeaders(ctx, hds...) |
| 808 |
opts = append((*c.CallOptions).UpdateDataSource[0:len((*c.CallOptions).UpdateDataSource):len((*c.CallOptions).UpdateDataSource)], opts...) |
| 809 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 810 |
resp := &datasourcespb.DataSource{} |
| 811 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 812 |
if settings.Path != "" { |
| 813 |
baseUrl.Path = settings.Path |
| 814 |
} |
| 815 |
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 816 |
if err != nil { |
| 817 |
return err |
| 818 |
} |
| 819 |
httpReq = httpReq.WithContext(ctx) |
| 820 |
httpReq.Header = headers |
| 821 |
|
| 822 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDataSource") |
| 823 |
if err != nil { |
| 824 |
return err |
| 825 |
} |
| 826 |
|
| 827 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 828 |
return err |
| 829 |
} |
| 830 |
|
| 831 |
return nil |
| 832 |
}, opts...) |
| 833 |
if e != nil { |
| 834 |
return nil, e |
| 835 |
} |
| 836 |
return resp, nil |
| 837 |
} |
| 838 |
|
| 839 |
// DeleteDataSource deletes a data source from your Merchant Center account. |
| 840 |
func (c *restClient) DeleteDataSource(ctx context.Context, req *datasourcespb.DeleteDataSourceRequest, opts ...gax.CallOption) error { |
| 841 |
baseUrl, err := url.Parse(c.endpoint) |
| 842 |
if err != nil { |
| 843 |
return err |
| 844 |
} |
| 845 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v", req.GetName()) |
| 846 |
|
| 847 |
params := url.Values{} |
| 848 |
params.Add("$alt", "json;enum-encoding=int") |
| 849 |
|
| 850 |
baseUrl.RawQuery = params.Encode() |
| 851 |
|
| 852 |
// Build HTTP headers from client and context metadata. |
| 853 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 854 |
|
| 855 |
hds = append(c.xGoogHeaders, hds...) |
| 856 |
hds = append(hds, "Content-Type", "application/json") |
| 857 |
headers := gax.BuildHeaders(ctx, hds...) |
| 858 |
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 859 |
if settings.Path != "" { |
| 860 |
baseUrl.Path = settings.Path |
| 861 |
} |
| 862 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 863 |
if err != nil { |
| 864 |
return err |
| 865 |
} |
| 866 |
httpReq = httpReq.WithContext(ctx) |
| 867 |
httpReq.Header = headers |
| 868 |
|
| 869 |
_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDataSource") |
| 870 |
return err |
| 871 |
}, opts...) |
| 872 |
} |
| 873 |
|
| 874 |
// FetchDataSource performs the data fetch immediately (even outside fetch schedule) on a |
| 875 |
// data source from your Merchant Center Account. If you need to call |
| 876 |
// this method more than once per day, you should use the Products service to |
| 877 |
// update your product data instead. |
| 878 |
// This method only works on data sources with a file input set. |
| 879 |
func (c *restClient) FetchDataSource(ctx context.Context, req *datasourcespb.FetchDataSourceRequest, opts ...gax.CallOption) error { |
| 880 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 881 |
jsonReq, err := m.Marshal(req) |
| 882 |
if err != nil { |
| 883 |
return err |
| 884 |
} |
| 885 |
|
| 886 |
baseUrl, err := url.Parse(c.endpoint) |
| 887 |
if err != nil { |
| 888 |
return err |
| 889 |
} |
| 890 |
baseUrl.Path += fmt.Sprintf("/datasources/v1/%v:fetch", req.GetName()) |
| 891 |
|
| 892 |
params := url.Values{} |
| 893 |
params.Add("$alt", "json;enum-encoding=int") |
| 894 |
|
| 895 |
baseUrl.RawQuery = params.Encode() |
| 896 |
|
| 897 |
// Build HTTP headers from client and context metadata. |
| 898 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 899 |
|
| 900 |
hds = append(c.xGoogHeaders, hds...) |
| 901 |
hds = append(hds, "Content-Type", "application/json") |
| 902 |
headers := gax.BuildHeaders(ctx, hds...) |
| 903 |
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 904 |
if settings.Path != "" { |
| 905 |
baseUrl.Path = settings.Path |
| 906 |
} |
| 907 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 908 |
if err != nil { |
| 909 |
return err |
| 910 |
} |
| 911 |
httpReq = httpReq.WithContext(ctx) |
| 912 |
httpReq.Header = headers |
| 913 |
|
| 914 |
_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "FetchDataSource") |
| 915 |
return err |
| 916 |
}, opts...) |
| 917 |
} |