google-cloud-bigtable 2.30.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/bigtable/__init__.py +25 -0
- google/cloud/bigtable/app_profile.py +377 -0
- google/cloud/bigtable/backup.py +490 -0
- google/cloud/bigtable/batcher.py +414 -0
- google/cloud/bigtable/client.py +475 -0
- google/cloud/bigtable/cluster.py +541 -0
- google/cloud/bigtable/column_family.py +362 -0
- google/cloud/bigtable/data/__init__.py +103 -0
- google/cloud/bigtable/data/_async/__init__.py +25 -0
- google/cloud/bigtable/data/_async/_mutate_rows.py +226 -0
- google/cloud/bigtable/data/_async/_read_rows.py +363 -0
- google/cloud/bigtable/data/_async/client.py +1522 -0
- google/cloud/bigtable/data/_async/mutations_batcher.py +534 -0
- google/cloud/bigtable/data/_cross_sync/__init__.py +20 -0
- google/cloud/bigtable/data/_cross_sync/_decorators.py +441 -0
- google/cloud/bigtable/data/_cross_sync/_mapping_meta.py +64 -0
- google/cloud/bigtable/data/_cross_sync/cross_sync.py +334 -0
- google/cloud/bigtable/data/_helpers.py +249 -0
- google/cloud/bigtable/data/_sync_autogen/_mutate_rows.py +182 -0
- google/cloud/bigtable/data/_sync_autogen/_read_rows.py +304 -0
- google/cloud/bigtable/data/_sync_autogen/client.py +1293 -0
- google/cloud/bigtable/data/_sync_autogen/mutations_batcher.py +449 -0
- google/cloud/bigtable/data/exceptions.py +340 -0
- google/cloud/bigtable/data/execute_query/__init__.py +43 -0
- google/cloud/bigtable/data/execute_query/_async/__init__.py +13 -0
- google/cloud/bigtable/data/execute_query/_async/execute_query_iterator.py +291 -0
- google/cloud/bigtable/data/execute_query/_byte_cursor.py +123 -0
- google/cloud/bigtable/data/execute_query/_checksum.py +43 -0
- google/cloud/bigtable/data/execute_query/_parameters_formatting.py +155 -0
- google/cloud/bigtable/data/execute_query/_query_result_parsing_utils.py +134 -0
- google/cloud/bigtable/data/execute_query/_reader.py +122 -0
- google/cloud/bigtable/data/execute_query/_sync_autogen/execute_query_iterator.py +239 -0
- google/cloud/bigtable/data/execute_query/metadata.py +399 -0
- google/cloud/bigtable/data/execute_query/values.py +123 -0
- google/cloud/bigtable/data/mutations.py +380 -0
- google/cloud/bigtable/data/read_modify_write_rules.py +112 -0
- google/cloud/bigtable/data/read_rows_query.py +536 -0
- google/cloud/bigtable/data/row.py +535 -0
- google/cloud/bigtable/data/row_filters.py +968 -0
- google/cloud/bigtable/encryption_info.py +64 -0
- google/cloud/bigtable/enums.py +223 -0
- google/cloud/bigtable/error.py +64 -0
- google/cloud/bigtable/gapic_version.py +16 -0
- google/cloud/bigtable/helpers.py +31 -0
- google/cloud/bigtable/instance.py +789 -0
- google/cloud/bigtable/policy.py +255 -0
- google/cloud/bigtable/row.py +1267 -0
- google/cloud/bigtable/row_data.py +380 -0
- google/cloud/bigtable/row_filters.py +838 -0
- google/cloud/bigtable/row_merger.py +250 -0
- google/cloud/bigtable/row_set.py +213 -0
- google/cloud/bigtable/table.py +1409 -0
- google/cloud/bigtable_admin/__init__.py +410 -0
- google/cloud/bigtable_admin/gapic_version.py +16 -0
- google/cloud/bigtable_admin/py.typed +2 -0
- google/cloud/bigtable_admin_v2/__init__.py +250 -0
- google/cloud/bigtable_admin_v2/gapic_metadata.json +962 -0
- google/cloud/bigtable_admin_v2/gapic_version.py +16 -0
- google/cloud/bigtable_admin_v2/py.typed +2 -0
- google/cloud/bigtable_admin_v2/services/__init__.py +15 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/__init__.py +22 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py +3465 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py +3944 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/pagers.py +681 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/__init__.py +40 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/base.py +751 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc.py +1249 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc_asyncio.py +1579 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest.py +6820 -0
- google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest_base.py +1746 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/__init__.py +22 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/async_client.py +3472 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py +3949 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/pagers.py +669 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/__init__.py +40 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py +708 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc.py +1257 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc_asyncio.py +1549 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest.py +6609 -0
- google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest_base.py +1714 -0
- google/cloud/bigtable_admin_v2/types/__init__.py +248 -0
- google/cloud/bigtable_admin_v2/types/bigtable_instance_admin.py +1364 -0
- google/cloud/bigtable_admin_v2/types/bigtable_table_admin.py +1715 -0
- google/cloud/bigtable_admin_v2/types/common.py +81 -0
- google/cloud/bigtable_admin_v2/types/instance.py +819 -0
- google/cloud/bigtable_admin_v2/types/table.py +1028 -0
- google/cloud/bigtable_admin_v2/types/types.py +776 -0
- google/cloud/bigtable_v2/__init__.py +136 -0
- google/cloud/bigtable_v2/gapic_metadata.json +193 -0
- google/cloud/bigtable_v2/gapic_version.py +16 -0
- google/cloud/bigtable_v2/py.typed +2 -0
- google/cloud/bigtable_v2/services/__init__.py +15 -0
- google/cloud/bigtable_v2/services/bigtable/__init__.py +22 -0
- google/cloud/bigtable_v2/services/bigtable/async_client.py +1741 -0
- google/cloud/bigtable_v2/services/bigtable/client.py +2194 -0
- google/cloud/bigtable_v2/services/bigtable/transports/__init__.py +38 -0
- google/cloud/bigtable_v2/services/bigtable/transports/base.py +343 -0
- google/cloud/bigtable_v2/services/bigtable/transports/grpc.py +660 -0
- google/cloud/bigtable_v2/services/bigtable/transports/grpc_asyncio.py +762 -0
- google/cloud/bigtable_v2/services/bigtable/transports/rest.py +2489 -0
- google/cloud/bigtable_v2/services/bigtable/transports/rest_base.py +711 -0
- google/cloud/bigtable_v2/types/__init__.py +138 -0
- google/cloud/bigtable_v2/types/bigtable.py +1531 -0
- google/cloud/bigtable_v2/types/data.py +1612 -0
- google/cloud/bigtable_v2/types/feature_flags.py +119 -0
- google/cloud/bigtable_v2/types/request_stats.py +171 -0
- google/cloud/bigtable_v2/types/response_params.py +64 -0
- google/cloud/bigtable_v2/types/types.py +579 -0
- google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_admin_v2_keywords.py +233 -0
- google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_v2_keywords.py +186 -0
- google_cloud_bigtable-2.30.0.dist-info/LICENSE +202 -0
- google_cloud_bigtable-2.30.0.dist-info/METADATA +154 -0
- google_cloud_bigtable-2.30.0.dist-info/RECORD +115 -0
- google_cloud_bigtable-2.30.0.dist-info/WHEEL +5 -0
- google_cloud_bigtable-2.30.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# Copyright 2015 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
|
+
# http://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
|
+
"""User friendly container for Google Cloud Bigtable Column Family."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
from google.cloud import _helpers
|
|
19
|
+
from google.cloud.bigtable_admin_v2.types import table as table_v2_pb2
|
|
20
|
+
from google.cloud.bigtable_admin_v2.types import (
|
|
21
|
+
bigtable_table_admin as table_admin_v2_pb2,
|
|
22
|
+
)
|
|
23
|
+
from google.api_core.gapic_v1.method import DEFAULT
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class GarbageCollectionRule(object):
|
|
27
|
+
"""Garbage collection rule for column families within a table.
|
|
28
|
+
|
|
29
|
+
Cells in the column family (within a table) fitting the rule will be
|
|
30
|
+
deleted during garbage collection.
|
|
31
|
+
|
|
32
|
+
.. note::
|
|
33
|
+
|
|
34
|
+
This class is a do-nothing base class for all GC rules.
|
|
35
|
+
|
|
36
|
+
.. note::
|
|
37
|
+
|
|
38
|
+
A string ``gc_expression`` can also be used with API requests, but
|
|
39
|
+
that value would be superceded by a ``gc_rule``. As a result, we
|
|
40
|
+
don't support that feature and instead support via native classes.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class MaxVersionsGCRule(GarbageCollectionRule):
|
|
45
|
+
"""Garbage collection limiting the number of versions of a cell.
|
|
46
|
+
|
|
47
|
+
For example:
|
|
48
|
+
|
|
49
|
+
.. literalinclude:: snippets_table.py
|
|
50
|
+
:start-after: [START bigtable_api_create_family_gc_max_versions]
|
|
51
|
+
:end-before: [END bigtable_api_create_family_gc_max_versions]
|
|
52
|
+
:dedent: 4
|
|
53
|
+
|
|
54
|
+
:type max_num_versions: int
|
|
55
|
+
:param max_num_versions: The maximum number of versions
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
def __init__(self, max_num_versions):
|
|
59
|
+
self.max_num_versions = max_num_versions
|
|
60
|
+
|
|
61
|
+
def __eq__(self, other):
|
|
62
|
+
if not isinstance(other, self.__class__):
|
|
63
|
+
return NotImplemented
|
|
64
|
+
return other.max_num_versions == self.max_num_versions
|
|
65
|
+
|
|
66
|
+
def __ne__(self, other):
|
|
67
|
+
return not self == other
|
|
68
|
+
|
|
69
|
+
def to_pb(self):
|
|
70
|
+
"""Converts the garbage collection rule to a protobuf.
|
|
71
|
+
|
|
72
|
+
:rtype: :class:`.table_v2_pb2.GcRule`
|
|
73
|
+
:returns: The converted current object.
|
|
74
|
+
"""
|
|
75
|
+
return table_v2_pb2.GcRule(max_num_versions=self.max_num_versions)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class MaxAgeGCRule(GarbageCollectionRule):
|
|
79
|
+
"""Garbage collection limiting the age of a cell.
|
|
80
|
+
|
|
81
|
+
For example:
|
|
82
|
+
|
|
83
|
+
.. literalinclude:: snippets_table.py
|
|
84
|
+
:start-after: [START bigtable_api_create_family_gc_max_age]
|
|
85
|
+
:end-before: [END bigtable_api_create_family_gc_max_age]
|
|
86
|
+
:dedent: 4
|
|
87
|
+
|
|
88
|
+
:type max_age: :class:`datetime.timedelta`
|
|
89
|
+
:param max_age: The maximum age allowed for a cell in the table.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
def __init__(self, max_age):
|
|
93
|
+
self.max_age = max_age
|
|
94
|
+
|
|
95
|
+
def __eq__(self, other):
|
|
96
|
+
if not isinstance(other, self.__class__):
|
|
97
|
+
return NotImplemented
|
|
98
|
+
return other.max_age == self.max_age
|
|
99
|
+
|
|
100
|
+
def __ne__(self, other):
|
|
101
|
+
return not self == other
|
|
102
|
+
|
|
103
|
+
def to_pb(self):
|
|
104
|
+
"""Converts the garbage collection rule to a protobuf.
|
|
105
|
+
|
|
106
|
+
:rtype: :class:`.table_v2_pb2.GcRule`
|
|
107
|
+
:returns: The converted current object.
|
|
108
|
+
"""
|
|
109
|
+
max_age = _helpers._timedelta_to_duration_pb(self.max_age)
|
|
110
|
+
return table_v2_pb2.GcRule(max_age=max_age)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class GCRuleUnion(GarbageCollectionRule):
|
|
114
|
+
"""Union of garbage collection rules.
|
|
115
|
+
|
|
116
|
+
For example:
|
|
117
|
+
|
|
118
|
+
.. literalinclude:: snippets_table.py
|
|
119
|
+
:start-after: [START bigtable_api_create_family_gc_union]
|
|
120
|
+
:end-before: [END bigtable_api_create_family_gc_union]
|
|
121
|
+
:dedent: 4
|
|
122
|
+
|
|
123
|
+
:type rules: list
|
|
124
|
+
:param rules: List of :class:`GarbageCollectionRule`.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def __init__(self, rules):
|
|
128
|
+
self.rules = rules
|
|
129
|
+
|
|
130
|
+
def __eq__(self, other):
|
|
131
|
+
if not isinstance(other, self.__class__):
|
|
132
|
+
return NotImplemented
|
|
133
|
+
return other.rules == self.rules
|
|
134
|
+
|
|
135
|
+
def __ne__(self, other):
|
|
136
|
+
return not self == other
|
|
137
|
+
|
|
138
|
+
def to_pb(self):
|
|
139
|
+
"""Converts the union into a single GC rule as a protobuf.
|
|
140
|
+
|
|
141
|
+
:rtype: :class:`.table_v2_pb2.GcRule`
|
|
142
|
+
:returns: The converted current object.
|
|
143
|
+
"""
|
|
144
|
+
union = table_v2_pb2.GcRule.Union(rules=[rule.to_pb() for rule in self.rules])
|
|
145
|
+
return table_v2_pb2.GcRule(union=union)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class GCRuleIntersection(GarbageCollectionRule):
|
|
149
|
+
"""Intersection of garbage collection rules.
|
|
150
|
+
|
|
151
|
+
For example:
|
|
152
|
+
|
|
153
|
+
.. literalinclude:: snippets_table.py
|
|
154
|
+
:start-after: [START bigtable_api_create_family_gc_intersection]
|
|
155
|
+
:end-before: [END bigtable_api_create_family_gc_intersection]
|
|
156
|
+
:dedent: 4
|
|
157
|
+
|
|
158
|
+
:type rules: list
|
|
159
|
+
:param rules: List of :class:`GarbageCollectionRule`.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
def __init__(self, rules):
|
|
163
|
+
self.rules = rules
|
|
164
|
+
|
|
165
|
+
def __eq__(self, other):
|
|
166
|
+
if not isinstance(other, self.__class__):
|
|
167
|
+
return NotImplemented
|
|
168
|
+
return other.rules == self.rules
|
|
169
|
+
|
|
170
|
+
def __ne__(self, other):
|
|
171
|
+
return not self == other
|
|
172
|
+
|
|
173
|
+
def to_pb(self):
|
|
174
|
+
"""Converts the intersection into a single GC rule as a protobuf.
|
|
175
|
+
|
|
176
|
+
:rtype: :class:`.table_v2_pb2.GcRule`
|
|
177
|
+
:returns: The converted current object.
|
|
178
|
+
"""
|
|
179
|
+
intersection = table_v2_pb2.GcRule.Intersection(
|
|
180
|
+
rules=[rule.to_pb() for rule in self.rules]
|
|
181
|
+
)
|
|
182
|
+
return table_v2_pb2.GcRule(intersection=intersection)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class ColumnFamily(object):
|
|
186
|
+
"""Representation of a Google Cloud Bigtable Column Family.
|
|
187
|
+
|
|
188
|
+
We can use a :class:`ColumnFamily` to:
|
|
189
|
+
|
|
190
|
+
* :meth:`create` itself
|
|
191
|
+
* :meth:`update` itself
|
|
192
|
+
* :meth:`delete` itself
|
|
193
|
+
|
|
194
|
+
:type column_family_id: str
|
|
195
|
+
:param column_family_id: The ID of the column family. Must be of the
|
|
196
|
+
form ``[_a-zA-Z0-9][-_.a-zA-Z0-9]*``.
|
|
197
|
+
|
|
198
|
+
:type table: :class:`Table <google.cloud.bigtable.table.Table>`
|
|
199
|
+
:param table: The table that owns the column family.
|
|
200
|
+
|
|
201
|
+
:type gc_rule: :class:`GarbageCollectionRule`
|
|
202
|
+
:param gc_rule: (Optional) The garbage collection settings for this
|
|
203
|
+
column family.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
def __init__(self, column_family_id, table, gc_rule=None):
|
|
207
|
+
self.column_family_id = column_family_id
|
|
208
|
+
self._table = table
|
|
209
|
+
self.gc_rule = gc_rule
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def name(self):
|
|
213
|
+
"""Column family name used in requests.
|
|
214
|
+
|
|
215
|
+
For example:
|
|
216
|
+
|
|
217
|
+
.. literalinclude:: snippets_table.py
|
|
218
|
+
:start-after: [START bigtable_api_column_family_name]
|
|
219
|
+
:end-before: [END bigtable_api_column_family_name]
|
|
220
|
+
:dedent: 4
|
|
221
|
+
|
|
222
|
+
.. note::
|
|
223
|
+
|
|
224
|
+
This property will not change if ``column_family_id`` does not, but
|
|
225
|
+
the return value is not cached.
|
|
226
|
+
|
|
227
|
+
The Column family name is of the form
|
|
228
|
+
|
|
229
|
+
``"projects/../zones/../clusters/../tables/../columnFamilies/.."``
|
|
230
|
+
|
|
231
|
+
:rtype: str
|
|
232
|
+
:returns: The column family name.
|
|
233
|
+
"""
|
|
234
|
+
return self._table.name + "/columnFamilies/" + self.column_family_id
|
|
235
|
+
|
|
236
|
+
def __eq__(self, other):
|
|
237
|
+
if not isinstance(other, self.__class__):
|
|
238
|
+
return NotImplemented
|
|
239
|
+
return (
|
|
240
|
+
other.column_family_id == self.column_family_id
|
|
241
|
+
and other._table == self._table
|
|
242
|
+
and other.gc_rule == self.gc_rule
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
def __ne__(self, other):
|
|
246
|
+
return not self == other
|
|
247
|
+
|
|
248
|
+
def to_pb(self):
|
|
249
|
+
"""Converts the column family to a protobuf.
|
|
250
|
+
|
|
251
|
+
:rtype: :class:`.table_v2_pb2.ColumnFamily`
|
|
252
|
+
:returns: The converted current object.
|
|
253
|
+
"""
|
|
254
|
+
if self.gc_rule is None:
|
|
255
|
+
return table_v2_pb2.ColumnFamily()
|
|
256
|
+
else:
|
|
257
|
+
return table_v2_pb2.ColumnFamily(gc_rule=self.gc_rule.to_pb())
|
|
258
|
+
|
|
259
|
+
def create(self):
|
|
260
|
+
"""Create this column family.
|
|
261
|
+
|
|
262
|
+
For example:
|
|
263
|
+
|
|
264
|
+
.. literalinclude:: snippets_table.py
|
|
265
|
+
:start-after: [START bigtable_api_create_column_family]
|
|
266
|
+
:end-before: [END bigtable_api_create_column_family]
|
|
267
|
+
:dedent: 4
|
|
268
|
+
|
|
269
|
+
"""
|
|
270
|
+
column_family = self.to_pb()
|
|
271
|
+
modification = table_admin_v2_pb2.ModifyColumnFamiliesRequest.Modification(
|
|
272
|
+
id=self.column_family_id, create=column_family
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
client = self._table._instance._client
|
|
276
|
+
# data it contains are the GC rule and the column family ID already
|
|
277
|
+
# stored on this instance.
|
|
278
|
+
client.table_admin_client.modify_column_families(
|
|
279
|
+
request={"name": self._table.name, "modifications": [modification]},
|
|
280
|
+
timeout=DEFAULT,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
def update(self):
|
|
284
|
+
"""Update this column family.
|
|
285
|
+
|
|
286
|
+
For example:
|
|
287
|
+
|
|
288
|
+
.. literalinclude:: snippets_table.py
|
|
289
|
+
:start-after: [START bigtable_api_update_column_family]
|
|
290
|
+
:end-before: [END bigtable_api_update_column_family]
|
|
291
|
+
:dedent: 4
|
|
292
|
+
|
|
293
|
+
.. note::
|
|
294
|
+
|
|
295
|
+
Only the GC rule can be updated. By changing the column family ID,
|
|
296
|
+
you will simply be referring to a different column family.
|
|
297
|
+
"""
|
|
298
|
+
column_family = self.to_pb()
|
|
299
|
+
modification = table_admin_v2_pb2.ModifyColumnFamiliesRequest.Modification(
|
|
300
|
+
id=self.column_family_id, update=column_family
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
client = self._table._instance._client
|
|
304
|
+
# data it contains are the GC rule and the column family ID already
|
|
305
|
+
# stored on this instance.
|
|
306
|
+
client.table_admin_client.modify_column_families(
|
|
307
|
+
request={"name": self._table.name, "modifications": [modification]},
|
|
308
|
+
timeout=DEFAULT,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
def delete(self):
|
|
312
|
+
"""Delete this column family.
|
|
313
|
+
|
|
314
|
+
For example:
|
|
315
|
+
|
|
316
|
+
.. literalinclude:: snippets_table.py
|
|
317
|
+
:start-after: [START bigtable_api_delete_column_family]
|
|
318
|
+
:end-before: [END bigtable_api_delete_column_family]
|
|
319
|
+
:dedent: 4
|
|
320
|
+
|
|
321
|
+
"""
|
|
322
|
+
modification = table_admin_v2_pb2.ModifyColumnFamiliesRequest.Modification(
|
|
323
|
+
id=self.column_family_id, drop=True
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
client = self._table._instance._client
|
|
327
|
+
# data it contains are the GC rule and the column family ID already
|
|
328
|
+
# stored on this instance.
|
|
329
|
+
client.table_admin_client.modify_column_families(
|
|
330
|
+
request={"name": self._table.name, "modifications": [modification]},
|
|
331
|
+
timeout=DEFAULT,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _gc_rule_from_pb(gc_rule_pb):
|
|
336
|
+
"""Convert a protobuf GC rule to a native object.
|
|
337
|
+
|
|
338
|
+
:type gc_rule_pb: :class:`.table_v2_pb2.GcRule`
|
|
339
|
+
:param gc_rule_pb: The GC rule to convert.
|
|
340
|
+
|
|
341
|
+
:rtype: :class:`GarbageCollectionRule` or :data:`NoneType <types.NoneType>`
|
|
342
|
+
:returns: An instance of one of the native rules defined
|
|
343
|
+
in :module:`column_family` or :data:`None` if no values were
|
|
344
|
+
set on the protobuf passed in.
|
|
345
|
+
:raises: :class:`ValueError <exceptions.ValueError>` if the rule name
|
|
346
|
+
is unexpected.
|
|
347
|
+
"""
|
|
348
|
+
rule_name = gc_rule_pb._pb.WhichOneof("rule")
|
|
349
|
+
if rule_name is None:
|
|
350
|
+
return None
|
|
351
|
+
|
|
352
|
+
if rule_name == "max_num_versions":
|
|
353
|
+
return MaxVersionsGCRule(gc_rule_pb.max_num_versions)
|
|
354
|
+
elif rule_name == "max_age":
|
|
355
|
+
return MaxAgeGCRule(gc_rule_pb.max_age)
|
|
356
|
+
elif rule_name == "union":
|
|
357
|
+
return GCRuleUnion([_gc_rule_from_pb(rule) for rule in gc_rule_pb.union.rules])
|
|
358
|
+
elif rule_name == "intersection":
|
|
359
|
+
rules = [_gc_rule_from_pb(rule) for rule in gc_rule_pb.intersection.rules]
|
|
360
|
+
return GCRuleIntersection(rules)
|
|
361
|
+
else:
|
|
362
|
+
raise ValueError("Unexpected rule name", rule_name)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2023 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from google.cloud.bigtable import gapic_version as package_version
|
|
17
|
+
|
|
18
|
+
from google.cloud.bigtable.data._async.client import BigtableDataClientAsync
|
|
19
|
+
from google.cloud.bigtable.data._async.client import TableAsync
|
|
20
|
+
from google.cloud.bigtable.data._async.mutations_batcher import MutationsBatcherAsync
|
|
21
|
+
from google.cloud.bigtable.data._sync_autogen.client import BigtableDataClient
|
|
22
|
+
from google.cloud.bigtable.data._sync_autogen.client import Table
|
|
23
|
+
from google.cloud.bigtable.data._sync_autogen.mutations_batcher import MutationsBatcher
|
|
24
|
+
|
|
25
|
+
from google.cloud.bigtable.data.read_rows_query import ReadRowsQuery
|
|
26
|
+
from google.cloud.bigtable.data.read_rows_query import RowRange
|
|
27
|
+
from google.cloud.bigtable.data.row import Row
|
|
28
|
+
from google.cloud.bigtable.data.row import Cell
|
|
29
|
+
|
|
30
|
+
from google.cloud.bigtable.data.mutations import Mutation
|
|
31
|
+
from google.cloud.bigtable.data.mutations import RowMutationEntry
|
|
32
|
+
from google.cloud.bigtable.data.mutations import SetCell
|
|
33
|
+
from google.cloud.bigtable.data.mutations import DeleteRangeFromColumn
|
|
34
|
+
from google.cloud.bigtable.data.mutations import DeleteAllFromFamily
|
|
35
|
+
from google.cloud.bigtable.data.mutations import DeleteAllFromRow
|
|
36
|
+
|
|
37
|
+
from google.cloud.bigtable.data.exceptions import InvalidChunk
|
|
38
|
+
from google.cloud.bigtable.data.exceptions import FailedMutationEntryError
|
|
39
|
+
from google.cloud.bigtable.data.exceptions import FailedQueryShardError
|
|
40
|
+
|
|
41
|
+
from google.cloud.bigtable.data.exceptions import RetryExceptionGroup
|
|
42
|
+
from google.cloud.bigtable.data.exceptions import MutationsExceptionGroup
|
|
43
|
+
from google.cloud.bigtable.data.exceptions import ShardedReadRowsExceptionGroup
|
|
44
|
+
from google.cloud.bigtable.data.exceptions import ParameterTypeInferenceFailed
|
|
45
|
+
|
|
46
|
+
from google.cloud.bigtable.data._helpers import TABLE_DEFAULT
|
|
47
|
+
from google.cloud.bigtable.data._helpers import RowKeySamples
|
|
48
|
+
from google.cloud.bigtable.data._helpers import ShardedQuery
|
|
49
|
+
|
|
50
|
+
# setup custom CrossSync mappings for library
|
|
51
|
+
from google.cloud.bigtable_v2.services.bigtable.async_client import (
|
|
52
|
+
BigtableAsyncClient,
|
|
53
|
+
)
|
|
54
|
+
from google.cloud.bigtable.data._async._read_rows import _ReadRowsOperationAsync
|
|
55
|
+
from google.cloud.bigtable.data._async._mutate_rows import _MutateRowsOperationAsync
|
|
56
|
+
|
|
57
|
+
from google.cloud.bigtable_v2.services.bigtable.client import (
|
|
58
|
+
BigtableClient,
|
|
59
|
+
)
|
|
60
|
+
from google.cloud.bigtable.data._sync_autogen._read_rows import _ReadRowsOperation
|
|
61
|
+
from google.cloud.bigtable.data._sync_autogen._mutate_rows import _MutateRowsOperation
|
|
62
|
+
|
|
63
|
+
from google.cloud.bigtable.data._cross_sync import CrossSync
|
|
64
|
+
|
|
65
|
+
CrossSync.add_mapping("GapicClient", BigtableAsyncClient)
|
|
66
|
+
CrossSync._Sync_Impl.add_mapping("GapicClient", BigtableClient)
|
|
67
|
+
CrossSync.add_mapping("_ReadRowsOperation", _ReadRowsOperationAsync)
|
|
68
|
+
CrossSync._Sync_Impl.add_mapping("_ReadRowsOperation", _ReadRowsOperation)
|
|
69
|
+
CrossSync.add_mapping("_MutateRowsOperation", _MutateRowsOperationAsync)
|
|
70
|
+
CrossSync._Sync_Impl.add_mapping("_MutateRowsOperation", _MutateRowsOperation)
|
|
71
|
+
CrossSync.add_mapping("MutationsBatcher", MutationsBatcherAsync)
|
|
72
|
+
CrossSync._Sync_Impl.add_mapping("MutationsBatcher", MutationsBatcher)
|
|
73
|
+
|
|
74
|
+
__version__: str = package_version.__version__
|
|
75
|
+
|
|
76
|
+
__all__ = (
|
|
77
|
+
"BigtableDataClientAsync",
|
|
78
|
+
"TableAsync",
|
|
79
|
+
"MutationsBatcherAsync",
|
|
80
|
+
"BigtableDataClient",
|
|
81
|
+
"Table",
|
|
82
|
+
"MutationsBatcher",
|
|
83
|
+
"RowKeySamples",
|
|
84
|
+
"ReadRowsQuery",
|
|
85
|
+
"RowRange",
|
|
86
|
+
"Mutation",
|
|
87
|
+
"RowMutationEntry",
|
|
88
|
+
"SetCell",
|
|
89
|
+
"DeleteRangeFromColumn",
|
|
90
|
+
"DeleteAllFromFamily",
|
|
91
|
+
"DeleteAllFromRow",
|
|
92
|
+
"Row",
|
|
93
|
+
"Cell",
|
|
94
|
+
"InvalidChunk",
|
|
95
|
+
"FailedMutationEntryError",
|
|
96
|
+
"FailedQueryShardError",
|
|
97
|
+
"RetryExceptionGroup",
|
|
98
|
+
"MutationsExceptionGroup",
|
|
99
|
+
"ShardedReadRowsExceptionGroup",
|
|
100
|
+
"ParameterTypeInferenceFailed",
|
|
101
|
+
"ShardedQuery",
|
|
102
|
+
"TABLE_DEFAULT",
|
|
103
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
# http://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
|
+
from google.cloud.bigtable.data._async.client import BigtableDataClientAsync
|
|
16
|
+
from google.cloud.bigtable.data._async.client import TableAsync
|
|
17
|
+
|
|
18
|
+
from google.cloud.bigtable.data._async.mutations_batcher import MutationsBatcherAsync
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"BigtableDataClientAsync",
|
|
23
|
+
"TableAsync",
|
|
24
|
+
"MutationsBatcherAsync",
|
|
25
|
+
]
|