@ -114,12 +114,14 @@ def sync(
|
|||||||
async def asyncio_detailed(
|
async def asyncio_detailed(
|
||||||
source_format: ValidFileTypes,
|
source_format: ValidFileTypes,
|
||||||
output_format: ValidFileTypes,
|
output_format: ValidFileTypes,
|
||||||
|
content: bytes,
|
||||||
*,
|
*,
|
||||||
client: AuthenticatedClient,
|
client: AuthenticatedClient,
|
||||||
) -> Response[Union[Any, FileConversion]]:
|
) -> Response[Union[Any, FileConversion]]:
|
||||||
kwargs = _get_kwargs(
|
kwargs = _get_kwargs(
|
||||||
source_format=source_format,
|
source_format=source_format,
|
||||||
output_format=output_format,
|
output_format=output_format,
|
||||||
|
content=content,
|
||||||
client=client,
|
client=client,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -132,6 +134,7 @@ async def asyncio_detailed(
|
|||||||
async def asyncio(
|
async def asyncio(
|
||||||
source_format: ValidFileTypes,
|
source_format: ValidFileTypes,
|
||||||
output_format: ValidFileTypes,
|
output_format: ValidFileTypes,
|
||||||
|
content: bytes,
|
||||||
*,
|
*,
|
||||||
client: AuthenticatedClient,
|
client: AuthenticatedClient,
|
||||||
) -> Optional[Union[Any, FileConversion]]:
|
) -> Optional[Union[Any, FileConversion]]:
|
||||||
@ -141,6 +144,7 @@ async def asyncio(
|
|||||||
await asyncio_detailed(
|
await asyncio_detailed(
|
||||||
source_format=source_format,
|
source_format=source_format,
|
||||||
output_format=output_format,
|
output_format=output_format,
|
||||||
|
content=content,
|
||||||
client=client,
|
client=client,
|
||||||
)
|
)
|
||||||
).parsed
|
).parsed
|
||||||
|
56
kittycad/api/file/file_convert_with_base64_helper.py
Normal file
56
kittycad/api/file/file_convert_with_base64_helper.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
from typing import Any, Dict, Optional, Union
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
from ...client import AuthenticatedClient
|
||||||
|
from ...models.file_conversion import FileConversion
|
||||||
|
from ...models.valid_file_types import ValidFileTypes
|
||||||
|
from ...types import Response
|
||||||
|
from ...api.file.file_convert import sync as fc_sync, asyncio as fc_asyncio
|
||||||
|
|
||||||
|
def sync(
|
||||||
|
source_format: ValidFileTypes,
|
||||||
|
output_format: ValidFileTypes,
|
||||||
|
content: bytes,
|
||||||
|
*,
|
||||||
|
client: AuthenticatedClient,
|
||||||
|
) -> Optional[Union[Any, FileConversion]]:
|
||||||
|
"""Convert a CAD file from one format to another. If the file being converted is larger than a certain size it will be performed asynchronously. This function automatically base64 encodes the request body and base64 decodes the request output."""
|
||||||
|
|
||||||
|
encoded = base64.b64encode(content)
|
||||||
|
|
||||||
|
fc = fc_sync(
|
||||||
|
source_format=source_format,
|
||||||
|
output_format=output_format,
|
||||||
|
content=encoded,
|
||||||
|
client=client,
|
||||||
|
)
|
||||||
|
|
||||||
|
if fc.output != "":
|
||||||
|
fc.output = base64.b64decode(fc.output)
|
||||||
|
|
||||||
|
return fc
|
||||||
|
|
||||||
|
|
||||||
|
async def asyncio(
|
||||||
|
source_format: ValidFileTypes,
|
||||||
|
output_format: ValidFileTypes,
|
||||||
|
content: bytes,
|
||||||
|
*,
|
||||||
|
client: AuthenticatedClient,
|
||||||
|
) -> Optional[Union[Any, FileConversion]]:
|
||||||
|
"""Convert a CAD file from one format to another. If the file being converted is larger than a certain size it will be performed asynchronously. This function automatically base64 encodes the request body and base64 decodes the request output."""
|
||||||
|
|
||||||
|
encoded = base64.b64encode(content)
|
||||||
|
|
||||||
|
fc = await fc_asyncio_detailed(
|
||||||
|
source_format=source_format,
|
||||||
|
output_format=output_format,
|
||||||
|
content=encoded,
|
||||||
|
client=client,
|
||||||
|
)
|
||||||
|
|
||||||
|
if fc.output != "":
|
||||||
|
fc.output = base64.b64decode(fc.output)
|
||||||
|
|
||||||
|
return fc
|
Reference in New Issue
Block a user