-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathBigtableClient.php
More file actions
737 lines (699 loc) · 29.9 KB
/
Copy pathBigtableClient.php
File metadata and controls
737 lines (699 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* GENERATED CODE WARNING
* Generated by gapic-generator-php from the file
* https://github.com/googleapis/googleapis/blob/master/google/bigtable/v2/bigtable.proto
* Updates to the above are reflected here through a refresh process.
*/
namespace Google\Cloud\Bigtable\V2\Client;
use Google\ApiCore\ApiException;
use Google\ApiCore\BidiStream;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\InsecureCredentialsWrapper;
use Google\ApiCore\Options\ClientOptions;
use Google\ApiCore\ResourceHelperTrait;
use Google\ApiCore\RetrySettings;
use Google\ApiCore\ServerStream;
use Google\ApiCore\Transport\TransportInterface;
use Google\ApiCore\ValidationException;
use Google\Auth\FetchAuthTokenInterface;
use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest;
use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse;
use Google\Cloud\Bigtable\V2\ClientConfiguration;
use Google\Cloud\Bigtable\V2\ExecuteQueryRequest;
use Google\Cloud\Bigtable\V2\ExecuteQueryResponse;
use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsRequest;
use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsResponse;
use Google\Cloud\Bigtable\V2\GetClientConfigurationRequest;
use Google\Cloud\Bigtable\V2\MutateRowRequest;
use Google\Cloud\Bigtable\V2\MutateRowResponse;
use Google\Cloud\Bigtable\V2\MutateRowsRequest;
use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry;
use Google\Cloud\Bigtable\V2\MutateRowsResponse;
use Google\Cloud\Bigtable\V2\Mutation;
use Google\Cloud\Bigtable\V2\PingAndWarmRequest;
use Google\Cloud\Bigtable\V2\PingAndWarmResponse;
use Google\Cloud\Bigtable\V2\PrepareQueryRequest;
use Google\Cloud\Bigtable\V2\PrepareQueryResponse;
use Google\Cloud\Bigtable\V2\ReadChangeStreamRequest;
use Google\Cloud\Bigtable\V2\ReadChangeStreamResponse;
use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest;
use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse;
use Google\Cloud\Bigtable\V2\ReadRowsRequest;
use Google\Cloud\Bigtable\V2\ReadRowsResponse;
use Google\Cloud\Bigtable\V2\SampleRowKeysRequest;
use Google\Cloud\Bigtable\V2\SampleRowKeysResponse;
use Grpc\ChannelCredentials;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Log\LoggerInterface;
/**
* Service Description: Service for reading from and writing to existing Bigtable tables.
*
* This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods.
*
* Many parameters require resource names to be formatted in a particular way. To
* assist with these names, this class includes a format method for each type of
* name, and additionally a parseName method to extract the individual identifiers
* contained within formatted names that are returned by the API.
*
* @method PromiseInterface<CheckAndMutateRowResponse> checkAndMutateRowAsync(CheckAndMutateRowRequest $request, array $optionalArgs = [])
* @method PromiseInterface<ClientConfiguration> getClientConfigurationAsync(GetClientConfigurationRequest $request, array $optionalArgs = [])
* @method PromiseInterface<MutateRowResponse> mutateRowAsync(MutateRowRequest $request, array $optionalArgs = [])
* @method PromiseInterface<PingAndWarmResponse> pingAndWarmAsync(PingAndWarmRequest $request, array $optionalArgs = [])
* @method PromiseInterface<PrepareQueryResponse> prepareQueryAsync(PrepareQueryRequest $request, array $optionalArgs = [])
* @method PromiseInterface<ReadModifyWriteRowResponse> readModifyWriteRowAsync(ReadModifyWriteRowRequest $request, array $optionalArgs = [])
*/
final class BigtableClient
{
use GapicClientTrait;
use ResourceHelperTrait;
/** The name of the service. */
private const SERVICE_NAME = 'google.bigtable.v2.Bigtable';
/**
* The default address of the service.
*
* @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
*/
private const SERVICE_ADDRESS = 'bigtable.googleapis.com';
/** The address template of the service. */
private const SERVICE_ADDRESS_TEMPLATE = 'bigtable.UNIVERSE_DOMAIN';
/** The default port of the service. */
private const DEFAULT_SERVICE_PORT = 443;
/** The name of the code generator, to be included in the agent header. */
private const CODEGEN_NAME = 'gapic';
/** The default scopes required by the service. */
public static $serviceScopes = [
'https://www.googleapis.com/auth/bigtable.data',
'https://www.googleapis.com/auth/bigtable.data.readonly',
'https://www.googleapis.com/auth/cloud-bigtable.data',
'https://www.googleapis.com/auth/cloud-bigtable.data.readonly',
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/cloud-platform.read-only',
];
private static function getClientDefaults()
{
return [
'serviceName' => self::SERVICE_NAME,
'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
'clientConfig' => __DIR__ . '/../resources/bigtable_client_config.json',
'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_descriptor_config.php',
'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_grpc_config.json',
'credentialsConfig' => [
'defaultScopes' => self::$serviceScopes,
],
'transportConfig' => [
'rest' => [
'restClientConfigPath' => __DIR__ . '/../resources/bigtable_rest_client_config.php',
],
],
];
}
/**
* Formats a string containing the fully-qualified path to represent a
* authorized_view resource.
*
* @param string $project
* @param string $instance
* @param string $table
* @param string $authorizedView
*
* @return string The formatted authorized_view resource.
*/
public static function authorizedViewName(string $project, string $instance, string $table, string $authorizedView): string
{
return self::getPathTemplate('authorizedView')->render([
'project' => $project,
'instance' => $instance,
'table' => $table,
'authorized_view' => $authorizedView,
]);
}
/**
* Formats a string containing the fully-qualified path to represent a instance
* resource.
*
* @param string $project
* @param string $instance
*
* @return string The formatted instance resource.
*/
public static function instanceName(string $project, string $instance): string
{
return self::getPathTemplate('instance')->render([
'project' => $project,
'instance' => $instance,
]);
}
/**
* Formats a string containing the fully-qualified path to represent a
* materialized_view resource.
*
* @param string $project
* @param string $instance
* @param string $materializedView
*
* @return string The formatted materialized_view resource.
*/
public static function materializedViewName(string $project, string $instance, string $materializedView): string
{
return self::getPathTemplate('materializedView')->render([
'project' => $project,
'instance' => $instance,
'materialized_view' => $materializedView,
]);
}
/**
* Formats a string containing the fully-qualified path to represent a table
* resource.
*
* @param string $project
* @param string $instance
* @param string $table
*
* @return string The formatted table resource.
*/
public static function tableName(string $project, string $instance, string $table): string
{
return self::getPathTemplate('table')->render([
'project' => $project,
'instance' => $instance,
'table' => $table,
]);
}
/**
* Parses a formatted name string and returns an associative array of the components in the name.
* The following name formats are supported:
* Template: Pattern
* - authorizedView: projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}
* - instance: projects/{project}/instances/{instance}
* - materializedView: projects/{project}/instances/{instance}/materializedViews/{materialized_view}
* - table: projects/{project}/instances/{instance}/tables/{table}
*
* The optional $template argument can be supplied to specify a particular pattern,
* and must match one of the templates listed above. If no $template argument is
* provided, or if the $template argument does not match one of the templates
* listed, then parseName will check each of the supported templates, and return
* the first match.
*
* @param string $formattedName The formatted name string
* @param ?string $template Optional name of template to match
*
* @return array An associative array from name component IDs to component values.
*
* @throws ValidationException If $formattedName could not be matched.
*/
public static function parseName(string $formattedName, ?string $template = null): array
{
return self::parseFormattedName($formattedName, $template);
}
/**
* Constructor.
*
* Setting the "BIGTABLE_EMULATOR_HOST" environment variable will automatically set
* the API Endpoint to the value specified in the variable, as well as ensure that
* empty credentials are used in the transport layer.
*
* @param array|ClientOptions $options {
* Optional. Options for configuring the service API wrapper.
*
* @type string $apiEndpoint
* The address of the API remote host. May optionally include the port, formatted
* as "<uri>:<port>". Default 'bigtable.googleapis.com:443'.
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
* This option should only be used with a pre-constructed
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
* when one of these objects are provided, any settings in $credentialsConfig will
* be ignored.
* **Important**: If you are providing a path to a credentials file, or a decoded
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
* unvalidated credential configuration to Google APIs can compromise the security
* of your systems and data. It is recommended to create the credentials explicitly
* ```
* use Google\Auth\Credentials\ServiceAccountCredentials;
* use Google\Cloud\Bigtable\V2\BigtableClient;
* $creds = new ServiceAccountCredentials($scopes, $json);
* $options = new BigtableClient(['credentials' => $creds]);
* ```
* {@see
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
* @type array $credentialsConfig
* Options used to configure credentials, including auth token caching, for the
* client. For a full list of supporting configuration options, see
* {@see \Google\ApiCore\CredentialsWrapper::build()} .
* @type bool $disableRetries
* Determines whether or not retries defined by the client configuration should be
* disabled. Defaults to `false`.
* @type string|array $clientConfig
* Client method configuration, including retry settings. This option can be either
* a path to a JSON file, or a PHP array containing the decoded JSON data. By
* default this settings points to the default client config file, which is
* provided in the resources folder.
* @type string|TransportInterface $transport
* The transport used for executing network requests. May be either the string
* `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system.
* *Advanced usage*: Additionally, it is possible to pass in an already
* instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note
* that when this object is provided, any settings in $transportConfig, and any
* $apiEndpoint setting, will be ignored.
* @type array $transportConfig
* Configuration options that will be used to construct the transport. Options for
* each supported transport type should be passed in a key for that transport. For
* example:
* $transportConfig = [
* 'grpc' => [...],
* 'rest' => [...],
* ];
* See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and
* {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the
* supported options.
* @type callable $clientCertSource
* A callable which returns the client cert as a string. This can be used to
* provide a certificate and private key to the transport layer for mTLS.
* @type false|LoggerInterface $logger
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
* @type string $universeDomain
* The service domain for the client. Defaults to 'googleapis.com'.
* }
*
* @throws ValidationException
*/
public function __construct(array|ClientOptions $options = [])
{
$options = $this->setDefaultEmulatorConfig($options);
$clientOptions = $this->buildClientOptions($options);
$this->setClientOptions($clientOptions);
}
/** Handles execution of the async variants for each documented method. */
public function __call($method, $args)
{
if (substr($method, -5) !== 'Async') {
trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR);
}
array_unshift($args, substr($method, 0, -5));
return call_user_func_array([$this, 'startAsyncCall'], $args);
}
/**
* Mutates a row atomically based on the output of a predicate Reader filter.
*
* The async variant is {@see BigtableClient::checkAndMutateRowAsync()} .
*
* @example samples/V2/BigtableClient/check_and_mutate_row.php
*
* @param CheckAndMutateRowRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return CheckAndMutateRowResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function checkAndMutateRow(CheckAndMutateRowRequest $request, array $callOptions = []): CheckAndMutateRowResponse
{
return $this->startApiCall('CheckAndMutateRow', $request, $callOptions)->wait();
}
/**
* Executes a SQL query against a particular Bigtable instance.
*
* @example samples/V2/BigtableClient/execute_query.php
*
* @param ExecuteQueryRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<ExecuteQueryResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function executeQuery(ExecuteQueryRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('ExecuteQuery', $request, $callOptions);
}
/**
* Returns the current list of partitions that make up the table's
* change stream. The union of partitions will cover the entire keyspace.
* Partitions can be read with `ReadChangeStream`.
* NOTE: This API is only intended to be used by Apache Beam BigtableIO.
*
* @example samples/V2/BigtableClient/generate_initial_change_stream_partitions.php
*
* @param GenerateInitialChangeStreamPartitionsRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<GenerateInitialChangeStreamPartitionsResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function generateInitialChangeStreamPartitions(GenerateInitialChangeStreamPartitionsRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('GenerateInitialChangeStreamPartitions', $request, $callOptions);
}
/**
* This RPC is only intended to be used by the official Cloud Bigtable client
* libraries to implement the Bigtable Session based protocol. It is subject
* to change without notice.
*
* The async variant is {@see BigtableClient::getClientConfigurationAsync()} .
*
* @example samples/V2/BigtableClient/get_client_configuration.php
*
* @param GetClientConfigurationRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return ClientConfiguration
*
* @throws ApiException Thrown if the API call fails.
*/
public function getClientConfiguration(GetClientConfigurationRequest $request, array $callOptions = []): ClientConfiguration
{
return $this->startApiCall('GetClientConfiguration', $request, $callOptions)->wait();
}
/**
* Mutates a row atomically. Cells already present in the row are left
* unchanged unless explicitly changed by `mutation`.
*
* The async variant is {@see BigtableClient::mutateRowAsync()} .
*
* @example samples/V2/BigtableClient/mutate_row.php
*
* @param MutateRowRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return MutateRowResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function mutateRow(MutateRowRequest $request, array $callOptions = []): MutateRowResponse
{
return $this->startApiCall('MutateRow', $request, $callOptions)->wait();
}
/**
* Mutates multiple rows in a batch. Each individual row is mutated
* atomically as in MutateRow, but the entire batch is not executed
* atomically.
*
* @example samples/V2/BigtableClient/mutate_rows.php
*
* @param MutateRowsRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<MutateRowsResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function mutateRows(MutateRowsRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('MutateRows', $request, $callOptions);
}
/**
* This RPC is only intended to be used by the official Cloud Bigtable client
* libraries to implement the Bigtable Session based protocol. It is subject
* to change without notice.
*
* @example samples/V2/BigtableClient/open_authorized_view.php
*
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*/
public function openAuthorizedView(array $callOptions = []): BidiStream
{
return $this->startApiCall('OpenAuthorizedView', null, $callOptions);
}
/**
* This RPC is only intended to be used by the official Cloud Bigtable client
* libraries to implement the Bigtable Session based protocol. It is subject
* to change without notice.
*
* @example samples/V2/BigtableClient/open_materialized_view.php
*
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*/
public function openMaterializedView(array $callOptions = []): BidiStream
{
return $this->startApiCall('OpenMaterializedView', null, $callOptions);
}
/**
* This RPC is only intended to be used by the official Cloud Bigtable client
* libraries to implement the Bigtable Session based protocol. It is subject
* to change without notice.
*
* @example samples/V2/BigtableClient/open_table.php
*
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*/
public function openTable(array $callOptions = []): BidiStream
{
return $this->startApiCall('OpenTable', null, $callOptions);
}
/**
* Warm up associated instance metadata for this connection.
* This call is not required but may be useful for connection keep-alive.
*
* The async variant is {@see BigtableClient::pingAndWarmAsync()} .
*
* @example samples/V2/BigtableClient/ping_and_warm.php
*
* @param PingAndWarmRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return PingAndWarmResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function pingAndWarm(PingAndWarmRequest $request, array $callOptions = []): PingAndWarmResponse
{
return $this->startApiCall('PingAndWarm', $request, $callOptions)->wait();
}
/**
* Prepares a GoogleSQL query for execution on a particular Bigtable instance.
*
* The async variant is {@see BigtableClient::prepareQueryAsync()} .
*
* @example samples/V2/BigtableClient/prepare_query.php
*
* @param PrepareQueryRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return PrepareQueryResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function prepareQuery(PrepareQueryRequest $request, array $callOptions = []): PrepareQueryResponse
{
return $this->startApiCall('PrepareQuery', $request, $callOptions)->wait();
}
/**
* Reads changes from a table's change stream. Changes will
* reflect both user-initiated mutations and mutations that are caused by
* garbage collection.
* NOTE: This API is only intended to be used by Apache Beam BigtableIO.
*
* @example samples/V2/BigtableClient/read_change_stream.php
*
* @param ReadChangeStreamRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<ReadChangeStreamResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function readChangeStream(ReadChangeStreamRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('ReadChangeStream', $request, $callOptions);
}
/**
* Modifies a row atomically on the server. The method reads the latest
* existing timestamp and value from the specified columns and writes a new
* entry based on pre-defined read/modify/write rules. The new value for the
* timestamp is the greater of the existing timestamp or the current server
* time. The method returns the new contents of all modified cells.
*
* The async variant is {@see BigtableClient::readModifyWriteRowAsync()} .
*
* @example samples/V2/BigtableClient/read_modify_write_row.php
*
* @param ReadModifyWriteRowRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return ReadModifyWriteRowResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function readModifyWriteRow(ReadModifyWriteRowRequest $request, array $callOptions = []): ReadModifyWriteRowResponse
{
return $this->startApiCall('ReadModifyWriteRow', $request, $callOptions)->wait();
}
/**
* Streams back the contents of all requested rows in key order, optionally
* applying the same Reader filter to each. Depending on their size,
* rows and cells may be broken up across multiple responses, but
* atomicity of each row will still be preserved. See the
* ReadRowsResponse documentation for details.
*
* @example samples/V2/BigtableClient/read_rows.php
*
* @param ReadRowsRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<ReadRowsResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function readRows(ReadRowsRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('ReadRows', $request, $callOptions);
}
/**
* Returns a sample of row keys in the table. The returned row keys will
* delimit contiguous sections of the table of approximately equal size,
* which can be used to break up the data for distributed tasks like
* mapreduces.
*
* If a `row_range` is provided in the request, the returned samples will be
* restricted to the specified range.
*
* @example samples/V2/BigtableClient/sample_row_keys.php
*
* @param SampleRowKeysRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return ServerStream<SampleRowKeysResponse>
*
* @throws ApiException Thrown if the API call fails.
*/
public function sampleRowKeys(SampleRowKeysRequest $request, array $callOptions = []): ServerStream
{
return $this->startApiCall('SampleRowKeys', $request, $callOptions);
}
/** Configure the gapic configuration to use a service emulator. */
private function setDefaultEmulatorConfig(array $options): array
{
$emulatorHost = getenv('BIGTABLE_EMULATOR_HOST');
if (empty($emulatorHost)) {
return $options;
}
if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) {
$search = $scheme . '://';
$emulatorHost = str_replace($search, '', $emulatorHost);
}
$options['apiEndpoint'] ??= $emulatorHost;
if (class_exists(ChannelCredentials::class)) {
$options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure();
}
$options['credentials'] ??= new InsecureCredentialsWrapper();
return $options;
}
}