2022-06-11 17:59:55 -07:00
|
|
|
import base64
|
2023-08-17 12:48:13 -07:00
|
|
|
from typing import Any, Optional, Tuple, Union
|
2022-06-11 17:59:55 -07:00
|
|
|
|
2023-05-04 00:58:06 -07:00
|
|
|
from ...api.api_calls.get_async_operation import asyncio as fc_asyncio, sync as fc_sync
|
2022-06-11 17:59:55 -07:00
|
|
|
from ...client import Client
|
|
|
|
from ...models import Error
|
|
|
|
from ...models.file_conversion import FileConversion
|
|
|
|
|
|
|
|
|
|
|
|
def sync(
|
|
|
|
id: str,
|
|
|
|
*,
|
|
|
|
client: Client,
|
2023-08-17 12:48:13 -07:00
|
|
|
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
2022-06-11 17:59:55 -07:00
|
|
|
"""Get the status of a file conversion. This function automatically base64 decodes the output response if there is one."""
|
|
|
|
|
|
|
|
fc = fc_sync(
|
|
|
|
id=id,
|
|
|
|
client=client,
|
|
|
|
)
|
|
|
|
|
|
|
|
if isinstance(fc, FileConversion) and fc.output != "":
|
2023-05-04 00:58:06 -07:00
|
|
|
if isinstance(fc.output, str):
|
2023-08-17 14:13:56 -07:00
|
|
|
b = base64.urlsafe_b64decode(fc.output.strip("=") + "===")
|
2023-08-17 12:48:13 -07:00
|
|
|
return (fc, b)
|
2022-06-11 17:59:55 -07:00
|
|
|
|
|
|
|
return fc
|
|
|
|
|
|
|
|
|
|
|
|
async def asyncio(
|
|
|
|
id: str,
|
|
|
|
*,
|
|
|
|
client: Client,
|
2023-08-17 12:48:13 -07:00
|
|
|
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
2022-06-11 17:59:55 -07:00
|
|
|
"""Get the status of a file conversion. This function automatically base64 decodes the output response if there is one."""
|
|
|
|
|
|
|
|
fc = await fc_asyncio(
|
2023-05-04 00:58:06 -07:00
|
|
|
id=id,
|
|
|
|
client=client,
|
|
|
|
)
|
2022-06-11 17:59:55 -07:00
|
|
|
|
|
|
|
if isinstance(fc, FileConversion) and fc.output != "":
|
2023-05-04 00:58:06 -07:00
|
|
|
if isinstance(fc.output, str):
|
2023-08-17 14:13:56 -07:00
|
|
|
b = base64.urlsafe_b64decode(fc.output.strip("=") + "===")
|
2023-08-17 12:48:13 -07:00
|
|
|
return (fc, b)
|
2022-06-11 17:59:55 -07:00
|
|
|
|
|
|
|
return fc
|