2
2
bigtable/api/src/create_cluster.php renamed to bigtable/src/create_cluster.phpCopy file name to clipboard Expand all lines: bigtable/src/create_cluster.php +2 -2 Lines changed: 2 additions & 2 deletions Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change 1
1
2
2
3
3
/**
4
- * Copyright 2018 Google LLC.
4
+ * Copyright 2019 Google LLC.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
19
19
/**
20
20
* For instructions on how to run the full sample:
21
21
*
22
- * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/api/ README.md
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
23
*/
24
24
25
25
// Include Google Cloud dependendencies using Composer
Original file line number Diff line number Diff line change
1
+
2
+
3
+ /**
4
+ * Copyright 2019 Google LLC.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ /**
20
+ * For instructions on how to run the full sample:
21
+ *
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
+ */
24
+
25
+ // Include Google Cloud dependendencies using Composer
26
+ require_once __DIR__ . '/../../vendor/autoload.php ' ;
27
+
28
+ if (count ($ argv ) != 4 ) {
29
+ return printf ("Usage: php %s PROJECT_ID INSTANCE_ID TABLE_ID " . PHP_EOL , __FILE__ );
30
+ }
31
+ list ($ _ , $ project_id , $ instance_id , $ table_id ) = $ argv ;
32
+
33
+ // [START bigtable_hw_create_table]
34
+
35
+ use Google \Cloud \Bigtable \Admin \V2 \BigtableInstanceAdminClient ;
36
+ use Google \Cloud \Bigtable \Admin \V2 \BigtableTableAdminClient ;
37
+ use Google \Cloud \Bigtable \Admin \V2 \ColumnFamily ;
38
+ use Google \Cloud \Bigtable \Admin \V2 \ModifyColumnFamiliesRequest \Modification ;
39
+ use Google \Cloud \Bigtable \Admin \V2 \Table \View ;
40
+ use Google \Cloud \Bigtable \Admin \V2 \Table ;
41
+ use Google \ApiCore \ApiException ;
42
+
43
+ /** Uncomment and populate these variables in your code */
44
+ // $project_id = 'The Google project ID';
45
+ // $instance_id = 'The Bigtable instance ID';
46
+ // $table_id = 'The Bigtable table ID';
47
+
48
+ $ instanceAdminClient = new BigtableInstanceAdminClient ();
49
+ $ tableAdminClient = new BigtableTableAdminClient ();
50
+
51
+ $ instanceName = $ instanceAdminClient ->instanceName ($ project_id , $ instance_id );
52
+ $ tableName = $ tableAdminClient ->tableName ($ project_id , $ instance_id , $ table_id );
53
+
54
+ // Check whether table exists in an instance.
55
+ // Create table if it does not exists.
56
+ $ table = new Table ();
57
+ printf ('Creating a Table : %s ' . PHP_EOL , $ table_id );
58
+
59
+ try {
60
+ $ tableAdminClient ->getTable ($ tableName , ['view ' => View::NAME_ONLY ]);
61
+ printf ('Table %s alredy exists ' . PHP_EOL , $ table_id );
62
+ } catch (ApiException $ e ) {
63
+ if ($ e ->getStatus () === 'NOT_FOUND ' ) {
64
+ printf ('Creating the %s table ' . PHP_EOL , $ table_id );
65
+
66
+ $ tableAdminClient ->createtable (
67
+ $ instanceName ,
68
+ $ table_id ,
69
+ $ table
70
+ );
71
+ $ columnFamily = new ColumnFamily ();
72
+ $ columnModification = new Modification ();
73
+ $ columnModification ->setId ('cf1 ' );
74
+ $ columnModification ->setCreate ($ columnFamily );
75
+ $ tableAdminClient ->modifyColumnFamilies ($ tableName , [$ columnModification ]);
76
+ printf ('Created table %s ' . PHP_EOL , $ table_id );
77
+ } else {
78
+ throw $ e ;
79
+ }
80
+ }
81
+ // [END bigtable_hw_create_table]
Original file line number Diff line number Diff line change
1
+
2
+
3
+ /**
4
+ * Copyright 2019 Google LLC.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ /**
20
+ * For instructions on how to run the full sample:
21
+ *
22
+ * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/bigtable/README.md
23
+ */
24
+
25
+ // Include Google Cloud dependendencies using Composer
26
+ require_once __DIR__ . '/../../vendor/autoload.php ' ;
27
+
28
+ if (count ($ argv ) < 3 || count ($ argv ) > 5 ) {
29
+ return printf ("Usage: php %s PROJECT_ID INSTANCE_ID TABLE_ID " . PHP_EOL , __FILE__ );
30
+ }
31
+ list ($ _ , $ project_id , $ instance_id , $ table_id ) = $ argv ;
32
+
33
+ // [START bigtable_hw_get_with_filter]
34
+
35
+ use Google \Cloud \Bigtable \BigtableClient ;
36
+ use Google \Cloud \Bigtable \V2 \RowFilter ;
37
+
38
+ /** Uncomment and populate these variables in your code */
39
+ // $project_id = 'The Google project ID';
40
+ // $instance_id = 'The Bigtable instance ID';
41
+ // $table_id = 'The Bigtable table ID';
42
+
43
+
44
+ // Connect to an existing table with an existing instance.
45
+ $ dataClient = new BigtableClient ([
46
+ 'projectId ' => $ project_id ,
47
+ ]);
48
+ $ table = $ dataClient ->table ($ instance_id , $ table_id );
49
+
50
+ printf ('Getting a single greeting by row key. ' . PHP_EOL );
51
+ $ key = 'greeting0 ' ;
52
+ // Only retrieve the most recent version of the cell.
53
+ $ row_filter = (new RowFilter )->setCellsPerColumnLimitFilter (1 );
54
+
55
+ $ column = 'greeting ' ;
56
+ $ columnFamilyId = 'cf1 ' ;
57
+
58
+ $ row = $ table ->readRow ($ key , [
59
+ 'rowFilter ' => $ row_filter
60
+ ]);
61
+ printf ('%s ' . PHP_EOL , $ row [$ columnFamilyId ][$ column ][0 ]['value ' ]);
62
+ // [END bigtable_hw_get_with_filter]
You can’t perform that action at this time.
0 commit comments