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,25 @@
|
|
|
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
|
+
"""Google Cloud Bigtable API package."""
|
|
16
|
+
|
|
17
|
+
from google.cloud.bigtable.client import Client
|
|
18
|
+
|
|
19
|
+
from google.cloud.bigtable import gapic_version as package_version
|
|
20
|
+
|
|
21
|
+
__version__: str
|
|
22
|
+
|
|
23
|
+
__version__ = package_version.__version__
|
|
24
|
+
|
|
25
|
+
__all__ = ["__version__", "Client"]
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Copyright 2018 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 AppProfile."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
from google.cloud.bigtable.enums import RoutingPolicyType
|
|
21
|
+
from google.cloud.bigtable_admin_v2.types import instance
|
|
22
|
+
from google.protobuf import field_mask_pb2
|
|
23
|
+
from google.api_core.exceptions import NotFound
|
|
24
|
+
|
|
25
|
+
_APP_PROFILE_NAME_RE = re.compile(
|
|
26
|
+
r"^projects/(?P<project>[^/]+)/"
|
|
27
|
+
r"instances/(?P<instance>[^/]+)/"
|
|
28
|
+
r"appProfiles/(?P<app_profile_id>[_a-zA-Z0-9][-_.a-zA-Z0-9]*)$"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class AppProfile(object):
|
|
33
|
+
"""Representation of a Google Cloud Bigtable AppProfile.
|
|
34
|
+
|
|
35
|
+
We can use a :class:`AppProfile` to:
|
|
36
|
+
|
|
37
|
+
* :meth:`reload` itself
|
|
38
|
+
* :meth:`create` itself
|
|
39
|
+
* :meth:`update` itself
|
|
40
|
+
* :meth:`delete` itself
|
|
41
|
+
|
|
42
|
+
:type app_profile_id: str
|
|
43
|
+
:param app_profile_id: The ID of the AppProfile. Must be of the form
|
|
44
|
+
``[_a-zA-Z0-9][-_.a-zA-Z0-9]*``.
|
|
45
|
+
|
|
46
|
+
:type: routing_policy_type: int
|
|
47
|
+
:param: routing_policy_type: (Optional) The type of the routing policy.
|
|
48
|
+
Possible values are represented
|
|
49
|
+
by the following constants:
|
|
50
|
+
:data:`google.cloud.bigtable.enums.RoutingPolicyType.ANY`
|
|
51
|
+
:data:`google.cloud.bigtable.enums.RoutingPolicyType.SINGLE`
|
|
52
|
+
|
|
53
|
+
:type: description: str
|
|
54
|
+
:param: description: (Optional) Long form description of the use
|
|
55
|
+
case for this AppProfile.
|
|
56
|
+
|
|
57
|
+
:type: cluster_id: str
|
|
58
|
+
:param: cluster_id: (Optional) Unique cluster_id which is only required
|
|
59
|
+
when routing_policy_type is
|
|
60
|
+
ROUTING_POLICY_TYPE_SINGLE.
|
|
61
|
+
|
|
62
|
+
:type: multi_cluster_ids: list
|
|
63
|
+
:param: multi_cluster_ids: (Optional) The set of clusters to route to.
|
|
64
|
+
The order is ignored; clusters will be tried in order of distance.
|
|
65
|
+
If left empty, all clusters are eligible.
|
|
66
|
+
|
|
67
|
+
:type: allow_transactional_writes: bool
|
|
68
|
+
:param: allow_transactional_writes: (Optional) If true, allow
|
|
69
|
+
transactional writes for
|
|
70
|
+
ROUTING_POLICY_TYPE_SINGLE.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
app_profile_id,
|
|
76
|
+
instance,
|
|
77
|
+
routing_policy_type=None,
|
|
78
|
+
description=None,
|
|
79
|
+
cluster_id=None,
|
|
80
|
+
multi_cluster_ids=None,
|
|
81
|
+
allow_transactional_writes=None,
|
|
82
|
+
):
|
|
83
|
+
self.app_profile_id = app_profile_id
|
|
84
|
+
self._instance = instance
|
|
85
|
+
self.routing_policy_type = routing_policy_type
|
|
86
|
+
self.description = description
|
|
87
|
+
self.cluster_id = cluster_id
|
|
88
|
+
self.multi_cluster_ids = multi_cluster_ids
|
|
89
|
+
self.allow_transactional_writes = allow_transactional_writes
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def name(self):
|
|
93
|
+
"""AppProfile name used in requests.
|
|
94
|
+
|
|
95
|
+
.. note::
|
|
96
|
+
|
|
97
|
+
This property will not change if ``app_profile_id`` does not, but
|
|
98
|
+
the return value is not cached.
|
|
99
|
+
|
|
100
|
+
For example:
|
|
101
|
+
|
|
102
|
+
.. literalinclude:: snippets.py
|
|
103
|
+
:start-after: [START bigtable_api_app_profile_name]
|
|
104
|
+
:end-before: [END bigtable_api_app_profile_name]
|
|
105
|
+
:dedent: 4
|
|
106
|
+
|
|
107
|
+
The AppProfile name is of the form
|
|
108
|
+
``"projects/../instances/../app_profile/{app_profile_id}"``
|
|
109
|
+
|
|
110
|
+
:rtype: str
|
|
111
|
+
:returns: The AppProfile name.
|
|
112
|
+
"""
|
|
113
|
+
return self.instance_admin_client.app_profile_path(
|
|
114
|
+
self._instance._client.project,
|
|
115
|
+
self._instance.instance_id,
|
|
116
|
+
self.app_profile_id,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def instance_admin_client(self):
|
|
121
|
+
"""Shortcut to instance_admin_client
|
|
122
|
+
|
|
123
|
+
:rtype: :class:`.bigtable_admin_pb2.BigtableInstanceAdmin`
|
|
124
|
+
:returns: A BigtableInstanceAdmin instance.
|
|
125
|
+
"""
|
|
126
|
+
return self._instance._client.instance_admin_client
|
|
127
|
+
|
|
128
|
+
def __eq__(self, other):
|
|
129
|
+
if not isinstance(other, self.__class__):
|
|
130
|
+
return False
|
|
131
|
+
# NOTE: This does not compare the configuration values, such as
|
|
132
|
+
# the routing_policy_type. Instead, it only compares
|
|
133
|
+
# identifying values instance, AppProfile ID and client. This is
|
|
134
|
+
# intentional, since the same AppProfile can be in different
|
|
135
|
+
# states if not synchronized.
|
|
136
|
+
return (
|
|
137
|
+
other.app_profile_id == self.app_profile_id
|
|
138
|
+
and other._instance == self._instance
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
def __ne__(self, other):
|
|
142
|
+
return not self == other
|
|
143
|
+
|
|
144
|
+
@classmethod
|
|
145
|
+
def from_pb(cls, app_profile_pb, instance):
|
|
146
|
+
"""Creates an instance app_profile from a protobuf.
|
|
147
|
+
|
|
148
|
+
:type app_profile_pb: :class:`instance.app_profile_pb`
|
|
149
|
+
:param app_profile_pb: An instance protobuf object.
|
|
150
|
+
|
|
151
|
+
:type instance: :class:`google.cloud.bigtable.instance.Instance`
|
|
152
|
+
:param instance: The instance that owns the cluster.
|
|
153
|
+
|
|
154
|
+
:rtype: :class:`AppProfile`
|
|
155
|
+
:returns: The AppProfile parsed from the protobuf response.
|
|
156
|
+
|
|
157
|
+
:raises: :class:`ValueError <exceptions.ValueError>` if the AppProfile
|
|
158
|
+
name does not match
|
|
159
|
+
``projects/{project}/instances/{instance_id}/appProfiles/{app_profile_id}``
|
|
160
|
+
or if the parsed instance ID does not match the istance ID
|
|
161
|
+
on the client.
|
|
162
|
+
or if the parsed project ID does not match the project ID
|
|
163
|
+
on the client.
|
|
164
|
+
"""
|
|
165
|
+
match_app_profile_name = _APP_PROFILE_NAME_RE.match(app_profile_pb.name)
|
|
166
|
+
if match_app_profile_name is None:
|
|
167
|
+
raise ValueError(
|
|
168
|
+
"AppProfile protobuf name was not in the " "expected format.",
|
|
169
|
+
app_profile_pb.name,
|
|
170
|
+
)
|
|
171
|
+
if match_app_profile_name.group("instance") != instance.instance_id:
|
|
172
|
+
raise ValueError(
|
|
173
|
+
"Instance ID on app_profile does not match the "
|
|
174
|
+
"instance ID on the client"
|
|
175
|
+
)
|
|
176
|
+
if match_app_profile_name.group("project") != instance._client.project:
|
|
177
|
+
raise ValueError(
|
|
178
|
+
"Project ID on app_profile does not match the "
|
|
179
|
+
"project ID on the client"
|
|
180
|
+
)
|
|
181
|
+
app_profile_id = match_app_profile_name.group("app_profile_id")
|
|
182
|
+
|
|
183
|
+
result = cls(app_profile_id, instance)
|
|
184
|
+
result._update_from_pb(app_profile_pb)
|
|
185
|
+
return result
|
|
186
|
+
|
|
187
|
+
def _update_from_pb(self, app_profile_pb):
|
|
188
|
+
"""Refresh self from the server-provided protobuf.
|
|
189
|
+
Helper for :meth:`from_pb` and :meth:`reload`.
|
|
190
|
+
"""
|
|
191
|
+
self.routing_policy_type = None
|
|
192
|
+
self.allow_transactional_writes = None
|
|
193
|
+
self.cluster_id = None
|
|
194
|
+
self.multi_cluster_ids = None
|
|
195
|
+
self.description = app_profile_pb.description
|
|
196
|
+
|
|
197
|
+
routing_policy_type = None
|
|
198
|
+
if app_profile_pb._pb.HasField("multi_cluster_routing_use_any"):
|
|
199
|
+
routing_policy_type = RoutingPolicyType.ANY
|
|
200
|
+
self.allow_transactional_writes = False
|
|
201
|
+
if app_profile_pb.multi_cluster_routing_use_any.cluster_ids:
|
|
202
|
+
self.multi_cluster_ids = (
|
|
203
|
+
app_profile_pb.multi_cluster_routing_use_any.cluster_ids
|
|
204
|
+
)
|
|
205
|
+
else:
|
|
206
|
+
routing_policy_type = RoutingPolicyType.SINGLE
|
|
207
|
+
self.cluster_id = app_profile_pb.single_cluster_routing.cluster_id
|
|
208
|
+
self.allow_transactional_writes = (
|
|
209
|
+
app_profile_pb.single_cluster_routing.allow_transactional_writes
|
|
210
|
+
)
|
|
211
|
+
self.routing_policy_type = routing_policy_type
|
|
212
|
+
|
|
213
|
+
def _to_pb(self):
|
|
214
|
+
"""Create an AppProfile proto buff message for API calls
|
|
215
|
+
:rtype: :class:`.instance.AppProfile`
|
|
216
|
+
:returns: The converted current object.
|
|
217
|
+
|
|
218
|
+
:raises: :class:`ValueError <exceptions.ValueError>` if the AppProfile
|
|
219
|
+
routing_policy_type is not set
|
|
220
|
+
"""
|
|
221
|
+
if not self.routing_policy_type:
|
|
222
|
+
raise ValueError("AppProfile required routing policy.")
|
|
223
|
+
|
|
224
|
+
single_cluster_routing = None
|
|
225
|
+
multi_cluster_routing_use_any = None
|
|
226
|
+
|
|
227
|
+
if self.routing_policy_type == RoutingPolicyType.ANY:
|
|
228
|
+
multi_cluster_routing_use_any = (
|
|
229
|
+
instance.AppProfile.MultiClusterRoutingUseAny(
|
|
230
|
+
cluster_ids=self.multi_cluster_ids
|
|
231
|
+
)
|
|
232
|
+
)
|
|
233
|
+
else:
|
|
234
|
+
single_cluster_routing = instance.AppProfile.SingleClusterRouting(
|
|
235
|
+
cluster_id=self.cluster_id,
|
|
236
|
+
allow_transactional_writes=self.allow_transactional_writes,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
app_profile_pb = instance.AppProfile(
|
|
240
|
+
name=self.name,
|
|
241
|
+
description=self.description,
|
|
242
|
+
multi_cluster_routing_use_any=multi_cluster_routing_use_any,
|
|
243
|
+
single_cluster_routing=single_cluster_routing,
|
|
244
|
+
)
|
|
245
|
+
return app_profile_pb
|
|
246
|
+
|
|
247
|
+
def reload(self):
|
|
248
|
+
"""Reload the metadata for this cluster
|
|
249
|
+
|
|
250
|
+
For example:
|
|
251
|
+
|
|
252
|
+
.. literalinclude:: snippets.py
|
|
253
|
+
:start-after: [START bigtable_api_reload_app_profile]
|
|
254
|
+
:end-before: [END bigtable_api_reload_app_profile]
|
|
255
|
+
:dedent: 4
|
|
256
|
+
"""
|
|
257
|
+
|
|
258
|
+
app_profile_pb = self.instance_admin_client.get_app_profile(
|
|
259
|
+
request={"name": self.name}
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# NOTE: _update_from_pb does not check that the project and
|
|
263
|
+
# app_profile ID on the response match the request.
|
|
264
|
+
self._update_from_pb(app_profile_pb)
|
|
265
|
+
|
|
266
|
+
def exists(self):
|
|
267
|
+
"""Check whether the AppProfile already exists.
|
|
268
|
+
|
|
269
|
+
For example:
|
|
270
|
+
|
|
271
|
+
.. literalinclude:: snippets.py
|
|
272
|
+
:start-after: [START bigtable_api_app_profile_exists]
|
|
273
|
+
:end-before: [END bigtable_api_app_profile_exists]
|
|
274
|
+
:dedent: 4
|
|
275
|
+
|
|
276
|
+
:rtype: bool
|
|
277
|
+
:returns: True if the AppProfile exists, else False.
|
|
278
|
+
"""
|
|
279
|
+
try:
|
|
280
|
+
self.instance_admin_client.get_app_profile(request={"name": self.name})
|
|
281
|
+
return True
|
|
282
|
+
# NOTE: There could be other exceptions that are returned to the user.
|
|
283
|
+
except NotFound:
|
|
284
|
+
return False
|
|
285
|
+
|
|
286
|
+
def create(self, ignore_warnings=None):
|
|
287
|
+
"""Create this AppProfile.
|
|
288
|
+
|
|
289
|
+
.. note::
|
|
290
|
+
|
|
291
|
+
Uses the ``instance`` and ``app_profile_id`` on the current
|
|
292
|
+
:class:`AppProfile` in addition to the ``routing_policy_type``,
|
|
293
|
+
``description``, ``cluster_id`` and ``allow_transactional_writes``.
|
|
294
|
+
To change them before creating, reset the values via
|
|
295
|
+
|
|
296
|
+
For example:
|
|
297
|
+
|
|
298
|
+
.. literalinclude:: snippets.py
|
|
299
|
+
:start-after: [START bigtable_api_create_app_profile]
|
|
300
|
+
:end-before: [END bigtable_api_create_app_profile]
|
|
301
|
+
:dedent: 4
|
|
302
|
+
|
|
303
|
+
:type: ignore_warnings: bool
|
|
304
|
+
:param: ignore_warnings: (Optional) If true, ignore safety checks when
|
|
305
|
+
creating the AppProfile.
|
|
306
|
+
"""
|
|
307
|
+
return self.from_pb(
|
|
308
|
+
self.instance_admin_client.create_app_profile(
|
|
309
|
+
request={
|
|
310
|
+
"parent": self._instance.name,
|
|
311
|
+
"app_profile_id": self.app_profile_id,
|
|
312
|
+
"app_profile": self._to_pb(),
|
|
313
|
+
"ignore_warnings": ignore_warnings,
|
|
314
|
+
}
|
|
315
|
+
),
|
|
316
|
+
self._instance,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
def update(self, ignore_warnings=None):
|
|
320
|
+
"""Update this app_profile.
|
|
321
|
+
|
|
322
|
+
.. note::
|
|
323
|
+
|
|
324
|
+
Update any or all of the following values:
|
|
325
|
+
``routing_policy_type``
|
|
326
|
+
``description``
|
|
327
|
+
``cluster_id``
|
|
328
|
+
``multi_cluster_ids``
|
|
329
|
+
``allow_transactional_writes``
|
|
330
|
+
|
|
331
|
+
For example:
|
|
332
|
+
|
|
333
|
+
.. literalinclude:: snippets.py
|
|
334
|
+
:start-after: [START bigtable_api_update_app_profile]
|
|
335
|
+
:end-before: [END bigtable_api_update_app_profile]
|
|
336
|
+
:dedent: 4
|
|
337
|
+
"""
|
|
338
|
+
update_mask_pb = field_mask_pb2.FieldMask()
|
|
339
|
+
|
|
340
|
+
if self.description is not None:
|
|
341
|
+
update_mask_pb.paths.append("description")
|
|
342
|
+
|
|
343
|
+
if self.routing_policy_type == RoutingPolicyType.ANY:
|
|
344
|
+
update_mask_pb.paths.append("multi_cluster_routing_use_any")
|
|
345
|
+
else:
|
|
346
|
+
update_mask_pb.paths.append("single_cluster_routing")
|
|
347
|
+
|
|
348
|
+
return self.instance_admin_client.update_app_profile(
|
|
349
|
+
request={
|
|
350
|
+
"app_profile": self._to_pb(),
|
|
351
|
+
"update_mask": update_mask_pb,
|
|
352
|
+
"ignore_warnings": ignore_warnings,
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
def delete(self, ignore_warnings=None):
|
|
357
|
+
"""Delete this AppProfile.
|
|
358
|
+
|
|
359
|
+
For example:
|
|
360
|
+
|
|
361
|
+
.. literalinclude:: snippets.py
|
|
362
|
+
:start-after: [START bigtable_api_delete_app_profile]
|
|
363
|
+
:end-before: [END bigtable_api_delete_app_profile]
|
|
364
|
+
:dedent: 4
|
|
365
|
+
|
|
366
|
+
:type: ignore_warnings: bool
|
|
367
|
+
:param: ignore_warnings: If true, ignore safety checks when deleting
|
|
368
|
+
the AppProfile.
|
|
369
|
+
|
|
370
|
+
:raises: google.api_core.exceptions.GoogleAPICallError: If the request
|
|
371
|
+
failed for any reason. google.api_core.exceptions.RetryError:
|
|
372
|
+
If the request failed due to a retryable error and retry
|
|
373
|
+
attempts failed. ValueError: If the parameters are invalid.
|
|
374
|
+
"""
|
|
375
|
+
self.instance_admin_client.delete_app_profile(
|
|
376
|
+
request={"name": self.name, "ignore_warnings": ignore_warnings}
|
|
377
|
+
)
|