better indent

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 21:23:35 -08:00
parent b09684bd9e
commit 0b9c32e6bf
8 changed files with 183 additions and 98 deletions

View File

@ -136,8 +136,10 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " + ": " +
parameter_type + parameter_type +
",\n") ",\n")
f.write("*, client: Client) -> Dict[str, Any]:\n") f.write("\t*,\n")
f.write("\turl = \"{}" + name + "\".format(client.base_url,\n") f.write("\tclient: Client,\n")
f.write(") -> Dict[str, Any]:\n")
f.write("\turl = \"{}" + name + "\".format(client.base_url")
# Iterate over the parameters. # Iterate over the parameters.
if 'parameters' in endpoint: if 'parameters' in endpoint:
parameters = endpoint['parameters'] parameters = endpoint['parameters']
@ -153,12 +155,11 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter) print(" parameter: ", parameter)
raise Exception("Unknown parameter type") raise Exception("Unknown parameter type")
f.write( f.write(
"\t" + ", " +
parameter_name + parameter_name +
"=" + "=" +
camel_to_snake(parameter_name) + camel_to_snake(parameter_name))
",\n") f.write(")\n")
f.write("\t)\n")
f.write("\n") f.write("\n")
f.write("\theaders: Dict[str, Any] = client.get_headers()\n") f.write("\theaders: Dict[str, Any] = client.get_headers()\n")
f.write("\tcookies: Dict[str, Any] = client.get_cookies()\n") f.write("\tcookies: Dict[str, Any] = client.get_cookies()\n")
@ -244,7 +245,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " + ": " +
parameter_type + parameter_type +
",\n") ",\n")
f.write("*, client: Client) -> Response[Union[Any, " + f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Response[Union[Any, " +
", ".join(endoint_refs) + ", ".join(endoint_refs) +
"]]:\n") "]]:\n")
f.write("\tkwargs = _get_kwargs(\n") f.write("\tkwargs = _get_kwargs(\n")
@ -303,7 +306,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " + ": " +
parameter_type + parameter_type +
",\n") ",\n")
f.write("*, client: Client) -> Optional[Union[Any, " + f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Optional[Union[Any, " +
", ".join(endoint_refs) + ", ".join(endoint_refs) +
"]]:\n") "]]:\n")
if 'description' in endpoint: if 'description' in endpoint:
@ -325,7 +330,7 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter) print(" parameter: ", parameter)
raise Exception("Unknown parameter type") raise Exception("Unknown parameter type")
f.write( f.write(
"\t" + "\t\t" +
camel_to_snake(parameter_name) + camel_to_snake(parameter_name) +
"=" + "=" +
camel_to_snake(parameter_name) + camel_to_snake(parameter_name) +
@ -358,7 +363,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " + ": " +
parameter_type + parameter_type +
",\n") ",\n")
f.write("*, client: Client) -> Response[Union[Any, " + f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Response[Union[Any, " +
", ".join(endoint_refs) + ", ".join(endoint_refs) +
"]]:\n") "]]:\n")
f.write("\tkwargs = _get_kwargs(\n") f.write("\tkwargs = _get_kwargs(\n")
@ -415,13 +422,16 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " + ": " +
parameter_type + parameter_type +
",\n") ",\n")
f.write("*, client: Client) -> Optional[Union[Any, " + f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Optional[Union[Any, " +
", ".join(endoint_refs) + ", ".join(endoint_refs) +
"]]:\n") "]]:\n")
if 'description' in endpoint: if 'description' in endpoint:
f.write("\t\"\"\" " + endpoint['description'] + " \"\"\"\n") f.write("\t\"\"\" " + endpoint['description'] + " \"\"\"\n")
f.write("\n") f.write("\n")
f.write("\treturn (await asyncio_detailed(\n") f.write("\treturn (\n")
f.write("\t\tawait asyncio_detailed(\n")
# Iterate over the parameters. # Iterate over the parameters.
if 'parameters' in endpoint: if 'parameters' in endpoint:
parameters = endpoint['parameters'] parameters = endpoint['parameters']
@ -437,13 +447,14 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter) print(" parameter: ", parameter)
raise Exception("Unknown parameter type") raise Exception("Unknown parameter type")
f.write( f.write(
"\t\t" + "\t\t\t" +
camel_to_snake(parameter_name) + camel_to_snake(parameter_name) +
"=" + "=" +
camel_to_snake(parameter_name) + camel_to_snake(parameter_name) +
",\n") ",\n")
f.write("\t\tclient=client,\n") f.write("\t\t\tclient=client,\n")
f.write("\t)).parsed\n") f.write("\t\t)\n")
f.write("\t).parsed\n")
# Close the file. # Close the file.
f.close() f.close()
@ -864,6 +875,7 @@ def getEndpointRefs(endpoint: dict) -> [str]:
json = content[content_type]['schema'] json = content[content_type]['schema']
if '$ref' in json: if '$ref' in json:
ref = json['$ref'].replace('#/components/schemas/', '') ref = json['$ref'].replace('#/components/schemas/', '')
if ref not in refs:
refs.append(ref) refs.append(ref)
return refs return refs

View File

@ -8,10 +8,10 @@ from ...types import Response
def _get_kwargs( def _get_kwargs(
id: str, id: str,
*, client: Client) -> Dict[str, Any]: *,
url = "{}/file/conversion/{id}".format(client.base_url, client: Client,
id=id, ) -> Dict[str, Any]:
) url = "{}/file/conversion/{id}".format(client.base_url, id=id)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -57,7 +57,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed( def sync_detailed(
id: str, id: str,
*, client: Client) -> Response[Union[Any, FileConversion]]: *,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
id=id, id=id,
client=client, client=client,
@ -73,7 +75,9 @@ def sync_detailed(
def sync( def sync(
id: str, id: str,
*, client: Client) -> Optional[Union[Any, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Get the status and output of an async file conversion. """ """ Get the status and output of an async file conversion. """
return sync_detailed( return sync_detailed(
@ -84,7 +88,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
id: str, id: str,
*, client: Client) -> Response[Union[Any, FileConversion]]: *,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
id=id, id=id,
client=client, client=client,
@ -98,10 +104,14 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
id: str, id: str,
*, client: Client) -> Optional[Union[Any, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Get the status and output of an async file conversion. """ """ Get the status and output of an async file conversion. """
return (await asyncio_detailed( return (
await asyncio_detailed(
id=id, id=id,
client=client, client=client,
)).parsed )
).parsed

View File

@ -4,7 +4,6 @@ import httpx
from ...client import Client from ...client import Client
from ...models.file_conversion import FileConversion from ...models.file_conversion import FileConversion
from ...models.file_conversion import FileConversion
from ...models.valid_source_file_format import ValidSourceFileFormat from ...models.valid_source_file_format import ValidSourceFileFormat
from ...models.valid_output_file_format import ValidOutputFileFormat from ...models.valid_output_file_format import ValidOutputFileFormat
from ...types import Response from ...types import Response
@ -12,11 +11,10 @@ from ...types import Response
def _get_kwargs( def _get_kwargs(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
*, client: Client) -> Dict[str, Any]: *,
url = "{}/file/conversion/{sourceFormat}/{outputFormat}".format(client.base_url, client: Client,
sourceFormat=source_format, ) -> Dict[str, Any]:
outputFormat=output_format, url = "{}/file/conversion/{sourceFormat}/{outputFormat}".format(client.base_url, sourceFormat=source_format, outputFormat=output_format)
)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -29,7 +27,7 @@ def _get_kwargs(
} }
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConversion, FileConversion]]: def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConversion]]:
if response.status_code == 200: if response.status_code == 200:
response_200 = FileConversion.from_dict(response.json()) response_200 = FileConversion.from_dict(response.json())
return response_200 return response_200
@ -54,7 +52,7 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConv
return None return None
def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConversion, FileConversion]]: def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConversion]]:
return Response( return Response(
status_code=response.status_code, status_code=response.status_code,
content=response.content, content=response.content,
@ -66,7 +64,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed( def sync_detailed(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
*, client: Client) -> Response[Union[Any, FileConversion, FileConversion]]: *,
client: Client,
) -> 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,
@ -84,7 +84,9 @@ def sync_detailed(
def sync( def sync(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
*, client: Client) -> Optional[Union[Any, FileConversion, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """ """ Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """
return sync_detailed( return sync_detailed(
@ -97,7 +99,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
*, client: Client) -> Response[Union[Any, FileConversion, FileConversion]]: *,
client: Client,
) -> 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,
@ -113,11 +117,15 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
source_format: ValidSourceFileFormat, source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat, output_format: ValidOutputFileFormat,
*, client: Client) -> Optional[Union[Any, FileConversion, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """ """ Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """
return (await asyncio_detailed( return (
await asyncio_detailed(
source_format=source_format, source_format=source_format,
output_format=output_format, output_format=output_format,
client=client, client=client,
)).parsed )
).parsed

View File

@ -6,9 +6,10 @@ from ...client import Client
from ...types import Response from ...types import Response
def _get_kwargs( def _get_kwargs(
*, client: Client) -> Dict[str, Any]: *,
url = "{}/_internal/gpu/devices".format(client.base_url, client: Client,
) ) -> Dict[str, Any]:
url = "{}/_internal/gpu/devices".format(client.base_url)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -43,7 +44,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, ]]:
def sync_detailed( def sync_detailed(
*, client: Client) -> Response[Union[Any, ]]: *,
client: Client,
) -> Response[Union[Any, ]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -57,7 +60,9 @@ def sync_detailed(
def sync( def sync(
*, client: Client) -> Optional[Union[Any, ]]: *,
client: Client,
) -> Optional[Union[Any, ]]:
""" Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """ """ Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """
return sync_detailed( return sync_detailed(
@ -66,7 +71,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, ]]: *,
client: Client,
) -> Response[Union[Any, ]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -78,9 +85,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, client: Client) -> Optional[Union[Any, ]]: *,
client: Client,
) -> Optional[Union[Any, ]]:
""" Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """ """ Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """
return (await asyncio_detailed( return (
await asyncio_detailed(
client=client, client=client,
)).parsed )
).parsed

View File

@ -7,9 +7,10 @@ from ...models.file_conversion import FileConversion
from ...types import Response from ...types import Response
def _get_kwargs( def _get_kwargs(
*, client: Client) -> Dict[str, Any]: *,
url = "{}/_internal/async/conversions/stop".format(client.base_url, client: Client,
) ) -> Dict[str, Any]:
url = "{}/_internal/async/conversions/stop".format(client.base_url)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -48,7 +49,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed( def sync_detailed(
*, client: Client) -> Response[Union[Any, FileConversion]]: *,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -62,7 +65,9 @@ def sync_detailed(
def sync( def sync(
*, client: Client) -> Optional[Union[Any, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """ """ Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """
return sync_detailed( return sync_detailed(
@ -71,7 +76,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, FileConversion]]: *,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -83,9 +90,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, client: Client) -> Optional[Union[Any, FileConversion]]: *,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """ """ Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """
return (await asyncio_detailed( return (
await asyncio_detailed(
client=client, client=client,
)).parsed )
).parsed

View File

@ -7,9 +7,10 @@ from ...models.auth_session import AuthSession
from ...types import Response from ...types import Response
def _get_kwargs( def _get_kwargs(
*, client: Client) -> Dict[str, Any]: *,
url = "{}/_meta/debug/session".format(client.base_url, client: Client,
) ) -> Dict[str, Any]:
url = "{}/_meta/debug/session".format(client.base_url)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -45,7 +46,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, AuthSess
def sync_detailed( def sync_detailed(
*, client: Client) -> Response[Union[Any, AuthSession]]: *,
client: Client,
) -> Response[Union[Any, AuthSession]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -59,7 +62,9 @@ def sync_detailed(
def sync( def sync(
*, client: Client) -> Optional[Union[Any, AuthSession]]: *,
client: Client,
) -> Optional[Union[Any, AuthSession]]:
""" Get information about your API request session. This is primarily used for debugging. """ """ Get information about your API request session. This is primarily used for debugging. """
return sync_detailed( return sync_detailed(
@ -68,7 +73,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, AuthSession]]: *,
client: Client,
) -> Response[Union[Any, AuthSession]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -80,9 +87,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, client: Client) -> Optional[Union[Any, AuthSession]]: *,
client: Client,
) -> Optional[Union[Any, AuthSession]]:
""" Get information about your API request session. This is primarily used for debugging. """ """ Get information about your API request session. This is primarily used for debugging. """
return (await asyncio_detailed( return (
await asyncio_detailed(
client=client, client=client,
)).parsed )
).parsed

View File

@ -7,9 +7,10 @@ from ...models.instance import Instance
from ...types import Response from ...types import Response
def _get_kwargs( def _get_kwargs(
*, client: Client) -> Dict[str, Any]: *,
url = "{}/_meta/debug/instance".format(client.base_url, client: Client,
) ) -> Dict[str, Any]:
url = "{}/_meta/debug/instance".format(client.base_url)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -45,7 +46,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, Instance
def sync_detailed( def sync_detailed(
*, client: Client) -> Response[Union[Any, Instance]]: *,
client: Client,
) -> Response[Union[Any, Instance]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -59,7 +62,9 @@ def sync_detailed(
def sync( def sync(
*, client: Client) -> Optional[Union[Any, Instance]]: *,
client: Client,
) -> Optional[Union[Any, Instance]]:
""" Get information about this specific API server instance. This is primarily used for debugging. """ """ Get information about this specific API server instance. This is primarily used for debugging. """
return sync_detailed( return sync_detailed(
@ -68,7 +73,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, Instance]]: *,
client: Client,
) -> Response[Union[Any, Instance]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -80,9 +87,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, client: Client) -> Optional[Union[Any, Instance]]: *,
client: Client,
) -> Optional[Union[Any, Instance]]:
""" Get information about this specific API server instance. This is primarily used for debugging. """ """ Get information about this specific API server instance. This is primarily used for debugging. """
return (await asyncio_detailed( return (
await asyncio_detailed(
client=client, client=client,
)).parsed )
).parsed

View File

@ -7,9 +7,10 @@ from ...models.pong_message import PongMessage
from ...types import Response from ...types import Response
def _get_kwargs( def _get_kwargs(
*, client: Client) -> Dict[str, Any]: *,
url = "{}/ping".format(client.base_url, client: Client,
) ) -> Dict[str, Any]:
url = "{}/ping".format(client.base_url)
headers: Dict[str, Any] = client.get_headers() headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies() cookies: Dict[str, Any] = client.get_cookies()
@ -39,7 +40,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, PongMess
def sync_detailed( def sync_detailed(
*, client: Client) -> Response[Union[Any, PongMessage]]: *,
client: Client,
) -> Response[Union[Any, PongMessage]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -53,7 +56,9 @@ def sync_detailed(
def sync( def sync(
*, client: Client) -> Optional[Union[Any, PongMessage]]: *,
client: Client,
) -> Optional[Union[Any, PongMessage]]:
""" Simple ping to the server. """ """ Simple ping to the server. """
return sync_detailed( return sync_detailed(
@ -62,7 +67,9 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, PongMessage]]: *,
client: Client,
) -> Response[Union[Any, PongMessage]]:
kwargs = _get_kwargs( kwargs = _get_kwargs(
client=client, client=client,
) )
@ -74,9 +81,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, client: Client) -> Optional[Union[Any, PongMessage]]: *,
client: Client,
) -> Optional[Union[Any, PongMessage]]:
""" Simple ping to the server. """ """ Simple ping to the server. """
return (await asyncio_detailed( return (
await asyncio_detailed(
client=client, client=client,
)).parsed )
).parsed