| 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 biglake |
| 18 |
|
| 19 |
import ( |
| 20 |
"bytes" |
| 21 |
"context" |
| 22 |
"fmt" |
| 23 |
"log/slog" |
| 24 |
"math" |
| 25 |
"net/http" |
| 26 |
"net/url" |
| 27 |
"time" |
| 28 |
|
| 29 |
biglakepb "cloud.google.com/go/bigquery/biglake/apiv1/biglakepb" |
| 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 newMetastoreClientHook clientHook |
| 43 |
|
| 44 |
// MetastoreCallOptions contains the retry settings for each method of MetastoreClient. |
| 45 |
type MetastoreCallOptions struct { |
| 46 |
CreateCatalog []gax.CallOption |
| 47 |
DeleteCatalog []gax.CallOption |
| 48 |
GetCatalog []gax.CallOption |
| 49 |
ListCatalogs []gax.CallOption |
| 50 |
CreateDatabase []gax.CallOption |
| 51 |
DeleteDatabase []gax.CallOption |
| 52 |
UpdateDatabase []gax.CallOption |
| 53 |
GetDatabase []gax.CallOption |
| 54 |
ListDatabases []gax.CallOption |
| 55 |
CreateTable []gax.CallOption |
| 56 |
DeleteTable []gax.CallOption |
| 57 |
UpdateTable []gax.CallOption |
| 58 |
RenameTable []gax.CallOption |
| 59 |
GetTable []gax.CallOption |
| 60 |
ListTables []gax.CallOption |
| 61 |
} |
| 62 |
|
| 63 |
func defaultMetastoreGRPCClientOptions() []option.ClientOption { |
| 64 |
return []option.ClientOption{ |
| 65 |
internaloption.WithDefaultEndpoint("biglake.googleapis.com:443"), |
| 66 |
internaloption.WithDefaultEndpointTemplate("biglake.UNIVERSE_DOMAIN:443"), |
| 67 |
internaloption.WithDefaultMTLSEndpoint("biglake.mtls.googleapis.com:443"), |
| 68 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 69 |
internaloption.WithDefaultAudience("https://biglake.googleapis.com/"), |
| 70 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 71 |
internaloption.EnableJwtWithScope(), |
| 72 |
internaloption.EnableNewAuthLibrary(), |
| 73 |
option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| 74 |
grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
func defaultMetastoreCallOptions() *MetastoreCallOptions { |
| 79 |
return &MetastoreCallOptions{ |
| 80 |
CreateCatalog: []gax.CallOption{ |
| 81 |
gax.WithTimeout(60000 * time.Millisecond), |
| 82 |
gax.WithRetry(func() gax.Retryer { |
| 83 |
return gax.OnCodes([]codes.Code{ |
| 84 |
codes.DeadlineExceeded, |
| 85 |
codes.Unavailable, |
| 86 |
}, gax.Backoff{ |
| 87 |
Initial: 1000 * time.Millisecond, |
| 88 |
Max: 10000 * time.Millisecond, |
| 89 |
Multiplier: 1.30, |
| 90 |
}) |
| 91 |
}), |
| 92 |
}, |
| 93 |
DeleteCatalog: []gax.CallOption{ |
| 94 |
gax.WithTimeout(60000 * time.Millisecond), |
| 95 |
gax.WithRetry(func() gax.Retryer { |
| 96 |
return gax.OnCodes([]codes.Code{ |
| 97 |
codes.DeadlineExceeded, |
| 98 |
codes.Unavailable, |
| 99 |
}, gax.Backoff{ |
| 100 |
Initial: 1000 * time.Millisecond, |
| 101 |
Max: 10000 * time.Millisecond, |
| 102 |
Multiplier: 1.30, |
| 103 |
}) |
| 104 |
}), |
| 105 |
}, |
| 106 |
GetCatalog: []gax.CallOption{ |
| 107 |
gax.WithTimeout(60000 * time.Millisecond), |
| 108 |
gax.WithRetry(func() gax.Retryer { |
| 109 |
return gax.OnCodes([]codes.Code{ |
| 110 |
codes.DeadlineExceeded, |
| 111 |
codes.Unavailable, |
| 112 |
}, gax.Backoff{ |
| 113 |
Initial: 1000 * time.Millisecond, |
| 114 |
Max: 10000 * time.Millisecond, |
| 115 |
Multiplier: 1.30, |
| 116 |
}) |
| 117 |
}), |
| 118 |
}, |
| 119 |
ListCatalogs: []gax.CallOption{ |
| 120 |
gax.WithTimeout(60000 * time.Millisecond), |
| 121 |
gax.WithRetry(func() gax.Retryer { |
| 122 |
return gax.OnCodes([]codes.Code{ |
| 123 |
codes.DeadlineExceeded, |
| 124 |
codes.Unavailable, |
| 125 |
}, gax.Backoff{ |
| 126 |
Initial: 1000 * time.Millisecond, |
| 127 |
Max: 10000 * time.Millisecond, |
| 128 |
Multiplier: 1.30, |
| 129 |
}) |
| 130 |
}), |
| 131 |
}, |
| 132 |
CreateDatabase: []gax.CallOption{ |
| 133 |
gax.WithTimeout(60000 * time.Millisecond), |
| 134 |
gax.WithRetry(func() gax.Retryer { |
| 135 |
return gax.OnCodes([]codes.Code{ |
| 136 |
codes.DeadlineExceeded, |
| 137 |
codes.Unavailable, |
| 138 |
}, gax.Backoff{ |
| 139 |
Initial: 1000 * time.Millisecond, |
| 140 |
Max: 10000 * time.Millisecond, |
| 141 |
Multiplier: 1.30, |
| 142 |
}) |
| 143 |
}), |
| 144 |
}, |
| 145 |
DeleteDatabase: []gax.CallOption{ |
| 146 |
gax.WithTimeout(60000 * time.Millisecond), |
| 147 |
gax.WithRetry(func() gax.Retryer { |
| 148 |
return gax.OnCodes([]codes.Code{ |
| 149 |
codes.DeadlineExceeded, |
| 150 |
codes.Unavailable, |
| 151 |
}, gax.Backoff{ |
| 152 |
Initial: 1000 * time.Millisecond, |
| 153 |
Max: 10000 * time.Millisecond, |
| 154 |
Multiplier: 1.30, |
| 155 |
}) |
| 156 |
}), |
| 157 |
}, |
| 158 |
UpdateDatabase: []gax.CallOption{ |
| 159 |
gax.WithTimeout(60000 * time.Millisecond), |
| 160 |
gax.WithRetry(func() gax.Retryer { |
| 161 |
return gax.OnCodes([]codes.Code{ |
| 162 |
codes.DeadlineExceeded, |
| 163 |
codes.Unavailable, |
| 164 |
}, gax.Backoff{ |
| 165 |
Initial: 1000 * time.Millisecond, |
| 166 |
Max: 10000 * time.Millisecond, |
| 167 |
Multiplier: 1.30, |
| 168 |
}) |
| 169 |
}), |
| 170 |
}, |
| 171 |
GetDatabase: []gax.CallOption{ |
| 172 |
gax.WithTimeout(60000 * time.Millisecond), |
| 173 |
gax.WithRetry(func() gax.Retryer { |
| 174 |
return gax.OnCodes([]codes.Code{ |
| 175 |
codes.DeadlineExceeded, |
| 176 |
codes.Unavailable, |
| 177 |
}, gax.Backoff{ |
| 178 |
Initial: 1000 * time.Millisecond, |
| 179 |
Max: 10000 * time.Millisecond, |
| 180 |
Multiplier: 1.30, |
| 181 |
}) |
| 182 |
}), |
| 183 |
}, |
| 184 |
ListDatabases: []gax.CallOption{ |
| 185 |
gax.WithTimeout(60000 * time.Millisecond), |
| 186 |
gax.WithRetry(func() gax.Retryer { |
| 187 |
return gax.OnCodes([]codes.Code{ |
| 188 |
codes.DeadlineExceeded, |
| 189 |
codes.Unavailable, |
| 190 |
}, gax.Backoff{ |
| 191 |
Initial: 1000 * time.Millisecond, |
| 192 |
Max: 10000 * time.Millisecond, |
| 193 |
Multiplier: 1.30, |
| 194 |
}) |
| 195 |
}), |
| 196 |
}, |
| 197 |
CreateTable: []gax.CallOption{ |
| 198 |
gax.WithTimeout(60000 * time.Millisecond), |
| 199 |
gax.WithRetry(func() gax.Retryer { |
| 200 |
return gax.OnCodes([]codes.Code{ |
| 201 |
codes.DeadlineExceeded, |
| 202 |
codes.Unavailable, |
| 203 |
}, gax.Backoff{ |
| 204 |
Initial: 1000 * time.Millisecond, |
| 205 |
Max: 10000 * time.Millisecond, |
| 206 |
Multiplier: 1.30, |
| 207 |
}) |
| 208 |
}), |
| 209 |
}, |
| 210 |
DeleteTable: []gax.CallOption{ |
| 211 |
gax.WithTimeout(60000 * time.Millisecond), |
| 212 |
gax.WithRetry(func() gax.Retryer { |
| 213 |
return gax.OnCodes([]codes.Code{ |
| 214 |
codes.DeadlineExceeded, |
| 215 |
codes.Unavailable, |
| 216 |
}, gax.Backoff{ |
| 217 |
Initial: 1000 * time.Millisecond, |
| 218 |
Max: 10000 * time.Millisecond, |
| 219 |
Multiplier: 1.30, |
| 220 |
}) |
| 221 |
}), |
| 222 |
}, |
| 223 |
UpdateTable: []gax.CallOption{ |
| 224 |
gax.WithTimeout(60000 * time.Millisecond), |
| 225 |
gax.WithRetry(func() gax.Retryer { |
| 226 |
return gax.OnCodes([]codes.Code{ |
| 227 |
codes.DeadlineExceeded, |
| 228 |
codes.Unavailable, |
| 229 |
}, gax.Backoff{ |
| 230 |
Initial: 1000 * time.Millisecond, |
| 231 |
Max: 10000 * time.Millisecond, |
| 232 |
Multiplier: 1.30, |
| 233 |
}) |
| 234 |
}), |
| 235 |
}, |
| 236 |
RenameTable: []gax.CallOption{ |
| 237 |
gax.WithTimeout(60000 * time.Millisecond), |
| 238 |
gax.WithRetry(func() gax.Retryer { |
| 239 |
return gax.OnCodes([]codes.Code{ |
| 240 |
codes.DeadlineExceeded, |
| 241 |
codes.Unavailable, |
| 242 |
}, gax.Backoff{ |
| 243 |
Initial: 1000 * time.Millisecond, |
| 244 |
Max: 10000 * time.Millisecond, |
| 245 |
Multiplier: 1.30, |
| 246 |
}) |
| 247 |
}), |
| 248 |
}, |
| 249 |
GetTable: []gax.CallOption{ |
| 250 |
gax.WithTimeout(60000 * time.Millisecond), |
| 251 |
gax.WithRetry(func() gax.Retryer { |
| 252 |
return gax.OnCodes([]codes.Code{ |
| 253 |
codes.DeadlineExceeded, |
| 254 |
codes.Unavailable, |
| 255 |
}, gax.Backoff{ |
| 256 |
Initial: 1000 * time.Millisecond, |
| 257 |
Max: 10000 * time.Millisecond, |
| 258 |
Multiplier: 1.30, |
| 259 |
}) |
| 260 |
}), |
| 261 |
}, |
| 262 |
ListTables: []gax.CallOption{ |
| 263 |
gax.WithTimeout(60000 * time.Millisecond), |
| 264 |
gax.WithRetry(func() gax.Retryer { |
| 265 |
return gax.OnCodes([]codes.Code{ |
| 266 |
codes.DeadlineExceeded, |
| 267 |
codes.Unavailable, |
| 268 |
}, gax.Backoff{ |
| 269 |
Initial: 1000 * time.Millisecond, |
| 270 |
Max: 10000 * time.Millisecond, |
| 271 |
Multiplier: 1.30, |
| 272 |
}) |
| 273 |
}), |
| 274 |
}, |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
func defaultMetastoreRESTCallOptions() *MetastoreCallOptions { |
| 279 |
return &MetastoreCallOptions{ |
| 280 |
CreateCatalog: []gax.CallOption{ |
| 281 |
gax.WithTimeout(60000 * time.Millisecond), |
| 282 |
gax.WithRetry(func() gax.Retryer { |
| 283 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 284 |
Initial: 1000 * time.Millisecond, |
| 285 |
Max: 10000 * time.Millisecond, |
| 286 |
Multiplier: 1.30, |
| 287 |
}, |
| 288 |
http.StatusGatewayTimeout, |
| 289 |
http.StatusServiceUnavailable) |
| 290 |
}), |
| 291 |
}, |
| 292 |
DeleteCatalog: []gax.CallOption{ |
| 293 |
gax.WithTimeout(60000 * time.Millisecond), |
| 294 |
gax.WithRetry(func() gax.Retryer { |
| 295 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 296 |
Initial: 1000 * time.Millisecond, |
| 297 |
Max: 10000 * time.Millisecond, |
| 298 |
Multiplier: 1.30, |
| 299 |
}, |
| 300 |
http.StatusGatewayTimeout, |
| 301 |
http.StatusServiceUnavailable) |
| 302 |
}), |
| 303 |
}, |
| 304 |
GetCatalog: []gax.CallOption{ |
| 305 |
gax.WithTimeout(60000 * time.Millisecond), |
| 306 |
gax.WithRetry(func() gax.Retryer { |
| 307 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 308 |
Initial: 1000 * time.Millisecond, |
| 309 |
Max: 10000 * time.Millisecond, |
| 310 |
Multiplier: 1.30, |
| 311 |
}, |
| 312 |
http.StatusGatewayTimeout, |
| 313 |
http.StatusServiceUnavailable) |
| 314 |
}), |
| 315 |
}, |
| 316 |
ListCatalogs: []gax.CallOption{ |
| 317 |
gax.WithTimeout(60000 * time.Millisecond), |
| 318 |
gax.WithRetry(func() gax.Retryer { |
| 319 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 320 |
Initial: 1000 * time.Millisecond, |
| 321 |
Max: 10000 * time.Millisecond, |
| 322 |
Multiplier: 1.30, |
| 323 |
}, |
| 324 |
http.StatusGatewayTimeout, |
| 325 |
http.StatusServiceUnavailable) |
| 326 |
}), |
| 327 |
}, |
| 328 |
CreateDatabase: []gax.CallOption{ |
| 329 |
gax.WithTimeout(60000 * time.Millisecond), |
| 330 |
gax.WithRetry(func() gax.Retryer { |
| 331 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 332 |
Initial: 1000 * time.Millisecond, |
| 333 |
Max: 10000 * time.Millisecond, |
| 334 |
Multiplier: 1.30, |
| 335 |
}, |
| 336 |
http.StatusGatewayTimeout, |
| 337 |
http.StatusServiceUnavailable) |
| 338 |
}), |
| 339 |
}, |
| 340 |
DeleteDatabase: []gax.CallOption{ |
| 341 |
gax.WithTimeout(60000 * time.Millisecond), |
| 342 |
gax.WithRetry(func() gax.Retryer { |
| 343 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 344 |
Initial: 1000 * time.Millisecond, |
| 345 |
Max: 10000 * time.Millisecond, |
| 346 |
Multiplier: 1.30, |
| 347 |
}, |
| 348 |
http.StatusGatewayTimeout, |
| 349 |
http.StatusServiceUnavailable) |
| 350 |
}), |
| 351 |
}, |
| 352 |
UpdateDatabase: []gax.CallOption{ |
| 353 |
gax.WithTimeout(60000 * time.Millisecond), |
| 354 |
gax.WithRetry(func() gax.Retryer { |
| 355 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 356 |
Initial: 1000 * time.Millisecond, |
| 357 |
Max: 10000 * time.Millisecond, |
| 358 |
Multiplier: 1.30, |
| 359 |
}, |
| 360 |
http.StatusGatewayTimeout, |
| 361 |
http.StatusServiceUnavailable) |
| 362 |
}), |
| 363 |
}, |
| 364 |
GetDatabase: []gax.CallOption{ |
| 365 |
gax.WithTimeout(60000 * time.Millisecond), |
| 366 |
gax.WithRetry(func() gax.Retryer { |
| 367 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 368 |
Initial: 1000 * time.Millisecond, |
| 369 |
Max: 10000 * time.Millisecond, |
| 370 |
Multiplier: 1.30, |
| 371 |
}, |
| 372 |
http.StatusGatewayTimeout, |
| 373 |
http.StatusServiceUnavailable) |
| 374 |
}), |
| 375 |
}, |
| 376 |
ListDatabases: []gax.CallOption{ |
| 377 |
gax.WithTimeout(60000 * time.Millisecond), |
| 378 |
gax.WithRetry(func() gax.Retryer { |
| 379 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 380 |
Initial: 1000 * time.Millisecond, |
| 381 |
Max: 10000 * time.Millisecond, |
| 382 |
Multiplier: 1.30, |
| 383 |
}, |
| 384 |
http.StatusGatewayTimeout, |
| 385 |
http.StatusServiceUnavailable) |
| 386 |
}), |
| 387 |
}, |
| 388 |
CreateTable: []gax.CallOption{ |
| 389 |
gax.WithTimeout(60000 * time.Millisecond), |
| 390 |
gax.WithRetry(func() gax.Retryer { |
| 391 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 392 |
Initial: 1000 * time.Millisecond, |
| 393 |
Max: 10000 * time.Millisecond, |
| 394 |
Multiplier: 1.30, |
| 395 |
}, |
| 396 |
http.StatusGatewayTimeout, |
| 397 |
http.StatusServiceUnavailable) |
| 398 |
}), |
| 399 |
}, |
| 400 |
DeleteTable: []gax.CallOption{ |
| 401 |
gax.WithTimeout(60000 * time.Millisecond), |
| 402 |
gax.WithRetry(func() gax.Retryer { |
| 403 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 404 |
Initial: 1000 * time.Millisecond, |
| 405 |
Max: 10000 * time.Millisecond, |
| 406 |
Multiplier: 1.30, |
| 407 |
}, |
| 408 |
http.StatusGatewayTimeout, |
| 409 |
http.StatusServiceUnavailable) |
| 410 |
}), |
| 411 |
}, |
| 412 |
UpdateTable: []gax.CallOption{ |
| 413 |
gax.WithTimeout(60000 * time.Millisecond), |
| 414 |
gax.WithRetry(func() gax.Retryer { |
| 415 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 416 |
Initial: 1000 * time.Millisecond, |
| 417 |
Max: 10000 * time.Millisecond, |
| 418 |
Multiplier: 1.30, |
| 419 |
}, |
| 420 |
http.StatusGatewayTimeout, |
| 421 |
http.StatusServiceUnavailable) |
| 422 |
}), |
| 423 |
}, |
| 424 |
RenameTable: []gax.CallOption{ |
| 425 |
gax.WithTimeout(60000 * time.Millisecond), |
| 426 |
gax.WithRetry(func() gax.Retryer { |
| 427 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 428 |
Initial: 1000 * time.Millisecond, |
| 429 |
Max: 10000 * time.Millisecond, |
| 430 |
Multiplier: 1.30, |
| 431 |
}, |
| 432 |
http.StatusGatewayTimeout, |
| 433 |
http.StatusServiceUnavailable) |
| 434 |
}), |
| 435 |
}, |
| 436 |
GetTable: []gax.CallOption{ |
| 437 |
gax.WithTimeout(60000 * time.Millisecond), |
| 438 |
gax.WithRetry(func() gax.Retryer { |
| 439 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 440 |
Initial: 1000 * time.Millisecond, |
| 441 |
Max: 10000 * time.Millisecond, |
| 442 |
Multiplier: 1.30, |
| 443 |
}, |
| 444 |
http.StatusGatewayTimeout, |
| 445 |
http.StatusServiceUnavailable) |
| 446 |
}), |
| 447 |
}, |
| 448 |
ListTables: []gax.CallOption{ |
| 449 |
gax.WithTimeout(60000 * time.Millisecond), |
| 450 |
gax.WithRetry(func() gax.Retryer { |
| 451 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 452 |
Initial: 1000 * time.Millisecond, |
| 453 |
Max: 10000 * time.Millisecond, |
| 454 |
Multiplier: 1.30, |
| 455 |
}, |
| 456 |
http.StatusGatewayTimeout, |
| 457 |
http.StatusServiceUnavailable) |
| 458 |
}), |
| 459 |
}, |
| 460 |
} |
| 461 |
} |
| 462 |
|
| 463 |
// internalMetastoreClient is an interface that defines the methods available from BigLake API. |
| 464 |
type internalMetastoreClient interface { |
| 465 |
Close() error |
| 466 |
setGoogleClientInfo(...string) |
| 467 |
Connection() *grpc.ClientConn |
| 468 |
CreateCatalog(context.Context, *biglakepb.CreateCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error) |
| 469 |
DeleteCatalog(context.Context, *biglakepb.DeleteCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error) |
| 470 |
GetCatalog(context.Context, *biglakepb.GetCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error) |
| 471 |
ListCatalogs(context.Context, *biglakepb.ListCatalogsRequest, ...gax.CallOption) *CatalogIterator |
| 472 |
CreateDatabase(context.Context, *biglakepb.CreateDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error) |
| 473 |
DeleteDatabase(context.Context, *biglakepb.DeleteDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error) |
| 474 |
UpdateDatabase(context.Context, *biglakepb.UpdateDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error) |
| 475 |
GetDatabase(context.Context, *biglakepb.GetDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error) |
| 476 |
ListDatabases(context.Context, *biglakepb.ListDatabasesRequest, ...gax.CallOption) *DatabaseIterator |
| 477 |
CreateTable(context.Context, *biglakepb.CreateTableRequest, ...gax.CallOption) (*biglakepb.Table, error) |
| 478 |
DeleteTable(context.Context, *biglakepb.DeleteTableRequest, ...gax.CallOption) (*biglakepb.Table, error) |
| 479 |
UpdateTable(context.Context, *biglakepb.UpdateTableRequest, ...gax.CallOption) (*biglakepb.Table, error) |
| 480 |
RenameTable(context.Context, *biglakepb.RenameTableRequest, ...gax.CallOption) (*biglakepb.Table, error) |
| 481 |
GetTable(context.Context, *biglakepb.GetTableRequest, ...gax.CallOption) (*biglakepb.Table, error) |
| 482 |
ListTables(context.Context, *biglakepb.ListTablesRequest, ...gax.CallOption) *TableIterator |
| 483 |
} |
| 484 |
|
| 485 |
// MetastoreClient is a client for interacting with BigLake API. |
| 486 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 487 |
// |
| 488 |
// BigLake Metastore is a serverless, highly available, multi-tenant runtime |
| 489 |
// metastore for Google Cloud Data Analytics products. |
| 490 |
// |
| 491 |
// The BigLake Metastore API defines the following resource model: |
| 492 |
// |
| 493 |
// A collection of Google Cloud projects: /projects/* |
| 494 |
// |
| 495 |
// Each project has a collection of available locations: /locations/* |
| 496 |
// |
| 497 |
// Each location has a collection of catalogs: /catalogs/* |
| 498 |
// |
| 499 |
// Each catalog has a collection of databases: /databases/* |
| 500 |
// |
| 501 |
// Each database has a collection of tables: /tables/* |
| 502 |
type MetastoreClient struct { |
| 503 |
// The internal transport-dependent client. |
| 504 |
internalClient internalMetastoreClient |
| 505 |
|
| 506 |
// The call options for this service. |
| 507 |
CallOptions *MetastoreCallOptions |
| 508 |
} |
| 509 |
|
| 510 |
// Wrapper methods routed to the internal client. |
| 511 |
|
| 512 |
// Close closes the connection to the API service. The user should invoke this when |
| 513 |
// the client is no longer required. |
| 514 |
func (c *MetastoreClient) Close() error { |
| 515 |
return c.internalClient.Close() |
| 516 |
} |
| 517 |
|
| 518 |
// setGoogleClientInfo sets the name and version of the application in |
| 519 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 520 |
// use by Google-written clients. |
| 521 |
func (c *MetastoreClient) setGoogleClientInfo(keyval ...string) { |
| 522 |
c.internalClient.setGoogleClientInfo(keyval...) |
| 523 |
} |
| 524 |
|
| 525 |
// Connection returns a connection to the API service. |
| 526 |
// |
| 527 |
// Deprecated: Connections are now pooled so this method does not always |
| 528 |
// return the same resource. |
| 529 |
func (c *MetastoreClient) Connection() *grpc.ClientConn { |
| 530 |
return c.internalClient.Connection() |
| 531 |
} |
| 532 |
|
| 533 |
// CreateCatalog creates a new catalog. |
| 534 |
func (c *MetastoreClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 535 |
return c.internalClient.CreateCatalog(ctx, req, opts...) |
| 536 |
} |
| 537 |
|
| 538 |
// DeleteCatalog deletes an existing catalog specified by the catalog ID. |
| 539 |
func (c *MetastoreClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 540 |
return c.internalClient.DeleteCatalog(ctx, req, opts...) |
| 541 |
} |
| 542 |
|
| 543 |
// GetCatalog gets the catalog specified by the resource name. |
| 544 |
func (c *MetastoreClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 545 |
return c.internalClient.GetCatalog(ctx, req, opts...) |
| 546 |
} |
| 547 |
|
| 548 |
// ListCatalogs list all catalogs in a specified project. |
| 549 |
func (c *MetastoreClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator { |
| 550 |
return c.internalClient.ListCatalogs(ctx, req, opts...) |
| 551 |
} |
| 552 |
|
| 553 |
// CreateDatabase creates a new database. |
| 554 |
func (c *MetastoreClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 555 |
return c.internalClient.CreateDatabase(ctx, req, opts...) |
| 556 |
} |
| 557 |
|
| 558 |
// DeleteDatabase deletes an existing database specified by the database ID. |
| 559 |
func (c *MetastoreClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 560 |
return c.internalClient.DeleteDatabase(ctx, req, opts...) |
| 561 |
} |
| 562 |
|
| 563 |
// UpdateDatabase updates an existing database specified by the database ID. |
| 564 |
func (c *MetastoreClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 565 |
return c.internalClient.UpdateDatabase(ctx, req, opts...) |
| 566 |
} |
| 567 |
|
| 568 |
// GetDatabase gets the database specified by the resource name. |
| 569 |
func (c *MetastoreClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 570 |
return c.internalClient.GetDatabase(ctx, req, opts...) |
| 571 |
} |
| 572 |
|
| 573 |
// ListDatabases list all databases in a specified catalog. |
| 574 |
func (c *MetastoreClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator { |
| 575 |
return c.internalClient.ListDatabases(ctx, req, opts...) |
| 576 |
} |
| 577 |
|
| 578 |
// CreateTable creates a new table. |
| 579 |
func (c *MetastoreClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 580 |
return c.internalClient.CreateTable(ctx, req, opts...) |
| 581 |
} |
| 582 |
|
| 583 |
// DeleteTable deletes an existing table specified by the table ID. |
| 584 |
func (c *MetastoreClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 585 |
return c.internalClient.DeleteTable(ctx, req, opts...) |
| 586 |
} |
| 587 |
|
| 588 |
// UpdateTable updates an existing table specified by the table ID. |
| 589 |
func (c *MetastoreClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 590 |
return c.internalClient.UpdateTable(ctx, req, opts...) |
| 591 |
} |
| 592 |
|
| 593 |
// RenameTable renames an existing table specified by the table ID. |
| 594 |
func (c *MetastoreClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 595 |
return c.internalClient.RenameTable(ctx, req, opts...) |
| 596 |
} |
| 597 |
|
| 598 |
// GetTable gets the table specified by the resource name. |
| 599 |
func (c *MetastoreClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 600 |
return c.internalClient.GetTable(ctx, req, opts...) |
| 601 |
} |
| 602 |
|
| 603 |
// ListTables list all tables in a specified database. |
| 604 |
func (c *MetastoreClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator { |
| 605 |
return c.internalClient.ListTables(ctx, req, opts...) |
| 606 |
} |
| 607 |
|
| 608 |
// metastoreGRPCClient is a client for interacting with BigLake API over gRPC transport. |
| 609 |
// |
| 610 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 611 |
type metastoreGRPCClient struct { |
| 612 |
// Connection pool of gRPC connections to the service. |
| 613 |
connPool gtransport.ConnPool |
| 614 |
|
| 615 |
// Points back to the CallOptions field of the containing MetastoreClient |
| 616 |
CallOptions **MetastoreCallOptions |
| 617 |
|
| 618 |
// The gRPC API client. |
| 619 |
metastoreClient biglakepb.MetastoreServiceClient |
| 620 |
|
| 621 |
// The x-goog-* metadata to be sent with each request. |
| 622 |
xGoogHeaders []string |
| 623 |
|
| 624 |
logger *slog.Logger |
| 625 |
} |
| 626 |
|
| 627 |
// NewMetastoreClient creates a new metastore service client based on gRPC. |
| 628 |
// The returned client must be Closed when it is done being used to clean up its underlying connections. |
| 629 |
// |
| 630 |
// BigLake Metastore is a serverless, highly available, multi-tenant runtime |
| 631 |
// metastore for Google Cloud Data Analytics products. |
| 632 |
// |
| 633 |
// The BigLake Metastore API defines the following resource model: |
| 634 |
// |
| 635 |
// A collection of Google Cloud projects: /projects/* |
| 636 |
// |
| 637 |
// Each project has a collection of available locations: /locations/* |
| 638 |
// |
| 639 |
// Each location has a collection of catalogs: /catalogs/* |
| 640 |
// |
| 641 |
// Each catalog has a collection of databases: /databases/* |
| 642 |
// |
| 643 |
// Each database has a collection of tables: /tables/* |
| 644 |
func NewMetastoreClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) { |
| 645 |
clientOpts := defaultMetastoreGRPCClientOptions() |
| 646 |
if newMetastoreClientHook != nil { |
| 647 |
hookOpts, err := newMetastoreClientHook(ctx, clientHookParams{}) |
| 648 |
if err != nil { |
| 649 |
return nil, err |
| 650 |
} |
| 651 |
clientOpts = append(clientOpts, hookOpts...) |
| 652 |
} |
| 653 |
|
| 654 |
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| 655 |
if err != nil { |
| 656 |
return nil, err |
| 657 |
} |
| 658 |
client := MetastoreClient{CallOptions: defaultMetastoreCallOptions()} |
| 659 |
|
| 660 |
c := &metastoreGRPCClient{ |
| 661 |
connPool: connPool, |
| 662 |
metastoreClient: biglakepb.NewMetastoreServiceClient(connPool), |
| 663 |
CallOptions: &client.CallOptions, |
| 664 |
logger: internaloption.GetLogger(opts), |
| 665 |
} |
| 666 |
c.setGoogleClientInfo() |
| 667 |
|
| 668 |
client.internalClient = c |
| 669 |
|
| 670 |
return &client, nil |
| 671 |
} |
| 672 |
|
| 673 |
// Connection returns a connection to the API service. |
| 674 |
// |
| 675 |
// Deprecated: Connections are now pooled so this method does not always |
| 676 |
// return the same resource. |
| 677 |
func (c *metastoreGRPCClient) Connection() *grpc.ClientConn { |
| 678 |
return c.connPool.Conn() |
| 679 |
} |
| 680 |
|
| 681 |
// setGoogleClientInfo sets the name and version of the application in |
| 682 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 683 |
// use by Google-written clients. |
| 684 |
func (c *metastoreGRPCClient) setGoogleClientInfo(keyval ...string) { |
| 685 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 686 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) |
| 687 |
c.xGoogHeaders = []string{ |
| 688 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
// Close closes the connection to the API service. The user should invoke this when |
| 693 |
// the client is no longer required. |
| 694 |
func (c *metastoreGRPCClient) Close() error { |
| 695 |
return c.connPool.Close() |
| 696 |
} |
| 697 |
|
| 698 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 699 |
type metastoreRESTClient struct { |
| 700 |
// The http endpoint to connect to. |
| 701 |
endpoint string |
| 702 |
|
| 703 |
// The http client. |
| 704 |
httpClient *http.Client |
| 705 |
|
| 706 |
// The x-goog-* headers to be sent with each request. |
| 707 |
xGoogHeaders []string |
| 708 |
|
| 709 |
// Points back to the CallOptions field of the containing MetastoreClient |
| 710 |
CallOptions **MetastoreCallOptions |
| 711 |
|
| 712 |
logger *slog.Logger |
| 713 |
} |
| 714 |
|
| 715 |
// NewMetastoreRESTClient creates a new metastore service rest client. |
| 716 |
// |
| 717 |
// BigLake Metastore is a serverless, highly available, multi-tenant runtime |
| 718 |
// metastore for Google Cloud Data Analytics products. |
| 719 |
// |
| 720 |
// The BigLake Metastore API defines the following resource model: |
| 721 |
// |
| 722 |
// A collection of Google Cloud projects: /projects/* |
| 723 |
// |
| 724 |
// Each project has a collection of available locations: /locations/* |
| 725 |
// |
| 726 |
// Each location has a collection of catalogs: /catalogs/* |
| 727 |
// |
| 728 |
// Each catalog has a collection of databases: /databases/* |
| 729 |
// |
| 730 |
// Each database has a collection of tables: /tables/* |
| 731 |
func NewMetastoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) { |
| 732 |
clientOpts := append(defaultMetastoreRESTClientOptions(), opts...) |
| 733 |
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) |
| 734 |
if err != nil { |
| 735 |
return nil, err |
| 736 |
} |
| 737 |
|
| 738 |
callOpts := defaultMetastoreRESTCallOptions() |
| 739 |
c := &metastoreRESTClient{ |
| 740 |
endpoint: endpoint, |
| 741 |
httpClient: httpClient, |
| 742 |
CallOptions: &callOpts, |
| 743 |
logger: internaloption.GetLogger(opts), |
| 744 |
} |
| 745 |
c.setGoogleClientInfo() |
| 746 |
|
| 747 |
return &MetastoreClient{internalClient: c, CallOptions: callOpts}, nil |
| 748 |
} |
| 749 |
|
| 750 |
func defaultMetastoreRESTClientOptions() []option.ClientOption { |
| 751 |
return []option.ClientOption{ |
| 752 |
internaloption.WithDefaultEndpoint("https://biglake.googleapis.com"), |
| 753 |
internaloption.WithDefaultEndpointTemplate("https://biglake.UNIVERSE_DOMAIN"), |
| 754 |
internaloption.WithDefaultMTLSEndpoint("https://biglake.mtls.googleapis.com"), |
| 755 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 756 |
internaloption.WithDefaultAudience("https://biglake.googleapis.com/"), |
| 757 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 758 |
internaloption.EnableNewAuthLibrary(), |
| 759 |
} |
| 760 |
} |
| 761 |
|
| 762 |
// setGoogleClientInfo sets the name and version of the application in |
| 763 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 764 |
// use by Google-written clients. |
| 765 |
func (c *metastoreRESTClient) setGoogleClientInfo(keyval ...string) { |
| 766 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 767 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) |
| 768 |
c.xGoogHeaders = []string{ |
| 769 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 770 |
} |
| 771 |
} |
| 772 |
|
| 773 |
// Close closes the connection to the API service. The user should invoke this when |
| 774 |
// the client is no longer required. |
| 775 |
func (c *metastoreRESTClient) Close() error { |
| 776 |
// Replace httpClient with nil to force cleanup. |
| 777 |
c.httpClient = nil |
| 778 |
return nil |
| 779 |
} |
| 780 |
|
| 781 |
// Connection returns a connection to the API service. |
| 782 |
// |
| 783 |
// Deprecated: This method always returns nil. |
| 784 |
func (c *metastoreRESTClient) Connection() *grpc.ClientConn { |
| 785 |
return nil |
| 786 |
} |
| 787 |
func (c *metastoreGRPCClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 788 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 789 |
|
| 790 |
hds = append(c.xGoogHeaders, hds...) |
| 791 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 792 |
opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...) |
| 793 |
var resp *biglakepb.Catalog |
| 794 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 795 |
var err error |
| 796 |
resp, err = executeRPC(ctx, c.metastoreClient.CreateCatalog, req, settings.GRPC, c.logger, "CreateCatalog") |
| 797 |
return err |
| 798 |
}, opts...) |
| 799 |
if err != nil { |
| 800 |
return nil, err |
| 801 |
} |
| 802 |
return resp, nil |
| 803 |
} |
| 804 |
|
| 805 |
func (c *metastoreGRPCClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 806 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 807 |
|
| 808 |
hds = append(c.xGoogHeaders, hds...) |
| 809 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 810 |
opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...) |
| 811 |
var resp *biglakepb.Catalog |
| 812 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 813 |
var err error |
| 814 |
resp, err = executeRPC(ctx, c.metastoreClient.DeleteCatalog, req, settings.GRPC, c.logger, "DeleteCatalog") |
| 815 |
return err |
| 816 |
}, opts...) |
| 817 |
if err != nil { |
| 818 |
return nil, err |
| 819 |
} |
| 820 |
return resp, nil |
| 821 |
} |
| 822 |
|
| 823 |
func (c *metastoreGRPCClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 824 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 825 |
|
| 826 |
hds = append(c.xGoogHeaders, hds...) |
| 827 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 828 |
opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...) |
| 829 |
var resp *biglakepb.Catalog |
| 830 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 831 |
var err error |
| 832 |
resp, err = executeRPC(ctx, c.metastoreClient.GetCatalog, req, settings.GRPC, c.logger, "GetCatalog") |
| 833 |
return err |
| 834 |
}, opts...) |
| 835 |
if err != nil { |
| 836 |
return nil, err |
| 837 |
} |
| 838 |
return resp, nil |
| 839 |
} |
| 840 |
|
| 841 |
func (c *metastoreGRPCClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator { |
| 842 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 843 |
|
| 844 |
hds = append(c.xGoogHeaders, hds...) |
| 845 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 846 |
opts = append((*c.CallOptions).ListCatalogs[0:len((*c.CallOptions).ListCatalogs):len((*c.CallOptions).ListCatalogs)], opts...) |
| 847 |
it := &CatalogIterator{} |
| 848 |
req = proto.Clone(req).(*biglakepb.ListCatalogsRequest) |
| 849 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) { |
| 850 |
resp := &biglakepb.ListCatalogsResponse{} |
| 851 |
if pageToken != "" { |
| 852 |
req.PageToken = pageToken |
| 853 |
} |
| 854 |
if pageSize > math.MaxInt32 { |
| 855 |
req.PageSize = math.MaxInt32 |
| 856 |
} else if pageSize != 0 { |
| 857 |
req.PageSize = int32(pageSize) |
| 858 |
} |
| 859 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 860 |
var err error |
| 861 |
resp, err = executeRPC(ctx, c.metastoreClient.ListCatalogs, req, settings.GRPC, c.logger, "ListCatalogs") |
| 862 |
return err |
| 863 |
}, opts...) |
| 864 |
if err != nil { |
| 865 |
return nil, "", err |
| 866 |
} |
| 867 |
|
| 868 |
it.Response = resp |
| 869 |
return resp.GetCatalogs(), resp.GetNextPageToken(), nil |
| 870 |
} |
| 871 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 872 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 873 |
if err != nil { |
| 874 |
return "", err |
| 875 |
} |
| 876 |
it.items = append(it.items, items...) |
| 877 |
return nextPageToken, nil |
| 878 |
} |
| 879 |
|
| 880 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 881 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 882 |
it.pageInfo.Token = req.GetPageToken() |
| 883 |
|
| 884 |
return it |
| 885 |
} |
| 886 |
|
| 887 |
func (c *metastoreGRPCClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 888 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 889 |
|
| 890 |
hds = append(c.xGoogHeaders, hds...) |
| 891 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 892 |
opts = append((*c.CallOptions).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], opts...) |
| 893 |
var resp *biglakepb.Database |
| 894 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 895 |
var err error |
| 896 |
resp, err = executeRPC(ctx, c.metastoreClient.CreateDatabase, req, settings.GRPC, c.logger, "CreateDatabase") |
| 897 |
return err |
| 898 |
}, opts...) |
| 899 |
if err != nil { |
| 900 |
return nil, err |
| 901 |
} |
| 902 |
return resp, nil |
| 903 |
} |
| 904 |
|
| 905 |
func (c *metastoreGRPCClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 906 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 907 |
|
| 908 |
hds = append(c.xGoogHeaders, hds...) |
| 909 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 910 |
opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...) |
| 911 |
var resp *biglakepb.Database |
| 912 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 913 |
var err error |
| 914 |
resp, err = executeRPC(ctx, c.metastoreClient.DeleteDatabase, req, settings.GRPC, c.logger, "DeleteDatabase") |
| 915 |
return err |
| 916 |
}, opts...) |
| 917 |
if err != nil { |
| 918 |
return nil, err |
| 919 |
} |
| 920 |
return resp, nil |
| 921 |
} |
| 922 |
|
| 923 |
func (c *metastoreGRPCClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 924 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))} |
| 925 |
|
| 926 |
hds = append(c.xGoogHeaders, hds...) |
| 927 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 928 |
opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...) |
| 929 |
var resp *biglakepb.Database |
| 930 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 931 |
var err error |
| 932 |
resp, err = executeRPC(ctx, c.metastoreClient.UpdateDatabase, req, settings.GRPC, c.logger, "UpdateDatabase") |
| 933 |
return err |
| 934 |
}, opts...) |
| 935 |
if err != nil { |
| 936 |
return nil, err |
| 937 |
} |
| 938 |
return resp, nil |
| 939 |
} |
| 940 |
|
| 941 |
func (c *metastoreGRPCClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 942 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 943 |
|
| 944 |
hds = append(c.xGoogHeaders, hds...) |
| 945 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 946 |
opts = append((*c.CallOptions).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], opts...) |
| 947 |
var resp *biglakepb.Database |
| 948 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 949 |
var err error |
| 950 |
resp, err = executeRPC(ctx, c.metastoreClient.GetDatabase, req, settings.GRPC, c.logger, "GetDatabase") |
| 951 |
return err |
| 952 |
}, opts...) |
| 953 |
if err != nil { |
| 954 |
return nil, err |
| 955 |
} |
| 956 |
return resp, nil |
| 957 |
} |
| 958 |
|
| 959 |
func (c *metastoreGRPCClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator { |
| 960 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 961 |
|
| 962 |
hds = append(c.xGoogHeaders, hds...) |
| 963 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 964 |
opts = append((*c.CallOptions).ListDatabases[0:len((*c.CallOptions).ListDatabases):len((*c.CallOptions).ListDatabases)], opts...) |
| 965 |
it := &DatabaseIterator{} |
| 966 |
req = proto.Clone(req).(*biglakepb.ListDatabasesRequest) |
| 967 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) { |
| 968 |
resp := &biglakepb.ListDatabasesResponse{} |
| 969 |
if pageToken != "" { |
| 970 |
req.PageToken = pageToken |
| 971 |
} |
| 972 |
if pageSize > math.MaxInt32 { |
| 973 |
req.PageSize = math.MaxInt32 |
| 974 |
} else if pageSize != 0 { |
| 975 |
req.PageSize = int32(pageSize) |
| 976 |
} |
| 977 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 978 |
var err error |
| 979 |
resp, err = executeRPC(ctx, c.metastoreClient.ListDatabases, req, settings.GRPC, c.logger, "ListDatabases") |
| 980 |
return err |
| 981 |
}, opts...) |
| 982 |
if err != nil { |
| 983 |
return nil, "", err |
| 984 |
} |
| 985 |
|
| 986 |
it.Response = resp |
| 987 |
return resp.GetDatabases(), resp.GetNextPageToken(), nil |
| 988 |
} |
| 989 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 990 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 991 |
if err != nil { |
| 992 |
return "", err |
| 993 |
} |
| 994 |
it.items = append(it.items, items...) |
| 995 |
return nextPageToken, nil |
| 996 |
} |
| 997 |
|
| 998 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 999 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1000 |
it.pageInfo.Token = req.GetPageToken() |
| 1001 |
|
| 1002 |
return it |
| 1003 |
} |
| 1004 |
|
| 1005 |
func (c *metastoreGRPCClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, 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).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...) |
| 1011 |
var resp *biglakepb.Table |
| 1012 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1013 |
var err error |
| 1014 |
resp, err = executeRPC(ctx, c.metastoreClient.CreateTable, req, settings.GRPC, c.logger, "CreateTable") |
| 1015 |
return err |
| 1016 |
}, opts...) |
| 1017 |
if err != nil { |
| 1018 |
return nil, err |
| 1019 |
} |
| 1020 |
return resp, nil |
| 1021 |
} |
| 1022 |
|
| 1023 |
func (c *metastoreGRPCClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1024 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1025 |
|
| 1026 |
hds = append(c.xGoogHeaders, hds...) |
| 1027 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1028 |
opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...) |
| 1029 |
var resp *biglakepb.Table |
| 1030 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1031 |
var err error |
| 1032 |
resp, err = executeRPC(ctx, c.metastoreClient.DeleteTable, req, settings.GRPC, c.logger, "DeleteTable") |
| 1033 |
return err |
| 1034 |
}, opts...) |
| 1035 |
if err != nil { |
| 1036 |
return nil, err |
| 1037 |
} |
| 1038 |
return resp, nil |
| 1039 |
} |
| 1040 |
|
| 1041 |
func (c *metastoreGRPCClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1042 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))} |
| 1043 |
|
| 1044 |
hds = append(c.xGoogHeaders, hds...) |
| 1045 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1046 |
opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...) |
| 1047 |
var resp *biglakepb.Table |
| 1048 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1049 |
var err error |
| 1050 |
resp, err = executeRPC(ctx, c.metastoreClient.UpdateTable, req, settings.GRPC, c.logger, "UpdateTable") |
| 1051 |
return err |
| 1052 |
}, opts...) |
| 1053 |
if err != nil { |
| 1054 |
return nil, err |
| 1055 |
} |
| 1056 |
return resp, nil |
| 1057 |
} |
| 1058 |
|
| 1059 |
func (c *metastoreGRPCClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1060 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1061 |
|
| 1062 |
hds = append(c.xGoogHeaders, hds...) |
| 1063 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1064 |
opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...) |
| 1065 |
var resp *biglakepb.Table |
| 1066 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1067 |
var err error |
| 1068 |
resp, err = executeRPC(ctx, c.metastoreClient.RenameTable, req, settings.GRPC, c.logger, "RenameTable") |
| 1069 |
return err |
| 1070 |
}, opts...) |
| 1071 |
if err != nil { |
| 1072 |
return nil, err |
| 1073 |
} |
| 1074 |
return resp, nil |
| 1075 |
} |
| 1076 |
|
| 1077 |
func (c *metastoreGRPCClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1078 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1079 |
|
| 1080 |
hds = append(c.xGoogHeaders, hds...) |
| 1081 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1082 |
opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...) |
| 1083 |
var resp *biglakepb.Table |
| 1084 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1085 |
var err error |
| 1086 |
resp, err = executeRPC(ctx, c.metastoreClient.GetTable, req, settings.GRPC, c.logger, "GetTable") |
| 1087 |
return err |
| 1088 |
}, opts...) |
| 1089 |
if err != nil { |
| 1090 |
return nil, err |
| 1091 |
} |
| 1092 |
return resp, nil |
| 1093 |
} |
| 1094 |
|
| 1095 |
func (c *metastoreGRPCClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator { |
| 1096 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 1097 |
|
| 1098 |
hds = append(c.xGoogHeaders, hds...) |
| 1099 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1100 |
opts = append((*c.CallOptions).ListTables[0:len((*c.CallOptions).ListTables):len((*c.CallOptions).ListTables)], opts...) |
| 1101 |
it := &TableIterator{} |
| 1102 |
req = proto.Clone(req).(*biglakepb.ListTablesRequest) |
| 1103 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) { |
| 1104 |
resp := &biglakepb.ListTablesResponse{} |
| 1105 |
if pageToken != "" { |
| 1106 |
req.PageToken = pageToken |
| 1107 |
} |
| 1108 |
if pageSize > math.MaxInt32 { |
| 1109 |
req.PageSize = math.MaxInt32 |
| 1110 |
} else if pageSize != 0 { |
| 1111 |
req.PageSize = int32(pageSize) |
| 1112 |
} |
| 1113 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1114 |
var err error |
| 1115 |
resp, err = executeRPC(ctx, c.metastoreClient.ListTables, req, settings.GRPC, c.logger, "ListTables") |
| 1116 |
return err |
| 1117 |
}, opts...) |
| 1118 |
if err != nil { |
| 1119 |
return nil, "", err |
| 1120 |
} |
| 1121 |
|
| 1122 |
it.Response = resp |
| 1123 |
return resp.GetTables(), resp.GetNextPageToken(), nil |
| 1124 |
} |
| 1125 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1126 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1127 |
if err != nil { |
| 1128 |
return "", err |
| 1129 |
} |
| 1130 |
it.items = append(it.items, items...) |
| 1131 |
return nextPageToken, nil |
| 1132 |
} |
| 1133 |
|
| 1134 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1135 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1136 |
it.pageInfo.Token = req.GetPageToken() |
| 1137 |
|
| 1138 |
return it |
| 1139 |
} |
| 1140 |
|
| 1141 |
// CreateCatalog creates a new catalog. |
| 1142 |
func (c *metastoreRESTClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 1143 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1144 |
body := req.GetCatalog() |
| 1145 |
jsonReq, err := m.Marshal(body) |
| 1146 |
if err != nil { |
| 1147 |
return nil, err |
| 1148 |
} |
| 1149 |
|
| 1150 |
baseUrl, err := url.Parse(c.endpoint) |
| 1151 |
if err != nil { |
| 1152 |
return nil, err |
| 1153 |
} |
| 1154 |
baseUrl.Path += fmt.Sprintf("/v1/%v/catalogs", req.GetParent()) |
| 1155 |
|
| 1156 |
params := url.Values{} |
| 1157 |
params.Add("$alt", "json;enum-encoding=int") |
| 1158 |
params.Add("catalogId", fmt.Sprintf("%v", req.GetCatalogId())) |
| 1159 |
|
| 1160 |
baseUrl.RawQuery = params.Encode() |
| 1161 |
|
| 1162 |
// Build HTTP headers from client and context metadata. |
| 1163 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 1164 |
|
| 1165 |
hds = append(c.xGoogHeaders, hds...) |
| 1166 |
hds = append(hds, "Content-Type", "application/json") |
| 1167 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1168 |
opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...) |
| 1169 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1170 |
resp := &biglakepb.Catalog{} |
| 1171 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1172 |
if settings.Path != "" { |
| 1173 |
baseUrl.Path = settings.Path |
| 1174 |
} |
| 1175 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1176 |
if err != nil { |
| 1177 |
return err |
| 1178 |
} |
| 1179 |
httpReq = httpReq.WithContext(ctx) |
| 1180 |
httpReq.Header = headers |
| 1181 |
|
| 1182 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCatalog") |
| 1183 |
if err != nil { |
| 1184 |
return err |
| 1185 |
} |
| 1186 |
|
| 1187 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1188 |
return err |
| 1189 |
} |
| 1190 |
|
| 1191 |
return nil |
| 1192 |
}, opts...) |
| 1193 |
if e != nil { |
| 1194 |
return nil, e |
| 1195 |
} |
| 1196 |
return resp, nil |
| 1197 |
} |
| 1198 |
|
| 1199 |
// DeleteCatalog deletes an existing catalog specified by the catalog ID. |
| 1200 |
func (c *metastoreRESTClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 1201 |
baseUrl, err := url.Parse(c.endpoint) |
| 1202 |
if err != nil { |
| 1203 |
return nil, err |
| 1204 |
} |
| 1205 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1206 |
|
| 1207 |
params := url.Values{} |
| 1208 |
params.Add("$alt", "json;enum-encoding=int") |
| 1209 |
|
| 1210 |
baseUrl.RawQuery = params.Encode() |
| 1211 |
|
| 1212 |
// Build HTTP headers from client and context metadata. |
| 1213 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1214 |
|
| 1215 |
hds = append(c.xGoogHeaders, hds...) |
| 1216 |
hds = append(hds, "Content-Type", "application/json") |
| 1217 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1218 |
opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...) |
| 1219 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1220 |
resp := &biglakepb.Catalog{} |
| 1221 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1222 |
if settings.Path != "" { |
| 1223 |
baseUrl.Path = settings.Path |
| 1224 |
} |
| 1225 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 1226 |
if err != nil { |
| 1227 |
return err |
| 1228 |
} |
| 1229 |
httpReq = httpReq.WithContext(ctx) |
| 1230 |
httpReq.Header = headers |
| 1231 |
|
| 1232 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCatalog") |
| 1233 |
if err != nil { |
| 1234 |
return err |
| 1235 |
} |
| 1236 |
|
| 1237 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1238 |
return err |
| 1239 |
} |
| 1240 |
|
| 1241 |
return nil |
| 1242 |
}, opts...) |
| 1243 |
if e != nil { |
| 1244 |
return nil, e |
| 1245 |
} |
| 1246 |
return resp, nil |
| 1247 |
} |
| 1248 |
|
| 1249 |
// GetCatalog gets the catalog specified by the resource name. |
| 1250 |
func (c *metastoreRESTClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) { |
| 1251 |
baseUrl, err := url.Parse(c.endpoint) |
| 1252 |
if err != nil { |
| 1253 |
return nil, err |
| 1254 |
} |
| 1255 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1256 |
|
| 1257 |
params := url.Values{} |
| 1258 |
params.Add("$alt", "json;enum-encoding=int") |
| 1259 |
|
| 1260 |
baseUrl.RawQuery = params.Encode() |
| 1261 |
|
| 1262 |
// Build HTTP headers from client and context metadata. |
| 1263 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1264 |
|
| 1265 |
hds = append(c.xGoogHeaders, hds...) |
| 1266 |
hds = append(hds, "Content-Type", "application/json") |
| 1267 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1268 |
opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...) |
| 1269 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1270 |
resp := &biglakepb.Catalog{} |
| 1271 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1272 |
if settings.Path != "" { |
| 1273 |
baseUrl.Path = settings.Path |
| 1274 |
} |
| 1275 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1276 |
if err != nil { |
| 1277 |
return err |
| 1278 |
} |
| 1279 |
httpReq = httpReq.WithContext(ctx) |
| 1280 |
httpReq.Header = headers |
| 1281 |
|
| 1282 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCatalog") |
| 1283 |
if err != nil { |
| 1284 |
return err |
| 1285 |
} |
| 1286 |
|
| 1287 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1288 |
return err |
| 1289 |
} |
| 1290 |
|
| 1291 |
return nil |
| 1292 |
}, opts...) |
| 1293 |
if e != nil { |
| 1294 |
return nil, e |
| 1295 |
} |
| 1296 |
return resp, nil |
| 1297 |
} |
| 1298 |
|
| 1299 |
// ListCatalogs list all catalogs in a specified project. |
| 1300 |
func (c *metastoreRESTClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator { |
| 1301 |
it := &CatalogIterator{} |
| 1302 |
req = proto.Clone(req).(*biglakepb.ListCatalogsRequest) |
| 1303 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1304 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) { |
| 1305 |
resp := &biglakepb.ListCatalogsResponse{} |
| 1306 |
if pageToken != "" { |
| 1307 |
req.PageToken = pageToken |
| 1308 |
} |
| 1309 |
if pageSize > math.MaxInt32 { |
| 1310 |
req.PageSize = math.MaxInt32 |
| 1311 |
} else if pageSize != 0 { |
| 1312 |
req.PageSize = int32(pageSize) |
| 1313 |
} |
| 1314 |
baseUrl, err := url.Parse(c.endpoint) |
| 1315 |
if err != nil { |
| 1316 |
return nil, "", err |
| 1317 |
} |
| 1318 |
baseUrl.Path += fmt.Sprintf("/v1/%v/catalogs", req.GetParent()) |
| 1319 |
|
| 1320 |
params := url.Values{} |
| 1321 |
params.Add("$alt", "json;enum-encoding=int") |
| 1322 |
if req.GetPageSize() != 0 { |
| 1323 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 1324 |
} |
| 1325 |
if req.GetPageToken() != "" { |
| 1326 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 1327 |
} |
| 1328 |
|
| 1329 |
baseUrl.RawQuery = params.Encode() |
| 1330 |
|
| 1331 |
// Build HTTP headers from client and context metadata. |
| 1332 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 1333 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1334 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1335 |
if settings.Path != "" { |
| 1336 |
baseUrl.Path = settings.Path |
| 1337 |
} |
| 1338 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1339 |
if err != nil { |
| 1340 |
return err |
| 1341 |
} |
| 1342 |
httpReq.Header = headers |
| 1343 |
|
| 1344 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListCatalogs") |
| 1345 |
if err != nil { |
| 1346 |
return err |
| 1347 |
} |
| 1348 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1349 |
return err |
| 1350 |
} |
| 1351 |
|
| 1352 |
return nil |
| 1353 |
}, opts...) |
| 1354 |
if e != nil { |
| 1355 |
return nil, "", e |
| 1356 |
} |
| 1357 |
it.Response = resp |
| 1358 |
return resp.GetCatalogs(), resp.GetNextPageToken(), nil |
| 1359 |
} |
| 1360 |
|
| 1361 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1362 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1363 |
if err != nil { |
| 1364 |
return "", err |
| 1365 |
} |
| 1366 |
it.items = append(it.items, items...) |
| 1367 |
return nextPageToken, nil |
| 1368 |
} |
| 1369 |
|
| 1370 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1371 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1372 |
it.pageInfo.Token = req.GetPageToken() |
| 1373 |
|
| 1374 |
return it |
| 1375 |
} |
| 1376 |
|
| 1377 |
// CreateDatabase creates a new database. |
| 1378 |
func (c *metastoreRESTClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 1379 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1380 |
body := req.GetDatabase() |
| 1381 |
jsonReq, err := m.Marshal(body) |
| 1382 |
if err != nil { |
| 1383 |
return nil, err |
| 1384 |
} |
| 1385 |
|
| 1386 |
baseUrl, err := url.Parse(c.endpoint) |
| 1387 |
if err != nil { |
| 1388 |
return nil, err |
| 1389 |
} |
| 1390 |
baseUrl.Path += fmt.Sprintf("/v1/%v/databases", req.GetParent()) |
| 1391 |
|
| 1392 |
params := url.Values{} |
| 1393 |
params.Add("$alt", "json;enum-encoding=int") |
| 1394 |
params.Add("databaseId", fmt.Sprintf("%v", req.GetDatabaseId())) |
| 1395 |
|
| 1396 |
baseUrl.RawQuery = params.Encode() |
| 1397 |
|
| 1398 |
// Build HTTP headers from client and context metadata. |
| 1399 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 1400 |
|
| 1401 |
hds = append(c.xGoogHeaders, hds...) |
| 1402 |
hds = append(hds, "Content-Type", "application/json") |
| 1403 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1404 |
opts = append((*c.CallOptions).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], opts...) |
| 1405 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1406 |
resp := &biglakepb.Database{} |
| 1407 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1408 |
if settings.Path != "" { |
| 1409 |
baseUrl.Path = settings.Path |
| 1410 |
} |
| 1411 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1412 |
if err != nil { |
| 1413 |
return err |
| 1414 |
} |
| 1415 |
httpReq = httpReq.WithContext(ctx) |
| 1416 |
httpReq.Header = headers |
| 1417 |
|
| 1418 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDatabase") |
| 1419 |
if err != nil { |
| 1420 |
return err |
| 1421 |
} |
| 1422 |
|
| 1423 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1424 |
return err |
| 1425 |
} |
| 1426 |
|
| 1427 |
return nil |
| 1428 |
}, opts...) |
| 1429 |
if e != nil { |
| 1430 |
return nil, e |
| 1431 |
} |
| 1432 |
return resp, nil |
| 1433 |
} |
| 1434 |
|
| 1435 |
// DeleteDatabase deletes an existing database specified by the database ID. |
| 1436 |
func (c *metastoreRESTClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 1437 |
baseUrl, err := url.Parse(c.endpoint) |
| 1438 |
if err != nil { |
| 1439 |
return nil, err |
| 1440 |
} |
| 1441 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1442 |
|
| 1443 |
params := url.Values{} |
| 1444 |
params.Add("$alt", "json;enum-encoding=int") |
| 1445 |
|
| 1446 |
baseUrl.RawQuery = params.Encode() |
| 1447 |
|
| 1448 |
// Build HTTP headers from client and context metadata. |
| 1449 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1450 |
|
| 1451 |
hds = append(c.xGoogHeaders, hds...) |
| 1452 |
hds = append(hds, "Content-Type", "application/json") |
| 1453 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1454 |
opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...) |
| 1455 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1456 |
resp := &biglakepb.Database{} |
| 1457 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1458 |
if settings.Path != "" { |
| 1459 |
baseUrl.Path = settings.Path |
| 1460 |
} |
| 1461 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 1462 |
if err != nil { |
| 1463 |
return err |
| 1464 |
} |
| 1465 |
httpReq = httpReq.WithContext(ctx) |
| 1466 |
httpReq.Header = headers |
| 1467 |
|
| 1468 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDatabase") |
| 1469 |
if err != nil { |
| 1470 |
return err |
| 1471 |
} |
| 1472 |
|
| 1473 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1474 |
return err |
| 1475 |
} |
| 1476 |
|
| 1477 |
return nil |
| 1478 |
}, opts...) |
| 1479 |
if e != nil { |
| 1480 |
return nil, e |
| 1481 |
} |
| 1482 |
return resp, nil |
| 1483 |
} |
| 1484 |
|
| 1485 |
// UpdateDatabase updates an existing database specified by the database ID. |
| 1486 |
func (c *metastoreRESTClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 1487 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1488 |
body := req.GetDatabase() |
| 1489 |
jsonReq, err := m.Marshal(body) |
| 1490 |
if err != nil { |
| 1491 |
return nil, err |
| 1492 |
} |
| 1493 |
|
| 1494 |
baseUrl, err := url.Parse(c.endpoint) |
| 1495 |
if err != nil { |
| 1496 |
return nil, err |
| 1497 |
} |
| 1498 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetDatabase().GetName()) |
| 1499 |
|
| 1500 |
params := url.Values{} |
| 1501 |
params.Add("$alt", "json;enum-encoding=int") |
| 1502 |
if req.GetUpdateMask() != nil { |
| 1503 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 1504 |
if err != nil { |
| 1505 |
return nil, err |
| 1506 |
} |
| 1507 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 1508 |
} |
| 1509 |
|
| 1510 |
baseUrl.RawQuery = params.Encode() |
| 1511 |
|
| 1512 |
// Build HTTP headers from client and context metadata. |
| 1513 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))} |
| 1514 |
|
| 1515 |
hds = append(c.xGoogHeaders, hds...) |
| 1516 |
hds = append(hds, "Content-Type", "application/json") |
| 1517 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1518 |
opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...) |
| 1519 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1520 |
resp := &biglakepb.Database{} |
| 1521 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1522 |
if settings.Path != "" { |
| 1523 |
baseUrl.Path = settings.Path |
| 1524 |
} |
| 1525 |
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1526 |
if err != nil { |
| 1527 |
return err |
| 1528 |
} |
| 1529 |
httpReq = httpReq.WithContext(ctx) |
| 1530 |
httpReq.Header = headers |
| 1531 |
|
| 1532 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDatabase") |
| 1533 |
if err != nil { |
| 1534 |
return err |
| 1535 |
} |
| 1536 |
|
| 1537 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1538 |
return err |
| 1539 |
} |
| 1540 |
|
| 1541 |
return nil |
| 1542 |
}, opts...) |
| 1543 |
if e != nil { |
| 1544 |
return nil, e |
| 1545 |
} |
| 1546 |
return resp, nil |
| 1547 |
} |
| 1548 |
|
| 1549 |
// GetDatabase gets the database specified by the resource name. |
| 1550 |
func (c *metastoreRESTClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) { |
| 1551 |
baseUrl, err := url.Parse(c.endpoint) |
| 1552 |
if err != nil { |
| 1553 |
return nil, err |
| 1554 |
} |
| 1555 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1556 |
|
| 1557 |
params := url.Values{} |
| 1558 |
params.Add("$alt", "json;enum-encoding=int") |
| 1559 |
|
| 1560 |
baseUrl.RawQuery = params.Encode() |
| 1561 |
|
| 1562 |
// Build HTTP headers from client and context metadata. |
| 1563 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1564 |
|
| 1565 |
hds = append(c.xGoogHeaders, hds...) |
| 1566 |
hds = append(hds, "Content-Type", "application/json") |
| 1567 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1568 |
opts = append((*c.CallOptions).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], opts...) |
| 1569 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1570 |
resp := &biglakepb.Database{} |
| 1571 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1572 |
if settings.Path != "" { |
| 1573 |
baseUrl.Path = settings.Path |
| 1574 |
} |
| 1575 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1576 |
if err != nil { |
| 1577 |
return err |
| 1578 |
} |
| 1579 |
httpReq = httpReq.WithContext(ctx) |
| 1580 |
httpReq.Header = headers |
| 1581 |
|
| 1582 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDatabase") |
| 1583 |
if err != nil { |
| 1584 |
return err |
| 1585 |
} |
| 1586 |
|
| 1587 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1588 |
return err |
| 1589 |
} |
| 1590 |
|
| 1591 |
return nil |
| 1592 |
}, opts...) |
| 1593 |
if e != nil { |
| 1594 |
return nil, e |
| 1595 |
} |
| 1596 |
return resp, nil |
| 1597 |
} |
| 1598 |
|
| 1599 |
// ListDatabases list all databases in a specified catalog. |
| 1600 |
func (c *metastoreRESTClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator { |
| 1601 |
it := &DatabaseIterator{} |
| 1602 |
req = proto.Clone(req).(*biglakepb.ListDatabasesRequest) |
| 1603 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1604 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) { |
| 1605 |
resp := &biglakepb.ListDatabasesResponse{} |
| 1606 |
if pageToken != "" { |
| 1607 |
req.PageToken = pageToken |
| 1608 |
} |
| 1609 |
if pageSize > math.MaxInt32 { |
| 1610 |
req.PageSize = math.MaxInt32 |
| 1611 |
} else if pageSize != 0 { |
| 1612 |
req.PageSize = int32(pageSize) |
| 1613 |
} |
| 1614 |
baseUrl, err := url.Parse(c.endpoint) |
| 1615 |
if err != nil { |
| 1616 |
return nil, "", err |
| 1617 |
} |
| 1618 |
baseUrl.Path += fmt.Sprintf("/v1/%v/databases", req.GetParent()) |
| 1619 |
|
| 1620 |
params := url.Values{} |
| 1621 |
params.Add("$alt", "json;enum-encoding=int") |
| 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 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDatabases") |
| 1645 |
if err != nil { |
| 1646 |
return err |
| 1647 |
} |
| 1648 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1649 |
return err |
| 1650 |
} |
| 1651 |
|
| 1652 |
return nil |
| 1653 |
}, opts...) |
| 1654 |
if e != nil { |
| 1655 |
return nil, "", e |
| 1656 |
} |
| 1657 |
it.Response = resp |
| 1658 |
return resp.GetDatabases(), resp.GetNextPageToken(), nil |
| 1659 |
} |
| 1660 |
|
| 1661 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1662 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1663 |
if err != nil { |
| 1664 |
return "", err |
| 1665 |
} |
| 1666 |
it.items = append(it.items, items...) |
| 1667 |
return nextPageToken, nil |
| 1668 |
} |
| 1669 |
|
| 1670 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1671 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1672 |
it.pageInfo.Token = req.GetPageToken() |
| 1673 |
|
| 1674 |
return it |
| 1675 |
} |
| 1676 |
|
| 1677 |
// CreateTable creates a new table. |
| 1678 |
func (c *metastoreRESTClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1679 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1680 |
body := req.GetTable() |
| 1681 |
jsonReq, err := m.Marshal(body) |
| 1682 |
if err != nil { |
| 1683 |
return nil, err |
| 1684 |
} |
| 1685 |
|
| 1686 |
baseUrl, err := url.Parse(c.endpoint) |
| 1687 |
if err != nil { |
| 1688 |
return nil, err |
| 1689 |
} |
| 1690 |
baseUrl.Path += fmt.Sprintf("/v1/%v/tables", req.GetParent()) |
| 1691 |
|
| 1692 |
params := url.Values{} |
| 1693 |
params.Add("$alt", "json;enum-encoding=int") |
| 1694 |
params.Add("tableId", fmt.Sprintf("%v", req.GetTableId())) |
| 1695 |
|
| 1696 |
baseUrl.RawQuery = params.Encode() |
| 1697 |
|
| 1698 |
// Build HTTP headers from client and context metadata. |
| 1699 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 1700 |
|
| 1701 |
hds = append(c.xGoogHeaders, hds...) |
| 1702 |
hds = append(hds, "Content-Type", "application/json") |
| 1703 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1704 |
opts = append((*c.CallOptions).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...) |
| 1705 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1706 |
resp := &biglakepb.Table{} |
| 1707 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1708 |
if settings.Path != "" { |
| 1709 |
baseUrl.Path = settings.Path |
| 1710 |
} |
| 1711 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1712 |
if err != nil { |
| 1713 |
return err |
| 1714 |
} |
| 1715 |
httpReq = httpReq.WithContext(ctx) |
| 1716 |
httpReq.Header = headers |
| 1717 |
|
| 1718 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTable") |
| 1719 |
if err != nil { |
| 1720 |
return err |
| 1721 |
} |
| 1722 |
|
| 1723 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1724 |
return err |
| 1725 |
} |
| 1726 |
|
| 1727 |
return nil |
| 1728 |
}, opts...) |
| 1729 |
if e != nil { |
| 1730 |
return nil, e |
| 1731 |
} |
| 1732 |
return resp, nil |
| 1733 |
} |
| 1734 |
|
| 1735 |
// DeleteTable deletes an existing table specified by the table ID. |
| 1736 |
func (c *metastoreRESTClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1737 |
baseUrl, err := url.Parse(c.endpoint) |
| 1738 |
if err != nil { |
| 1739 |
return nil, err |
| 1740 |
} |
| 1741 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1742 |
|
| 1743 |
params := url.Values{} |
| 1744 |
params.Add("$alt", "json;enum-encoding=int") |
| 1745 |
|
| 1746 |
baseUrl.RawQuery = params.Encode() |
| 1747 |
|
| 1748 |
// Build HTTP headers from client and context metadata. |
| 1749 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1750 |
|
| 1751 |
hds = append(c.xGoogHeaders, hds...) |
| 1752 |
hds = append(hds, "Content-Type", "application/json") |
| 1753 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1754 |
opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...) |
| 1755 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1756 |
resp := &biglakepb.Table{} |
| 1757 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1758 |
if settings.Path != "" { |
| 1759 |
baseUrl.Path = settings.Path |
| 1760 |
} |
| 1761 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 1762 |
if err != nil { |
| 1763 |
return err |
| 1764 |
} |
| 1765 |
httpReq = httpReq.WithContext(ctx) |
| 1766 |
httpReq.Header = headers |
| 1767 |
|
| 1768 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTable") |
| 1769 |
if err != nil { |
| 1770 |
return err |
| 1771 |
} |
| 1772 |
|
| 1773 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1774 |
return err |
| 1775 |
} |
| 1776 |
|
| 1777 |
return nil |
| 1778 |
}, opts...) |
| 1779 |
if e != nil { |
| 1780 |
return nil, e |
| 1781 |
} |
| 1782 |
return resp, nil |
| 1783 |
} |
| 1784 |
|
| 1785 |
// UpdateTable updates an existing table specified by the table ID. |
| 1786 |
func (c *metastoreRESTClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1787 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1788 |
body := req.GetTable() |
| 1789 |
jsonReq, err := m.Marshal(body) |
| 1790 |
if err != nil { |
| 1791 |
return nil, err |
| 1792 |
} |
| 1793 |
|
| 1794 |
baseUrl, err := url.Parse(c.endpoint) |
| 1795 |
if err != nil { |
| 1796 |
return nil, err |
| 1797 |
} |
| 1798 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetTable().GetName()) |
| 1799 |
|
| 1800 |
params := url.Values{} |
| 1801 |
params.Add("$alt", "json;enum-encoding=int") |
| 1802 |
if req.GetUpdateMask() != nil { |
| 1803 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 1804 |
if err != nil { |
| 1805 |
return nil, err |
| 1806 |
} |
| 1807 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 1808 |
} |
| 1809 |
|
| 1810 |
baseUrl.RawQuery = params.Encode() |
| 1811 |
|
| 1812 |
// Build HTTP headers from client and context metadata. |
| 1813 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))} |
| 1814 |
|
| 1815 |
hds = append(c.xGoogHeaders, hds...) |
| 1816 |
hds = append(hds, "Content-Type", "application/json") |
| 1817 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1818 |
opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...) |
| 1819 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1820 |
resp := &biglakepb.Table{} |
| 1821 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1822 |
if settings.Path != "" { |
| 1823 |
baseUrl.Path = settings.Path |
| 1824 |
} |
| 1825 |
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1826 |
if err != nil { |
| 1827 |
return err |
| 1828 |
} |
| 1829 |
httpReq = httpReq.WithContext(ctx) |
| 1830 |
httpReq.Header = headers |
| 1831 |
|
| 1832 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTable") |
| 1833 |
if err != nil { |
| 1834 |
return err |
| 1835 |
} |
| 1836 |
|
| 1837 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1838 |
return err |
| 1839 |
} |
| 1840 |
|
| 1841 |
return nil |
| 1842 |
}, opts...) |
| 1843 |
if e != nil { |
| 1844 |
return nil, e |
| 1845 |
} |
| 1846 |
return resp, nil |
| 1847 |
} |
| 1848 |
|
| 1849 |
// RenameTable renames an existing table specified by the table ID. |
| 1850 |
func (c *metastoreRESTClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1851 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1852 |
jsonReq, err := m.Marshal(req) |
| 1853 |
if err != nil { |
| 1854 |
return nil, err |
| 1855 |
} |
| 1856 |
|
| 1857 |
baseUrl, err := url.Parse(c.endpoint) |
| 1858 |
if err != nil { |
| 1859 |
return nil, err |
| 1860 |
} |
| 1861 |
baseUrl.Path += fmt.Sprintf("/v1/%v:rename", req.GetName()) |
| 1862 |
|
| 1863 |
params := url.Values{} |
| 1864 |
params.Add("$alt", "json;enum-encoding=int") |
| 1865 |
|
| 1866 |
baseUrl.RawQuery = params.Encode() |
| 1867 |
|
| 1868 |
// Build HTTP headers from client and context metadata. |
| 1869 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1870 |
|
| 1871 |
hds = append(c.xGoogHeaders, hds...) |
| 1872 |
hds = append(hds, "Content-Type", "application/json") |
| 1873 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1874 |
opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...) |
| 1875 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1876 |
resp := &biglakepb.Table{} |
| 1877 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1878 |
if settings.Path != "" { |
| 1879 |
baseUrl.Path = settings.Path |
| 1880 |
} |
| 1881 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1882 |
if err != nil { |
| 1883 |
return err |
| 1884 |
} |
| 1885 |
httpReq = httpReq.WithContext(ctx) |
| 1886 |
httpReq.Header = headers |
| 1887 |
|
| 1888 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RenameTable") |
| 1889 |
if err != nil { |
| 1890 |
return err |
| 1891 |
} |
| 1892 |
|
| 1893 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1894 |
return err |
| 1895 |
} |
| 1896 |
|
| 1897 |
return nil |
| 1898 |
}, opts...) |
| 1899 |
if e != nil { |
| 1900 |
return nil, e |
| 1901 |
} |
| 1902 |
return resp, nil |
| 1903 |
} |
| 1904 |
|
| 1905 |
// GetTable gets the table specified by the resource name. |
| 1906 |
func (c *metastoreRESTClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) { |
| 1907 |
baseUrl, err := url.Parse(c.endpoint) |
| 1908 |
if err != nil { |
| 1909 |
return nil, err |
| 1910 |
} |
| 1911 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 1912 |
|
| 1913 |
params := url.Values{} |
| 1914 |
params.Add("$alt", "json;enum-encoding=int") |
| 1915 |
|
| 1916 |
baseUrl.RawQuery = params.Encode() |
| 1917 |
|
| 1918 |
// Build HTTP headers from client and context metadata. |
| 1919 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 1920 |
|
| 1921 |
hds = append(c.xGoogHeaders, hds...) |
| 1922 |
hds = append(hds, "Content-Type", "application/json") |
| 1923 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1924 |
opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...) |
| 1925 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1926 |
resp := &biglakepb.Table{} |
| 1927 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1928 |
if settings.Path != "" { |
| 1929 |
baseUrl.Path = settings.Path |
| 1930 |
} |
| 1931 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1932 |
if err != nil { |
| 1933 |
return err |
| 1934 |
} |
| 1935 |
httpReq = httpReq.WithContext(ctx) |
| 1936 |
httpReq.Header = headers |
| 1937 |
|
| 1938 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTable") |
| 1939 |
if err != nil { |
| 1940 |
return err |
| 1941 |
} |
| 1942 |
|
| 1943 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1944 |
return err |
| 1945 |
} |
| 1946 |
|
| 1947 |
return nil |
| 1948 |
}, opts...) |
| 1949 |
if e != nil { |
| 1950 |
return nil, e |
| 1951 |
} |
| 1952 |
return resp, nil |
| 1953 |
} |
| 1954 |
|
| 1955 |
// ListTables list all tables in a specified database. |
| 1956 |
func (c *metastoreRESTClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator { |
| 1957 |
it := &TableIterator{} |
| 1958 |
req = proto.Clone(req).(*biglakepb.ListTablesRequest) |
| 1959 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1960 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) { |
| 1961 |
resp := &biglakepb.ListTablesResponse{} |
| 1962 |
if pageToken != "" { |
| 1963 |
req.PageToken = pageToken |
| 1964 |
} |
| 1965 |
if pageSize > math.MaxInt32 { |
| 1966 |
req.PageSize = math.MaxInt32 |
| 1967 |
} else if pageSize != 0 { |
| 1968 |
req.PageSize = int32(pageSize) |
| 1969 |
} |
| 1970 |
baseUrl, err := url.Parse(c.endpoint) |
| 1971 |
if err != nil { |
| 1972 |
return nil, "", err |
| 1973 |
} |
| 1974 |
baseUrl.Path += fmt.Sprintf("/v1/%v/tables", req.GetParent()) |
| 1975 |
|
| 1976 |
params := url.Values{} |
| 1977 |
params.Add("$alt", "json;enum-encoding=int") |
| 1978 |
if req.GetPageSize() != 0 { |
| 1979 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 1980 |
} |
| 1981 |
if req.GetPageToken() != "" { |
| 1982 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 1983 |
} |
| 1984 |
if req.GetView() != 0 { |
| 1985 |
params.Add("view", fmt.Sprintf("%v", req.GetView())) |
| 1986 |
} |
| 1987 |
|
| 1988 |
baseUrl.RawQuery = params.Encode() |
| 1989 |
|
| 1990 |
// Build HTTP headers from client and context metadata. |
| 1991 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 1992 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1993 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1994 |
if settings.Path != "" { |
| 1995 |
baseUrl.Path = settings.Path |
| 1996 |
} |
| 1997 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1998 |
if err != nil { |
| 1999 |
return err |
| 2000 |
} |
| 2001 |
httpReq.Header = headers |
| 2002 |
|
| 2003 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTables") |
| 2004 |
if err != nil { |
| 2005 |
return err |
| 2006 |
} |
| 2007 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2008 |
return err |
| 2009 |
} |
| 2010 |
|
| 2011 |
return nil |
| 2012 |
}, opts...) |
| 2013 |
if e != nil { |
| 2014 |
return nil, "", e |
| 2015 |
} |
| 2016 |
it.Response = resp |
| 2017 |
return resp.GetTables(), resp.GetNextPageToken(), nil |
| 2018 |
} |
| 2019 |
|
| 2020 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 2021 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 2022 |
if err != nil { |
| 2023 |
return "", err |
| 2024 |
} |
| 2025 |
it.items = append(it.items, items...) |
| 2026 |
return nextPageToken, nil |
| 2027 |
} |
| 2028 |
|
| 2029 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 2030 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 2031 |
it.pageInfo.Token = req.GetPageToken() |
| 2032 |
|
| 2033 |
return it |
| 2034 |
} |