This repository was archived by the owner on May 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 77import pydantic
88import requests
99
10+ from data_diff .errors import DataDiffDatasourceIdNotFoundError
11+
1012from ..utils import getLogger
1113
1214logger = getLogger (__name__ )
@@ -207,9 +209,15 @@ def get_data_sources(self) -> List[TCloudApiDataSource]:
207209 return [TCloudApiDataSource (** item ) for item in rv .json ()]
208210
209211 def get_data_source (self , data_source_id : int ) -> TCloudApiDataSource :
210- rv = self .make_get_request (url = f"api/v1/data_sources/ { data_source_id } " )
212+ rv = self .make_get_request (url = f"api/v1/data_sources" )
211213 rv .raise_for_status ()
212- return TCloudApiDataSource (** rv .json ())
214+ response_json = rv .json ()
215+ datasource = next ((datasource for datasource in response_json if datasource ["id" ] == data_source_id ), None )
216+ if not datasource :
217+ raise DataDiffDatasourceIdNotFoundError (
218+ f"Datasource ID: { data_source_id } was not found in your Datafold account!"
219+ )
220+ return TCloudApiDataSource (** datasource )
213221
214222 def create_data_source (self , config : TDsConfig ) -> TCloudApiDataSource :
215223 payload = config .dict ()
Original file line number Diff line number Diff line change @@ -56,3 +56,7 @@ class DataDiffNoAPIKeyError(Exception):
5656
5757class DataDiffNoDatasourceIdError (Exception ):
5858 "Raised when using --cloud but no datasource_id was found in dbt_project.yml"
59+
60+
61+ class DataDiffDatasourceIdNotFoundError (Exception ):
62+ "Raised when using --cloud but the datasource_id is not found for a particular org."
You can’t perform that action at this time.
0 commit comments