Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 22:30:43 -08:00
parent 0ceebbee9c
commit 669b7aded0
4 changed files with 13 additions and 10 deletions

View File

@ -143,6 +143,9 @@ def generatePath(
params_str += ', ' + \ params_str += ', ' + \
camel_to_snake(parameter_name) + '=' + parameter_type camel_to_snake(parameter_name) + '=' + parameter_type
if request_body_type:
params_str += ', body=' + request_body_type
example = """from kittycad.models import """ + success_type + """ example = """from kittycad.models import """ + success_type + """
from kittycad.api.""" + tag_name + """ import """ + fn_name + """ from kittycad.api.""" + tag_name + """ import """ + fn_name + """
from kittycad.types import Response from kittycad.types import Response

View File

@ -13,18 +13,18 @@ from ...api.file.post_file_conversion import sync as fc_sync, asyncio as fc_asyn
def sync( def sync(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
content: bytes, body: bytes,
*, *,
client: Client, client: Client,
) -> Optional[Union[Any, FileConversion]]: ) -> 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.""" """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) encoded = base64.b64encode(body)
fc = fc_sync( fc = fc_sync(
source_format=source_format, source_format=source_format,
output_format=output_format, output_format=output_format,
content=encoded, body=encoded,
client=client, client=client,
) )
@ -37,18 +37,18 @@ def sync(
async def asyncio( async def asyncio(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
content: bytes, body: bytes,
*, *,
client: Client, client: Client,
) -> Optional[Union[Any, FileConversion]]: ) -> 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.""" """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) encoded = base64.b64encode(body)
fc = await fc_asyncio( fc = await fc_asyncio(
source_format=source_format, source_format=source_format,
output_format=output_format, output_format=output_format,
content=encoded, body=encoded,
client=client, client=client,
) )

View File

@ -93,9 +93,9 @@ def test_file_convert_stl():
file.close() file.close()
# Get the fc. # Get the fc.
fc: FileConversion = post_file_convertsion_with_base64_helper.sync( fc: FileConversion = post_file_conversion_with_base64_helper.sync(
client=client, client=client,
content=content, body=content,
source_format=ValidSourceFileFormat.STL, source_format=ValidSourceFileFormat.STL,
output_format=ValidOutputFileFormat.OBJ) output_format=ValidOutputFileFormat.OBJ)
@ -115,7 +115,7 @@ async def test_file_convert_stl_async():
file.close() file.close()
# Get the fc. # Get the fc.
fc: FileConversion = await post_file_convertsion_with_base64_helper.asyncio(client=client, content=content, source_format=ValidSourceFileFormat.STL, output_format=ValidOutputFileFormat.OBJ) fc: FileConversion = await post_file_conversion_with_base64_helper.asyncio(client=client, body=content, source_format=ValidSourceFileFormat.STL, output_format=ValidOutputFileFormat.OBJ)
assert fc is not None assert fc is not None

View File

@ -646,7 +646,7 @@
"libDocsLink": "https://pkg.go.dev/github.com/kittycad/kittycad.go/#FileService.PostConversion" "libDocsLink": "https://pkg.go.dev/github.com/kittycad/kittycad.go/#FileService.PostConversion"
}, },
"x-python": { "x-python": {
"example": "from kittycad.models import FileConversion\nfrom kittycad.api.file import file_conversion_status_with_base64_helper\nfrom kittycad.types import Response\n\nfc: FileConversion = file_conversion_status_with_base64_helper.sync(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[FileConversion] = file_conversion_status_with_base64_helper.sync_detailed(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat)\n\n# OR run async\nfc: FileConversion = await file_conversion_status_with_base64_helper.asyncio(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat)\n\n# OR run async with more info\nresponse: Response[FileConversion] = await file_conversion_status_with_base64_helper.asyncio_detailed(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat)", "example": "from kittycad.models import FileConversion\nfrom kittycad.api.file import file_conversion_status_with_base64_helper\nfrom kittycad.types import Response\n\nfc: FileConversion = file_conversion_status_with_base64_helper.sync(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat, body=bytes)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[FileConversion] = file_conversion_status_with_base64_helper.sync_detailed(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat, body=bytes)\n\n# OR run async\nfc: FileConversion = await file_conversion_status_with_base64_helper.asyncio(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat, body=bytes)\n\n# OR run async with more info\nresponse: Response[FileConversion] = await file_conversion_status_with_base64_helper.asyncio_detailed(client=client, source_format=ValidSourceFileFormat, output_format=ValidOutputFileFormat, body=bytes)",
"libDocsLink": "" "libDocsLink": ""
} }
} }