@@ -74,8 +74,14 @@ class HiveConnectionDTO(ConnectionDTO):
7474
7575
7676@dataclass
77- class IcebergRESTCatalogS3ConnectionBaseDTO (ConnectionDTO ):
77+ class IcebergConnectionBaseDTO (ConnectionDTO ):
7878 rest_catalog_url : str
79+ flavor : ClassVar [str ]
80+ type : ClassVar [str ] = "iceberg"
81+
82+
83+ @dataclass
84+ class IcebergRESTCatalogS3DirectConnectionBaseDTO (IcebergConnectionBaseDTO ):
7985 s3_warehouse_path : str
8086 s3_host : str
8187 s3_bucket : str
@@ -86,18 +92,18 @@ class IcebergRESTCatalogS3ConnectionBaseDTO(ConnectionDTO):
8692 s3_port : int | None
8793 s3_protocol : str
8894 s3_additional_params : dict
89- type : ClassVar [str ] = "iceberg_rest_s3 "
95+ implementation : ClassVar [str ] = "iceberg_rest_s3_direct "
9096
9197
9298@dataclass (kw_only = True )
93- class IcebergRESTCatalogBasicAuthS3DTO ( IcebergRESTCatalogS3ConnectionBaseDTO ):
99+ class IcebergRESTCatalogBasicAuthS3BasicDTO ( IcebergRESTCatalogS3DirectConnectionBaseDTO ):
94100 rest_catalog_username : str
95101 rest_catalog_password : str
96102 rest_catalog_auth_type : Literal ["basic" ] = "basic"
97103
98104
99105@dataclass (kw_only = True )
100- class IcebergRESTCatalogOAuth2ClientCredentialsS3DTO ( IcebergRESTCatalogS3ConnectionBaseDTO ):
106+ class IcebergRESTCatalogOAuth2ClientCredentialsS3BasicDTO ( IcebergRESTCatalogS3DirectConnectionBaseDTO ):
101107 rest_catalog_oauth2_client_id : str
102108 rest_catalog_oauth2_client_secret : str
103109 rest_catalog_oauth2_scopes : list [str ]
@@ -107,13 +113,52 @@ class IcebergRESTCatalogOAuth2ClientCredentialsS3DTO(IcebergRESTCatalogS3Connect
107113 rest_catalog_auth_type : Literal ["oauth2" ] = "oauth2"
108114
109115
110- # TODO: should be refactored
111- class IcebergRESTCatalogS3ConnectionDTO :
112- def __new__ (cls , ** data ):
113- if "rest_catalog_oauth2_client_id" in data :
114- return IcebergRESTCatalogOAuth2ClientCredentialsS3DTO (** data )
116+ @dataclass
117+ class IcebergRESTCatalogS3DelegatedConnectionBaseDTO (IcebergConnectionBaseDTO ):
118+ s3_warehouse_name : str | None = None
119+ s3_access_delegation : Literal ["vended-credentials" , "remote-signing" ] = "vended-credentials"
120+ implementation : ClassVar [str ] = "iceberg_rest_s3_delegated"
121+
122+
123+ @dataclass (kw_only = True )
124+ class IcebergRESTCatalogBasicAuthS3DelegatedDTO (IcebergRESTCatalogS3DelegatedConnectionBaseDTO ):
125+ rest_catalog_username : str
126+ rest_catalog_password : str
127+ rest_catalog_auth_type : Literal ["basic" ] = "basic"
128+
115129
116- return IcebergRESTCatalogBasicAuthS3DTO (** data )
130+ @dataclass (kw_only = True )
131+ class IcebergRESTCatalogOAuth2ClientCredentialsS3DelegatedDTO (IcebergRESTCatalogS3DelegatedConnectionBaseDTO ):
132+ rest_catalog_oauth2_client_id : str
133+ rest_catalog_oauth2_client_secret : str
134+ rest_catalog_oauth2_scopes : list [str ]
135+ rest_catalog_oauth2_resource : str | None = None
136+ rest_catalog_oauth2_audience : str | None = None
137+ rest_catalog_oauth2_token_endpoint : str | None = None
138+ rest_catalog_auth_type : Literal ["oauth2" ] = "oauth2"
139+
140+
141+ # TODO: should be refactored
142+ def get_iceberg_rest_catalog_s3_direct_connection_dto (
143+ ** data ,
144+ ) -> IcebergRESTCatalogBasicAuthS3BasicDTO | IcebergRESTCatalogOAuth2ClientCredentialsS3BasicDTO :
145+ if "rest_catalog_oauth2_client_id" in data :
146+ return IcebergRESTCatalogOAuth2ClientCredentialsS3BasicDTO (** data )
147+ return IcebergRESTCatalogBasicAuthS3BasicDTO (** data )
148+
149+
150+ def get_iceberg_rest_catalog_s3_delegated_connection_dto (
151+ ** data ,
152+ ) -> IcebergRESTCatalogBasicAuthS3DelegatedDTO | IcebergRESTCatalogOAuth2ClientCredentialsS3DelegatedDTO :
153+ if "rest_catalog_oauth2_client_id" in data :
154+ return IcebergRESTCatalogOAuth2ClientCredentialsS3DelegatedDTO (** data )
155+ return IcebergRESTCatalogBasicAuthS3DelegatedDTO (** data )
156+
157+
158+ def get_iceberg_connection_dto (** data ) -> IcebergConnectionBaseDTO :
159+ if "s3_warehouse_path" in data :
160+ return get_iceberg_rest_catalog_s3_direct_connection_dto (** data )
161+ return get_iceberg_rest_catalog_s3_delegated_connection_dto (** data )
117162
118163
119164@dataclass
0 commit comments