5
5
6
6
from ... import errors
7
7
from ...client import Client
8
- from ...models .data_source_config import DataSourceConfig
8
+ from ...models .data_source_command_result import DataSourceCommandResult
9
9
from ...models .error import Error
10
- from ...types import Response
10
+ from ...types import UNSET , Response
11
11
12
12
13
13
def _get_kwargs (
14
14
data_source_id : str ,
15
15
* ,
16
16
client : Client ,
17
+ command : str ,
17
18
) -> Dict [str , Any ]:
18
- url = "{}/datasources/{dataSourceId}/config " .format (client .base_url , dataSourceId = data_source_id )
19
+ url = "{}/datasources/{dataSourceId}/command " .format (client .base_url , dataSourceId = data_source_id )
19
20
20
21
headers : Dict [str , str ] = client .get_headers ()
21
22
cookies : Dict [str , Any ] = client .get_cookies ()
22
23
24
+ params : Dict [str , Any ] = {}
25
+ params ["command" ] = command
26
+
27
+ params = {k : v for k , v in params .items () if v is not UNSET and v is not None }
28
+
29
+ # Set the proxies if the client has proxies set.
30
+ proxies = None
31
+ if hasattr (client , "proxies" ) and client .proxies is not None :
32
+ https_proxy = client .proxies .get ("https" )
33
+ if https_proxy :
34
+ proxies = https_proxy
35
+ else :
36
+ http_proxy = client .proxies .get ("http" )
37
+ if http_proxy :
38
+ proxies = http_proxy
39
+
23
40
return {
24
41
"method" : "get" ,
25
42
"url" : url ,
26
43
"headers" : headers ,
27
44
"cookies" : cookies ,
28
45
"timeout" : client .get_timeout (),
46
+ "proxies" : proxies ,
47
+ "params" : params ,
29
48
}
30
49
31
50
32
- def _parse_response (* , client : Client , response : httpx .Response ) -> Optional [Union [DataSourceConfig , Error ]]:
51
+ def _parse_response (* , client : Client , response : httpx .Response ) -> Optional [Union [DataSourceCommandResult , Error ]]:
33
52
if response .status_code == HTTPStatus .OK :
34
- response_200 = DataSourceConfig .from_dict (response .json ())
53
+ response_200 = DataSourceCommandResult .from_dict (response .json ())
35
54
36
55
return response_200
37
56
if response .status_code == HTTPStatus .BAD_REQUEST :
@@ -50,17 +69,13 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
50
69
response_500 = Error .from_dict (response .json ())
51
70
52
71
return response_500
53
- if response .status_code == HTTPStatus .NOT_IMPLEMENTED :
54
- response_501 = Error .from_dict (response .json ())
55
-
56
- return response_501
57
72
if client .raise_on_unexpected_status :
58
- raise errors .UnexpectedStatus (f"Unexpected status code: { response .status_code } " )
73
+ raise errors .UnexpectedStatus (f"Unexpected status code: { response .status_code } ( { response } ) " )
59
74
else :
60
75
return None
61
76
62
77
63
- def _build_response (* , client : Client , response : httpx .Response ) -> Response [Union [DataSourceConfig , Error ]]:
78
+ def _build_response (* , client : Client , response : httpx .Response ) -> Response [Union [DataSourceCommandResult , Error ]]:
64
79
return Response (
65
80
status_code = HTTPStatus (response .status_code ),
66
81
content = response .content ,
@@ -73,23 +88,26 @@ def sync_detailed(
73
88
data_source_id : str ,
74
89
* ,
75
90
client : Client ,
76
- ) -> Response [Union [DataSourceConfig , Error ]]:
77
- """retrieve the data source config
91
+ command : str ,
92
+ ) -> Response [Union [DataSourceCommandResult , Error ]]:
93
+ """Execute a data source's command (e.g. to fetch metadata).
78
94
79
95
Args:
80
96
data_source_id (str):
97
+ command (str):
81
98
82
99
Raises:
83
100
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
84
101
httpx.TimeoutException: If the request takes longer than Client.timeout.
85
102
86
103
Returns:
87
- Response[Union[DataSourceConfig , Error]]
104
+ Response[Union[DataSourceCommandResult , Error]]
88
105
"""
89
106
90
107
kwargs = _get_kwargs (
91
108
data_source_id = data_source_id ,
92
109
client = client ,
110
+ command = command ,
93
111
)
94
112
95
113
response = httpx .request (
@@ -104,47 +122,53 @@ def sync(
104
122
data_source_id : str ,
105
123
* ,
106
124
client : Client ,
107
- ) -> Optional [Union [DataSourceConfig , Error ]]:
108
- """retrieve the data source config
125
+ command : str ,
126
+ ) -> Optional [Union [DataSourceCommandResult , Error ]]:
127
+ """Execute a data source's command (e.g. to fetch metadata).
109
128
110
129
Args:
111
130
data_source_id (str):
131
+ command (str):
112
132
113
133
Raises:
114
134
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
115
135
httpx.TimeoutException: If the request takes longer than Client.timeout.
116
136
117
137
Returns:
118
- Response[Union[DataSourceConfig , Error]]
138
+ Response[Union[DataSourceCommandResult , Error]]
119
139
"""
120
140
121
141
return sync_detailed (
122
142
data_source_id = data_source_id ,
123
143
client = client ,
144
+ command = command ,
124
145
).parsed
125
146
126
147
127
148
async def asyncio_detailed (
128
149
data_source_id : str ,
129
150
* ,
130
151
client : Client ,
131
- ) -> Response [Union [DataSourceConfig , Error ]]:
132
- """retrieve the data source config
152
+ command : str ,
153
+ ) -> Response [Union [DataSourceCommandResult , Error ]]:
154
+ """Execute a data source's command (e.g. to fetch metadata).
133
155
134
156
Args:
135
157
data_source_id (str):
158
+ command (str):
136
159
137
160
Raises:
138
161
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
139
162
httpx.TimeoutException: If the request takes longer than Client.timeout.
140
163
141
164
Returns:
142
- Response[Union[DataSourceConfig , Error]]
165
+ Response[Union[DataSourceCommandResult , Error]]
143
166
"""
144
167
145
168
kwargs = _get_kwargs (
146
169
data_source_id = data_source_id ,
147
170
client = client ,
171
+ command = command ,
148
172
)
149
173
150
174
async with httpx .AsyncClient (verify = client .verify_ssl ) as _client :
@@ -157,23 +181,26 @@ async def asyncio(
157
181
data_source_id : str ,
158
182
* ,
159
183
client : Client ,
160
- ) -> Optional [Union [DataSourceConfig , Error ]]:
161
- """retrieve the data source config
184
+ command : str ,
185
+ ) -> Optional [Union [DataSourceCommandResult , Error ]]:
186
+ """Execute a data source's command (e.g. to fetch metadata).
162
187
163
188
Args:
164
189
data_source_id (str):
190
+ command (str):
165
191
166
192
Raises:
167
193
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
168
194
httpx.TimeoutException: If the request takes longer than Client.timeout.
169
195
170
196
Returns:
171
- Response[Union[DataSourceConfig , Error]]
197
+ Response[Union[DataSourceCommandResult , Error]]
172
198
"""
173
199
174
200
return (
175
201
await asyncio_detailed (
176
202
data_source_id = data_source_id ,
177
203
client = client ,
204
+ command = command ,
178
205
)
179
206
).parsed
0 commit comments