Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 60d4199

Browse files
authored
refactor: Refactored classic client to use new Admin API (#1114)
* refactor: Refactored classic client to use new Admin API * added newline after gapic_version files
1 parent 8a6ff11 commit 60d4199

21 files changed

Lines changed: 218 additions & 187 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 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+
__version__ = "2.30.1" # {x-release-please-version}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 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+
__version__ = "2.30.1" # {x-release-please-version}

google/cloud/bigtable/app_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import re
1919

2020
from google.cloud.bigtable.enums import RoutingPolicyType
21-
from google.cloud.bigtable_admin_v2.types import instance
21+
from google.cloud.bigtable.admin_v2.types import instance
2222
from google.protobuf import field_mask_pb2
2323
from google.api_core.exceptions import NotFound
2424

google/cloud/bigtable/backup.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import re
1818

1919
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
20-
from google.cloud.bigtable_admin_v2 import BigtableTableAdminClient
21-
from google.cloud.bigtable_admin_v2.types import table
20+
from google.cloud.bigtable.admin_v2 import BaseBigtableTableAdminClient
21+
from google.cloud.bigtable.admin_v2.types import table
2222
from google.cloud.bigtable.encryption_info import EncryptionInfo
2323
from google.cloud.bigtable.policy import Policy
2424
from google.cloud.exceptions import NotFound # type: ignore
@@ -106,7 +106,7 @@ def name(self):
106106
if not self._cluster:
107107
raise ValueError('"cluster" parameter must be set')
108108

109-
return BigtableTableAdminClient.backup_path(
109+
return BaseBigtableTableAdminClient.backup_path(
110110
project=self._instance._client.project,
111111
instance=self._instance.instance_id,
112112
cluster=self._cluster,
@@ -141,7 +141,7 @@ def parent(self):
141141
:returns: A full path to the parent cluster.
142142
"""
143143
if not self._parent and self._cluster:
144-
self._parent = BigtableTableAdminClient.cluster_path(
144+
self._parent = BaseBigtableTableAdminClient.cluster_path(
145145
project=self._instance._client.project,
146146
instance=self._instance.instance_id,
147147
cluster=self._cluster,
@@ -163,7 +163,7 @@ def source_table(self):
163163
:returns: The Table name.
164164
"""
165165
if not self._source_table and self.table_id:
166-
self._source_table = BigtableTableAdminClient.table_path(
166+
self._source_table = BaseBigtableTableAdminClient.table_path(
167167
project=self._instance._client.project,
168168
instance=self._instance.instance_id,
169169
table=self.table_id,
@@ -226,7 +226,7 @@ def size_bytes(self):
226226
def state(self):
227227
"""The current state of this Backup.
228228
229-
:rtype: :class:`~google.cloud.bigtable_admin_v2.gapic.enums.Backup.State`
229+
:rtype: :class:`~google.cloud.bigtable.admin_v2.types.table.Backup.State`
230230
:returns: The current state of this Backup.
231231
"""
232232
return self._state
@@ -305,8 +305,7 @@ def create(self, cluster_id=None):
305305
created Backup.
306306
307307
:rtype: :class:`~google.api_core.operation.Operation`
308-
:returns: :class:`~google.cloud.bigtable_admin_v2.types._OperationFuture`
309-
instance, to be used to poll the status of the 'create' request
308+
:returns: A future to be used to poll the status of the 'create' request
310309
:raises Conflict: if the Backup already exists
311310
:raises NotFound: if the Instance owning the Backup does not exist
312311
:raises BadRequest: if the `table` or `expire_time` values are invalid,
@@ -343,7 +342,7 @@ def get(self):
343342
"""Retrieves metadata of a pending or completed Backup.
344343
345344
:returns: An instance of
346-
:class:`~google.cloud.bigtable_admin_v2.types.Backup`
345+
:class:`~google.cloud.bigtable.admin_v2.types.Backup`
347346
348347
:raises google.api_core.exceptions.GoogleAPICallError: If the request
349348
failed for any reason.
@@ -412,7 +411,7 @@ def restore(self, table_id, instance_id=None):
412411
:param instance_id: (Optional) The ID of the Instance to restore the
413412
backup into, if different from the current one.
414413
415-
:rtype: :class:`~google.cloud.bigtable_admin_v2.types._OperationFuture`
414+
:rtype: :class:`~google.api_core.operation.Operation`
416415
:returns: A future to be used to poll the status of the 'restore'
417416
request.
418417
@@ -426,14 +425,14 @@ def restore(self, table_id, instance_id=None):
426425
"""
427426
api = self._instance._client.table_admin_client
428427
if instance_id:
429-
parent = BigtableTableAdminClient.instance_path(
428+
parent = BaseBigtableTableAdminClient.instance_path(
430429
project=self._instance._client.project,
431430
instance=instance_id,
432431
)
433432
else:
434433
parent = self._instance.name
435434

436-
return api.restore_table(
435+
return api._restore_table(
437436
request={"parent": parent, "table_id": table_id, "backup": self.name}
438437
)
439438

google/cloud/bigtable/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
from google.auth.credentials import AnonymousCredentials # type: ignore
3636

3737
from google.cloud import bigtable_v2
38-
from google.cloud import bigtable_admin_v2
38+
from google.cloud.bigtable import admin_v2
3939
from google.cloud.bigtable_v2.services.bigtable.transports import BigtableGrpcTransport
40-
from google.cloud.bigtable_admin_v2.services.bigtable_instance_admin.transports import (
40+
from google.cloud.bigtable.admin_v2.services.bigtable_instance_admin.transports import (
4141
BigtableInstanceAdminGrpcTransport,
4242
)
43-
from google.cloud.bigtable_admin_v2.services.bigtable_table_admin.transports import (
43+
from google.cloud.bigtable.admin_v2.services.bigtable_table_admin.transports import (
4444
BigtableTableAdminGrpcTransport,
4545
)
4646

@@ -50,7 +50,7 @@
5050

5151
from google.cloud.client import ClientWithProject # type: ignore
5252

53-
from google.cloud.bigtable_admin_v2.types import instance
53+
from google.cloud.bigtable.admin_v2.types import instance
5454
from google.cloud.bigtable.cluster import _CLUSTER_NAME_RE
5555
from google.cloud.environment_vars import BIGTABLE_EMULATOR # type: ignore
5656

@@ -325,11 +325,11 @@ def table_admin_client(self):
325325
raise ValueError("Client is not an admin client.")
326326

327327
transport = self._create_gapic_client_channel(
328-
bigtable_admin_v2.BigtableTableAdminClient,
328+
admin_v2.BaseBigtableTableAdminClient,
329329
BigtableTableAdminGrpcTransport,
330330
)
331331
klass = _create_gapic_client(
332-
bigtable_admin_v2.BigtableTableAdminClient,
332+
admin_v2.BaseBigtableTableAdminClient,
333333
client_options=self._admin_client_options,
334334
transport=transport,
335335
)
@@ -358,11 +358,11 @@ def instance_admin_client(self):
358358
raise ValueError("Client is not an admin client.")
359359

360360
transport = self._create_gapic_client_channel(
361-
bigtable_admin_v2.BigtableInstanceAdminClient,
361+
admin_v2.BigtableInstanceAdminClient,
362362
BigtableInstanceAdminGrpcTransport,
363363
)
364364
klass = _create_gapic_client(
365-
bigtable_admin_v2.BigtableInstanceAdminClient,
365+
admin_v2.BigtableInstanceAdminClient,
366366
client_options=self._admin_client_options,
367367
transport=transport,
368368
)

google/cloud/bigtable/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
import re
19-
from google.cloud.bigtable_admin_v2.types import instance
19+
from google.cloud.bigtable.admin_v2.types import instance
2020
from google.api_core.exceptions import NotFound
2121
from google.protobuf import field_mask_pb2
2222

google/cloud/bigtable/column_family.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717

1818
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 (
19+
from google.cloud.bigtable.admin_v2.types import table as table_v2_pb2
20+
from google.cloud.bigtable.admin_v2.types import (
2121
bigtable_table_admin as table_admin_v2_pb2,
2222
)
2323
from google.api_core.gapic_v1.method import DEFAULT
@@ -275,7 +275,7 @@ def create(self):
275275
client = self._table._instance._client
276276
# data it contains are the GC rule and the column family ID already
277277
# stored on this instance.
278-
client.table_admin_client.modify_column_families(
278+
client.table_admin_client._modify_column_families(
279279
request={"name": self._table.name, "modifications": [modification]},
280280
timeout=DEFAULT,
281281
)
@@ -303,7 +303,7 @@ def update(self):
303303
client = self._table._instance._client
304304
# data it contains are the GC rule and the column family ID already
305305
# stored on this instance.
306-
client.table_admin_client.modify_column_families(
306+
client.table_admin_client._modify_column_families(
307307
request={"name": self._table.name, "modifications": [modification]},
308308
timeout=DEFAULT,
309309
)
@@ -326,7 +326,7 @@ def delete(self):
326326
client = self._table._instance._client
327327
# data it contains are the GC rule and the column family ID already
328328
# stored on this instance.
329-
client.table_admin_client.modify_column_families(
329+
client.table_admin_client._modify_column_families(
330330
request={"name": self._table.name, "modifications": [modification]},
331331
timeout=DEFAULT,
332332
)

google/cloud/bigtable/enums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# limitations under the License.
1414
"""Wrappers for gapic enum types."""
1515

16-
from google.cloud.bigtable_admin_v2.types import common
17-
from google.cloud.bigtable_admin_v2.types import instance
18-
from google.cloud.bigtable_admin_v2.types import table
16+
from google.cloud.bigtable.admin_v2.types import common
17+
from google.cloud.bigtable.admin_v2.types import instance
18+
from google.cloud.bigtable.admin_v2.types import table
1919

2020

2121
class StorageType(object):

google/cloud/bigtable/instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from google.protobuf import field_mask_pb2
2424

25-
from google.cloud.bigtable_admin_v2.types import instance
25+
from google.cloud.bigtable.admin_v2.types import instance
2626

2727
from google.iam.v1 import options_pb2 # type: ignore
2828

google/cloud/bigtable/table.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
from google.cloud.bigtable.row_set import RowRange
4848
from google.cloud.bigtable import enums
4949
from google.cloud.bigtable_v2.types import bigtable as data_messages_v2_pb2
50-
from google.cloud.bigtable_admin_v2 import BigtableTableAdminClient
51-
from google.cloud.bigtable_admin_v2.types import table as admin_messages_v2_pb2
52-
from google.cloud.bigtable_admin_v2.types import (
50+
from google.cloud.bigtable.admin_v2 import BaseBigtableTableAdminClient
51+
from google.cloud.bigtable.admin_v2.types import table as admin_messages_v2_pb2
52+
from google.cloud.bigtable.admin_v2.types import (
5353
bigtable_table_admin as table_admin_messages_v2_pb2,
5454
)
5555

@@ -990,7 +990,7 @@ def list_backups(self, cluster_id=None, filter_=None, order_by=None, page_size=0
990990
if filter_:
991991
backups_filter = "({}) AND ({})".format(backups_filter, filter_)
992992

993-
parent = BigtableTableAdminClient.cluster_path(
993+
parent = BaseBigtableTableAdminClient.cluster_path(
994994
project=self._instance._client.project,
995995
instance=self._instance.instance_id,
996996
cluster=cluster_id,
@@ -1037,7 +1037,7 @@ def restore(self, new_table_id, cluster_id=None, backup_id=None, backup_name=Non
10371037
and `backup_id` parameters even of such specified.
10381038
10391039
:return: An instance of
1040-
:class:`~google.cloud.bigtable_admin_v2.types._OperationFuture`.
1040+
:class:`~google.api_core.operation.Operation`.
10411041
10421042
:raises: google.api_core.exceptions.AlreadyExists: If the table
10431043
already exists.
@@ -1049,13 +1049,13 @@ def restore(self, new_table_id, cluster_id=None, backup_id=None, backup_name=Non
10491049
"""
10501050
api = self._instance._client.table_admin_client
10511051
if not backup_name:
1052-
backup_name = BigtableTableAdminClient.backup_path(
1052+
backup_name = BaseBigtableTableAdminClient.backup_path(
10531053
project=self._instance._client.project,
10541054
instance=self._instance.instance_id,
10551055
cluster=cluster_id,
10561056
backup=backup_id,
10571057
)
1058-
return api.restore_table(
1058+
return api._restore_table(
10591059
request={
10601060
"parent": self._instance.name,
10611061
"table_id": new_table_id,

0 commit comments

Comments
 (0)