1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17+ import re
1718from enum import Enum
1819from typing import (
1920 TYPE_CHECKING ,
8283ICEBERG_REST_SPEC_VERSION = "0.14.1"
8384
8485
86+ CAMEL_TO_SNAKE_CASE_PATTERN = re .compile (r"(?<!^)(?=[A-Z])" )
87+
88+
8589class Endpoints :
8690 get_config : str = "config"
8791 list_namespaces : str = "namespaces"
@@ -104,6 +108,28 @@ class Endpoints:
104108 view_exists : str = "namespaces/{namespace}/views/{view}"
105109
106110
111+ ENDPOINT_PARAMS_MAP : dict [str , tuple [str ]] = {
112+ Endpoints .drop_table : ("purgeRequested" ,),
113+ }
114+
115+
116+ def _get_endpoint_params (endpoint : str , ** kwargs : Any ) -> dict [str , Any ] | None :
117+ """Get the query parameters for the endpoint."""
118+ if not kwargs or endpoint not in ENDPOINT_PARAMS_MAP :
119+ return None
120+
121+ snake_case_query_params = {
122+ param : CAMEL_TO_SNAKE_CASE_PATTERN .sub ("_" , param ).lower () for param in ENDPOINT_PARAMS_MAP [endpoint ]
123+ }
124+
125+ _params = {}
126+ for camel , snake in snake_case_query_params .items ():
127+ if snake in kwargs :
128+ _params [camel ] = kwargs [snake ]
129+
130+ return _params
131+
132+
107133class IdentifierKind (Enum ):
108134 TABLE = "table"
109135 VIEW = "view"
@@ -584,7 +610,9 @@ def register_table(self, identifier: Union[str, Identifier], metadata_location:
584610 return self ._response_to_table (self .identifier_to_tuple (identifier ), table_response )
585611
586612 @retry (** _RETRY_ARGS )
587- def list_tables (self , namespace : Union [str , Identifier ]) -> List [Identifier ]:
613+ def list_tables (
614+ self , namespace : Union [str , Identifier ], page_token : str | None = None , page_size : int | None = None
615+ ) -> List [Identifier ]:
588616 namespace_tuple = self ._check_valid_namespace_identifier (namespace )
589617 namespace_concat = NAMESPACE_SEPARATOR .join (namespace_tuple )
590618 response = self ._session .get (self .url (Endpoints .list_tables , namespace = namespace_concat ))
@@ -616,8 +644,9 @@ def load_table(self, identifier: Union[str, Identifier]) -> Table:
616644
617645 @retry (** _RETRY_ARGS )
618646 def drop_table (self , identifier : Union [str , Identifier ], purge_requested : bool = False ) -> None :
647+ params = _get_endpoint_params (Endpoints .drop_table , purge_requested = purge_requested )
619648 response = self ._session .delete (
620- self .url (Endpoints .drop_table , prefixed = True , purge = purge_requested , ** self ._split_identifier_for_path (identifier )),
649+ self .url (Endpoints .drop_table , prefixed = True , ** self ._split_identifier_for_path (identifier )), params = params
621650 )
622651 try :
623652 response .raise_for_status ()
0 commit comments