From 8cc89352a39ce1fbe763b0541b6ac310e2db2c03 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Thu, 5 Nov 2026 16:26:54 +0000 Subject: [PATCH 1/2] chore(bigtable): deprecate legacy handwritten Client and Instance admin methods Add DeprecationWarning and Sphinx deprecated directives to handwritten admin methods on Client and Instance in favor of BigtableInstanceAdminClient and BigtableTableAdminClient. --- .../google/cloud/bigtable/client.py | 32 ++++ .../google/cloud/bigtable/instance.py | 141 ++++++++++++++++++ 2 files changed, 173 insertions(+) diff --git a/packages/google-cloud-bigtable/google/cloud/bigtable/client.py b/packages/google-cloud-bigtable/google/cloud/bigtable/client.py index 02c94b3eb724..df87e9d76197 100644 --- a/packages/google-cloud-bigtable/google/cloud/bigtable/client.py +++ b/packages/google-cloud-bigtable/google/cloud/bigtable/client.py @@ -291,6 +291,10 @@ def table_data_client(self): def table_admin_client(self): """Getter for the gRPC stub used for the Table Admin API. + .. deprecated:: 2.30.0 + Use :class:`google.cloud.bigtable_admin_v2.BigtableTableAdminClient` + instead. + For example: .. literalinclude:: snippets.py @@ -324,6 +328,10 @@ def table_admin_client(self): def instance_admin_client(self): """Getter for the gRPC stub used for the Table Admin API. + .. deprecated:: 2.30.0 + Use :class:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient` + instead. + For example: .. literalinclude:: snippets.py @@ -423,6 +431,11 @@ def instance(self, instance_id, display_name=None, instance_type=None, labels=No def list_instances(self): """List instances owned by the project. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.list_instances` + instead. + For example: .. literalinclude:: snippets.py @@ -437,6 +450,13 @@ def list_instances(self): 'failed_locations' is a list of locations which could not be resolved. """ + warnings.warn( + "Client.list_instances is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "list_instances instead.", + DeprecationWarning, + stacklevel=2, + ) resp = self.instance_admin_client.list_instances( request={"parent": self.project_path} ) @@ -446,6 +466,11 @@ def list_instances(self): def list_clusters(self): """List the clusters in the project. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.list_clusters` + instead. + For example: .. literalinclude:: snippets.py @@ -460,6 +485,13 @@ def list_clusters(self): 'failed_locations' is a list of strings representing locations which could not be resolved. """ + warnings.warn( + "Client.list_clusters is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "list_clusters instead.", + DeprecationWarning, + stacklevel=2, + ) resp = self.instance_admin_client.list_clusters( request={ "parent": self.instance_admin_client.instance_path(self.project, "-") diff --git a/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py b/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py index db5d67e270d8..9570c4e85cce 100644 --- a/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py +++ b/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py @@ -229,6 +229,11 @@ def create( ): """Create this instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.create_instance` + instead. + For example: .. literalinclude:: snippets.py @@ -319,6 +324,14 @@ def create( default_storage_type can not be set \ simultaneously." ) + else: + warnings.warn( + "Instance.create is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "create_instance instead.", + DeprecationWarning, + stacklevel=2, + ) instance_pb = instance.Instance( display_name=self.display_name, type_=self.type_, labels=self.labels @@ -338,6 +351,11 @@ def create( def exists(self): """Check whether the instance already exists. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.get_instance` + instead. + For example: .. literalinclude:: snippets.py @@ -348,6 +366,13 @@ def exists(self): :rtype: bool :returns: True if the table exists, else False. """ + warnings.warn( + "Instance.exists is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "get_instance instead.", + DeprecationWarning, + stacklevel=2, + ) try: self._client.instance_admin_client.get_instance(request={"name": self.name}) return True @@ -358,6 +383,11 @@ def exists(self): def reload(self): """Reload the metadata for this instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.get_instance` + instead. + For example: .. literalinclude:: snippets.py @@ -365,6 +395,13 @@ def reload(self): :end-before: [END bigtable_api_reload_instance] :dedent: 4 """ + warnings.warn( + "Instance.reload is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "get_instance instead.", + DeprecationWarning, + stacklevel=2, + ) instance_pb = self._client.instance_admin_client.get_instance( request={"name": self.name} ) @@ -376,6 +413,11 @@ def reload(self): def update(self): """Updates an instance within a project. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.partial_update_instance` + instead. + For example: .. literalinclude:: snippets.py @@ -402,6 +444,13 @@ def update(self): :returns: The long-running operation corresponding to the update operation. """ + warnings.warn( + "Instance.update is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "partial_update_instance instead.", + DeprecationWarning, + stacklevel=2, + ) update_mask_pb = field_mask_pb2.FieldMask() if self.display_name is not None: update_mask_pb.paths.append("display_name") @@ -423,6 +472,11 @@ def update(self): def delete(self): """Delete this instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.delete_instance` + instead. + For example: .. literalinclude:: snippets.py @@ -449,11 +503,23 @@ def delete(self): irrevocably disappear from the API, and their data will be permanently deleted. """ + warnings.warn( + "Instance.delete is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "delete_instance instead.", + DeprecationWarning, + stacklevel=2, + ) self._client.instance_admin_client.delete_instance(request={"name": self.name}) def get_iam_policy(self, requested_policy_version=None): """Gets the access control policy for an instance resource. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.get_iam_policy` + instead. + For example: .. literalinclude:: snippets.py @@ -476,6 +542,13 @@ def get_iam_policy(self, requested_policy_version=None): :rtype: :class:`google.cloud.bigtable.policy.Policy` :returns: The current IAM policy of this instance """ + warnings.warn( + "Instance.get_iam_policy is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "get_iam_policy instead.", + DeprecationWarning, + stacklevel=2, + ) args = {"resource": self.name} if requested_policy_version is not None: args["options_"] = options_pb2.GetPolicyOptions( @@ -491,6 +564,11 @@ def set_iam_policy(self, policy): """Sets the access control policy on an instance resource. Replaces any existing policy. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.set_iam_policy` + instead. + For more information about policy, please see documentation of class `google.cloud.bigtable.policy.Policy` @@ -508,6 +586,13 @@ class `google.cloud.bigtable.policy.Policy` :rtype: :class:`google.cloud.bigtable.policy.Policy` :returns: The current IAM policy of this instance. """ + warnings.warn( + "Instance.set_iam_policy is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "set_iam_policy instead.", + DeprecationWarning, + stacklevel=2, + ) instance_admin_client = self._client.instance_admin_client resp = instance_admin_client.set_iam_policy( request={"resource": self.name, "policy": policy.to_pb()} @@ -518,6 +603,11 @@ def test_iam_permissions(self, permissions): """Returns permissions that the caller has on the specified instance resource. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.test_iam_permissions` + instead. + For example: .. literalinclude:: snippets.py @@ -537,6 +627,13 @@ def test_iam_permissions(self, permissions): :rtype: list :returns: A List(string) of permissions allowed on the instance """ + warnings.warn( + "Instance.test_iam_permissions is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "test_iam_permissions instead.", + DeprecationWarning, + stacklevel=2, + ) instance_admin_client = self._client.instance_admin_client resp = instance_admin_client.test_iam_permissions( request={"resource": self.name, "permissions": permissions} @@ -556,6 +653,10 @@ def cluster( ): """Factory to create a cluster associated with this instance. + .. deprecated:: 2.30.0 + Use :class:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient` + instead. + For example: .. literalinclude:: snippets.py @@ -620,6 +721,11 @@ def cluster( def list_clusters(self): """List the clusters in this instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.list_clusters` + instead. + For example: .. literalinclude:: snippets.py @@ -634,6 +740,13 @@ def list_clusters(self): 'failed_locations' is a list of locations which could not be resolved. """ + warnings.warn( + "Instance.list_clusters is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "list_clusters instead.", + DeprecationWarning, + stacklevel=2, + ) resp = self._client.instance_admin_client.list_clusters( request={"parent": self.name} ) @@ -672,6 +785,11 @@ def table(self, table_id, mutation_timeout=None, app_profile_id=None): def list_tables(self): """List the tables in this instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableTableAdminClient.list_tables` + instead. + For example: .. literalinclude:: snippets.py @@ -684,6 +802,13 @@ def list_tables(self): :raises: :class:`ValueError ` if one of the returned tables has a name that is not of the expected format. """ + warnings.warn( + "Instance.list_tables is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableTableAdminClient." + "list_tables instead.", + DeprecationWarning, + stacklevel=2, + ) table_list_pb = self._client.table_admin_client.list_tables( request={"parent": self.name} ) @@ -711,6 +836,10 @@ def app_profile( ): """Factory to create AppProfile associated with this instance. + .. deprecated:: 2.30.0 + Use :class:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient` + instead. + For example: .. literalinclude:: snippets.py @@ -764,6 +893,11 @@ def app_profile( def list_app_profiles(self): """Lists information about AppProfiles in an instance. + .. deprecated:: 2.30.0 + Use + :meth:`google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient.list_app_profiles` + instead. + For example: .. literalinclude:: snippets.py @@ -777,6 +911,13 @@ def list_app_profiles(self): :class:`~google.cloud.bigtable.app_profile.AppProfile` instances. """ + warnings.warn( + "Instance.list_app_profiles is deprecated. Use " + "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." + "list_app_profiles instead.", + DeprecationWarning, + stacklevel=2, + ) resp = self._client.instance_admin_client.list_app_profiles( request={"parent": self.name} ) From 4fc27523d84b98c9f3198509b95168d37d043825 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Thu, 5 Nov 2026 19:51:24 +0000 Subject: [PATCH 2/2] docs(bigtable): remove runtime DeprecationWarning from Client and Instance admin methods Keep only the Sphinx .. deprecated:: 2.30.0 docstring notices without emitting runtime warnings. --- .../google/cloud/bigtable/client.py | 14 ---- .../google/cloud/bigtable/instance.py | 78 ------------------- 2 files changed, 92 deletions(-) diff --git a/packages/google-cloud-bigtable/google/cloud/bigtable/client.py b/packages/google-cloud-bigtable/google/cloud/bigtable/client.py index df87e9d76197..602997d000a4 100644 --- a/packages/google-cloud-bigtable/google/cloud/bigtable/client.py +++ b/packages/google-cloud-bigtable/google/cloud/bigtable/client.py @@ -450,13 +450,6 @@ def list_instances(self): 'failed_locations' is a list of locations which could not be resolved. """ - warnings.warn( - "Client.list_instances is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "list_instances instead.", - DeprecationWarning, - stacklevel=2, - ) resp = self.instance_admin_client.list_instances( request={"parent": self.project_path} ) @@ -485,13 +478,6 @@ def list_clusters(self): 'failed_locations' is a list of strings representing locations which could not be resolved. """ - warnings.warn( - "Client.list_clusters is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "list_clusters instead.", - DeprecationWarning, - stacklevel=2, - ) resp = self.instance_admin_client.list_clusters( request={ "parent": self.instance_admin_client.instance_path(self.project, "-") diff --git a/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py b/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py index 9570c4e85cce..eb04ef3a7611 100644 --- a/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py +++ b/packages/google-cloud-bigtable/google/cloud/bigtable/instance.py @@ -324,14 +324,6 @@ def create( default_storage_type can not be set \ simultaneously." ) - else: - warnings.warn( - "Instance.create is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "create_instance instead.", - DeprecationWarning, - stacklevel=2, - ) instance_pb = instance.Instance( display_name=self.display_name, type_=self.type_, labels=self.labels @@ -366,13 +358,6 @@ def exists(self): :rtype: bool :returns: True if the table exists, else False. """ - warnings.warn( - "Instance.exists is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "get_instance instead.", - DeprecationWarning, - stacklevel=2, - ) try: self._client.instance_admin_client.get_instance(request={"name": self.name}) return True @@ -395,13 +380,6 @@ def reload(self): :end-before: [END bigtable_api_reload_instance] :dedent: 4 """ - warnings.warn( - "Instance.reload is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "get_instance instead.", - DeprecationWarning, - stacklevel=2, - ) instance_pb = self._client.instance_admin_client.get_instance( request={"name": self.name} ) @@ -444,13 +422,6 @@ def update(self): :returns: The long-running operation corresponding to the update operation. """ - warnings.warn( - "Instance.update is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "partial_update_instance instead.", - DeprecationWarning, - stacklevel=2, - ) update_mask_pb = field_mask_pb2.FieldMask() if self.display_name is not None: update_mask_pb.paths.append("display_name") @@ -503,13 +474,6 @@ def delete(self): irrevocably disappear from the API, and their data will be permanently deleted. """ - warnings.warn( - "Instance.delete is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "delete_instance instead.", - DeprecationWarning, - stacklevel=2, - ) self._client.instance_admin_client.delete_instance(request={"name": self.name}) def get_iam_policy(self, requested_policy_version=None): @@ -542,13 +506,6 @@ def get_iam_policy(self, requested_policy_version=None): :rtype: :class:`google.cloud.bigtable.policy.Policy` :returns: The current IAM policy of this instance """ - warnings.warn( - "Instance.get_iam_policy is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "get_iam_policy instead.", - DeprecationWarning, - stacklevel=2, - ) args = {"resource": self.name} if requested_policy_version is not None: args["options_"] = options_pb2.GetPolicyOptions( @@ -586,13 +543,6 @@ class `google.cloud.bigtable.policy.Policy` :rtype: :class:`google.cloud.bigtable.policy.Policy` :returns: The current IAM policy of this instance. """ - warnings.warn( - "Instance.set_iam_policy is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "set_iam_policy instead.", - DeprecationWarning, - stacklevel=2, - ) instance_admin_client = self._client.instance_admin_client resp = instance_admin_client.set_iam_policy( request={"resource": self.name, "policy": policy.to_pb()} @@ -627,13 +577,6 @@ def test_iam_permissions(self, permissions): :rtype: list :returns: A List(string) of permissions allowed on the instance """ - warnings.warn( - "Instance.test_iam_permissions is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "test_iam_permissions instead.", - DeprecationWarning, - stacklevel=2, - ) instance_admin_client = self._client.instance_admin_client resp = instance_admin_client.test_iam_permissions( request={"resource": self.name, "permissions": permissions} @@ -740,13 +683,6 @@ def list_clusters(self): 'failed_locations' is a list of locations which could not be resolved. """ - warnings.warn( - "Instance.list_clusters is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "list_clusters instead.", - DeprecationWarning, - stacklevel=2, - ) resp = self._client.instance_admin_client.list_clusters( request={"parent": self.name} ) @@ -802,13 +738,6 @@ def list_tables(self): :raises: :class:`ValueError ` if one of the returned tables has a name that is not of the expected format. """ - warnings.warn( - "Instance.list_tables is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableTableAdminClient." - "list_tables instead.", - DeprecationWarning, - stacklevel=2, - ) table_list_pb = self._client.table_admin_client.list_tables( request={"parent": self.name} ) @@ -911,13 +840,6 @@ def list_app_profiles(self): :class:`~google.cloud.bigtable.app_profile.AppProfile` instances. """ - warnings.warn( - "Instance.list_app_profiles is deprecated. Use " - "google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient." - "list_app_profiles instead.", - DeprecationWarning, - stacklevel=2, - ) resp = self._client.instance_admin_client.list_app_profiles( request={"parent": self.name} )