Skip to content

Commit 2859a03

Browse files
authored
Merge pull request #137 from priceloop/feature-add-job-id-export
feat: create job id export
2 parents f7e6c5f + 42bb909 commit 2859a03

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
from http import HTTPStatus
2+
from typing import Any, Dict, Optional
3+
4+
import httpx
5+
from ... import errors
6+
from ...client import AuthenticatedClient, Client
7+
from ...models.export_info import ExportInfo
8+
from ...types import Response
9+
10+
11+
def _get_kwargs(
12+
workspace: str,
13+
export_job_id: int,
14+
*,
15+
client: AuthenticatedClient,
16+
) -> Dict[str, Any]:
17+
url = "{}/api/v1.0/workspaces/{workspace}/exports/{export_job_id}".format(
18+
client.base_url, workspace=workspace, export_job_id=export_job_id
19+
)
20+
21+
headers: Dict[str, str] = client.get_headers()
22+
cookies: Dict[str, Any] = client.get_cookies()
23+
24+
return {
25+
"method": "get",
26+
"url": url,
27+
"headers": headers,
28+
"cookies": cookies,
29+
"timeout": client.get_timeout(),
30+
"follow_redirects": client.follow_redirects,
31+
}
32+
33+
34+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional["ExportInfo"]:
35+
if response.status_code == HTTPStatus.OK:
36+
response_200 = ExportInfo.from_dict(response.json())
37+
return response_200
38+
if client.raise_on_unexpected_status:
39+
raise errors.UnexpectedStatus(response.status_code, response.content)
40+
else:
41+
return None
42+
43+
44+
def _build_response(*, client: Client, response: httpx.Response) -> Response["ExportInfo"]:
45+
return Response(
46+
status_code=HTTPStatus(response.status_code),
47+
content=response.content,
48+
headers=response.headers,
49+
parsed=_parse_response(client=client, response=response),
50+
)
51+
52+
53+
def sync_detailed(
54+
workspace: str,
55+
export_job_id: int,
56+
*,
57+
client: AuthenticatedClient,
58+
) -> Response["ExportInfo"]:
59+
"""This API endpoint returns a url from which the published table can be donwloaded.
60+
61+
Args:
62+
workspace (str): Example: workspace-name.
63+
export_job_id (int): Example: 5.
64+
65+
Raises:
66+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
67+
httpx.TimeoutException: If the request takes longer than Client.timeout.
68+
69+
Returns:
70+
Response['ExportInfo']
71+
"""
72+
73+
kwargs = _get_kwargs(
74+
workspace=workspace,
75+
export_job_id=export_job_id,
76+
client=client,
77+
)
78+
79+
response = httpx.request(
80+
verify=client.verify_ssl,
81+
**kwargs,
82+
)
83+
84+
return _build_response(client=client, response=response)
85+
86+
87+
def sync(
88+
workspace: str,
89+
export_job_id: int,
90+
*,
91+
client: AuthenticatedClient,
92+
) -> Optional["ExportInfo"]:
93+
"""This API endpoint returns a url from which the published table can be donwloaded.
94+
95+
Args:
96+
workspace (str): Example: workspace-name.
97+
export_job_id (int): Example: 5.
98+
99+
Raises:
100+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
101+
httpx.TimeoutException: If the request takes longer than Client.timeout.
102+
103+
Returns:
104+
Response['ExportInfo']
105+
"""
106+
107+
return sync_detailed(
108+
workspace=workspace,
109+
export_job_id=export_job_id,
110+
client=client,
111+
).parsed

0 commit comments

Comments
 (0)