Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 22:10:46 -08:00
parent 89a450f697
commit 5fcd6d048e
50 changed files with 34 additions and 739 deletions

View File

@ -1,17 +0,0 @@
AuthenticatedClient
===================
.. currentmodule:: kittycad
.. autoclass:: AuthenticatedClient
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~AuthenticatedClient.get_headers
.. rubric:: Methods Documentation
.. automethod:: get_headers

View File

@ -1,27 +0,0 @@
Client
======
.. currentmodule:: kittycad
.. autoclass:: Client
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~Client.get_cookies
~Client.get_headers
~Client.get_timeout
~Client.with_cookies
~Client.with_headers
~Client.with_timeout
.. rubric:: Methods Documentation
.. automethod:: get_cookies
.. automethod:: get_headers
.. automethod:: get_timeout
.. automethod:: with_cookies
.. automethod:: with_headers
.. automethod:: with_timeout

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.file.file_conversion_by_id
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
asyncio_detailed
================
.. currentmodule:: kittycad.api.file.file_conversion_by_id
.. autofunction:: asyncio_detailed

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.file.file_conversion_by_id
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
sync_detailed
=============
.. currentmodule:: kittycad.api.file.file_conversion_by_id
.. autofunction:: sync_detailed

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.file.file_conversion_by_id_with_base64_helper
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.file.file_conversion_by_id_with_base64_helper
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.file.file_convert
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
asyncio_detailed
================
.. currentmodule:: kittycad.api.file.file_convert
.. autofunction:: asyncio_detailed

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.file.file_convert
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
sync_detailed
=============
.. currentmodule:: kittycad.api.file.file_convert
.. autofunction:: sync_detailed

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.file.file_convert_with_base64_helper
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.file.file_convert_with_base64_helper
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.meta.meta_debug_instance
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
asyncio_detailed
================
.. currentmodule:: kittycad.api.meta.meta_debug_instance
.. autofunction:: asyncio_detailed

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.meta.meta_debug_instance
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
sync_detailed
=============
.. currentmodule:: kittycad.api.meta.meta_debug_instance
.. autofunction:: sync_detailed

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.meta.meta_debug_session
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
asyncio_detailed
================
.. currentmodule:: kittycad.api.meta.meta_debug_session
.. autofunction:: asyncio_detailed

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.meta.meta_debug_session
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
sync_detailed
=============
.. currentmodule:: kittycad.api.meta.meta_debug_session
.. autofunction:: sync_detailed

View File

@ -1,6 +0,0 @@
asyncio
=======
.. currentmodule:: kittycad.api.meta.ping
.. autofunction:: asyncio

View File

@ -1,6 +0,0 @@
asyncio_detailed
================
.. currentmodule:: kittycad.api.meta.ping
.. autofunction:: asyncio_detailed

View File

@ -1,6 +0,0 @@
sync
====
.. currentmodule:: kittycad.api.meta.ping
.. autofunction:: sync

View File

@ -1,6 +0,0 @@
sync_detailed
=============
.. currentmodule:: kittycad.api.meta.ping
.. autofunction:: sync_detailed

View File

@ -1,17 +0,0 @@
AuthenticatedClient
===================
.. currentmodule:: kittycad.client
.. autoclass:: AuthenticatedClient
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~AuthenticatedClient.get_headers
.. rubric:: Methods Documentation
.. automethod:: get_headers

View File

@ -1,17 +0,0 @@
AuthenticatedClientFromEnv
==========================
.. currentmodule:: kittycad.client
.. autoclass:: AuthenticatedClientFromEnv
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~AuthenticatedClientFromEnv.get_headers
.. rubric:: Methods Documentation
.. automethod:: get_headers

View File

@ -1,27 +0,0 @@
Client
======
.. currentmodule:: kittycad.client
.. autoclass:: Client
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~Client.get_cookies
~Client.get_headers
~Client.get_timeout
~Client.with_cookies
~Client.with_headers
~Client.with_timeout
.. rubric:: Methods Documentation
.. automethod:: get_cookies
.. automethod:: get_headers
.. automethod:: get_timeout
.. automethod:: with_cookies
.. automethod:: with_headers
.. automethod:: with_timeout

View File

@ -1,29 +0,0 @@
AuthSession
===========
.. currentmodule:: kittycad.models
.. autoclass:: AuthSession
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~AuthSession.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~AuthSession.from_dict
~AuthSession.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,21 +0,0 @@
Environment
===========
.. currentmodule:: kittycad.models
.. autoclass:: Environment
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~Environment.DEVELOPMENT
~Environment.PREVIEW
~Environment.PRODUCTION
.. rubric:: Attributes Documentation
.. autoattribute:: DEVELOPMENT
.. autoattribute:: PREVIEW
.. autoattribute:: PRODUCTION

View File

@ -1,29 +0,0 @@
ErrorMessage
============
.. currentmodule:: kittycad.models
.. autoclass:: ErrorMessage
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~ErrorMessage.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~ErrorMessage.from_dict
~ErrorMessage.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,29 +0,0 @@
FileConversion
==============
.. currentmodule:: kittycad.models
.. autoclass:: FileConversion
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~FileConversion.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~FileConversion.from_dict
~FileConversion.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,25 +0,0 @@
FileConversionStatus
====================
.. currentmodule:: kittycad.models
.. autoclass:: FileConversionStatus
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~FileConversionStatus.COMPLETED
~FileConversionStatus.FAILED
~FileConversionStatus.IN_PROGRESS
~FileConversionStatus.QUEUED
~FileConversionStatus.UPLOADED
.. rubric:: Attributes Documentation
.. autoattribute:: COMPLETED
.. autoattribute:: FAILED
.. autoattribute:: IN_PROGRESS
.. autoattribute:: QUEUED
.. autoattribute:: UPLOADED

View File

@ -1,29 +0,0 @@
InstanceMetadata
================
.. currentmodule:: kittycad.models
.. autoclass:: InstanceMetadata
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~InstanceMetadata.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~InstanceMetadata.from_dict
~InstanceMetadata.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,29 +0,0 @@
Message
=======
.. currentmodule:: kittycad.models
.. autoclass:: Message
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~Message.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~Message.from_dict
~Message.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,25 +0,0 @@
ValidFileTypes
==============
.. currentmodule:: kittycad.models
.. autoclass:: ValidFileTypes
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~ValidFileTypes.DWG
~ValidFileTypes.DXF
~ValidFileTypes.OBJ
~ValidFileTypes.STEP
~ValidFileTypes.STL
.. rubric:: Attributes Documentation
.. autoattribute:: DWG
.. autoattribute:: DXF
.. autoattribute:: OBJ
.. autoattribute:: STEP
.. autoattribute:: STL

View File

@ -1,29 +0,0 @@
AuthSession
===========
.. currentmodule:: kittycad.models.auth_session
.. autoclass:: AuthSession
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~AuthSession.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~AuthSession.from_dict
~AuthSession.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,21 +0,0 @@
Environment
===========
.. currentmodule:: kittycad.models.environment
.. autoclass:: Environment
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~Environment.DEVELOPMENT
~Environment.PREVIEW
~Environment.PRODUCTION
.. rubric:: Attributes Documentation
.. autoattribute:: DEVELOPMENT
.. autoattribute:: PREVIEW
.. autoattribute:: PRODUCTION

View File

@ -1,29 +0,0 @@
ErrorMessage
============
.. currentmodule:: kittycad.models.error_message
.. autoclass:: ErrorMessage
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~ErrorMessage.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~ErrorMessage.from_dict
~ErrorMessage.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,29 +0,0 @@
FileConversion
==============
.. currentmodule:: kittycad.models.file_conversion
.. autoclass:: FileConversion
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~FileConversion.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~FileConversion.from_dict
~FileConversion.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,25 +0,0 @@
FileConversionStatus
====================
.. currentmodule:: kittycad.models.file_conversion
.. autoclass:: FileConversionStatus
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~FileConversionStatus.COMPLETED
~FileConversionStatus.FAILED
~FileConversionStatus.IN_PROGRESS
~FileConversionStatus.QUEUED
~FileConversionStatus.UPLOADED
.. rubric:: Attributes Documentation
.. autoattribute:: COMPLETED
.. autoattribute:: FAILED
.. autoattribute:: IN_PROGRESS
.. autoattribute:: QUEUED
.. autoattribute:: UPLOADED

View File

@ -1,25 +0,0 @@
FileConversionStatus
====================
.. currentmodule:: kittycad.models.file_conversion_status
.. autoclass:: FileConversionStatus
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~FileConversionStatus.COMPLETED
~FileConversionStatus.FAILED
~FileConversionStatus.IN_PROGRESS
~FileConversionStatus.QUEUED
~FileConversionStatus.UPLOADED
.. rubric:: Attributes Documentation
.. autoattribute:: COMPLETED
.. autoattribute:: FAILED
.. autoattribute:: IN_PROGRESS
.. autoattribute:: QUEUED
.. autoattribute:: UPLOADED

View File

@ -1,29 +0,0 @@
InstanceMetadata
================
.. currentmodule:: kittycad.models.instance_metadata
.. autoclass:: InstanceMetadata
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~InstanceMetadata.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~InstanceMetadata.from_dict
~InstanceMetadata.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,29 +0,0 @@
Message
=======
.. currentmodule:: kittycad.models.message
.. autoclass:: Message
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~Message.additional_keys
.. rubric:: Methods Summary
.. autosummary::
~Message.from_dict
~Message.to_dict
.. rubric:: Attributes Documentation
.. autoattribute:: additional_keys
.. rubric:: Methods Documentation
.. automethod:: from_dict
.. automethod:: to_dict

View File

@ -1,25 +0,0 @@
ValidFileTypes
==============
.. currentmodule:: kittycad.models.valid_file_types
.. autoclass:: ValidFileTypes
:show-inheritance:
.. rubric:: Attributes Summary
.. autosummary::
~ValidFileTypes.DWG
~ValidFileTypes.DXF
~ValidFileTypes.OBJ
~ValidFileTypes.STEP
~ValidFileTypes.STL
.. rubric:: Attributes Documentation
.. autoattribute:: DWG
.. autoattribute:: DXF
.. autoattribute:: OBJ
.. autoattribute:: STEP
.. autoattribute:: STL

View File

@ -1,17 +0,0 @@
File
====
.. currentmodule:: kittycad.types
.. autoclass:: File
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~File.to_tuple
.. rubric:: Methods Documentation
.. automethod:: to_tuple

View File

@ -1,7 +0,0 @@
Response
========
.. currentmodule:: kittycad.types
.. autoclass:: Response
:show-inheritance:

View File

@ -6,9 +6,8 @@
Welcome to kittycad's documentation!
====================================
.. toctree::
:maxdepth: 3
:caption: Contents:
.. autosummary::
:toctree: modules
kittycad.api
kittycad.client

View File

@ -22,10 +22,9 @@ def main():
generateTypes(cwd, parser)
# Generate the paths.
generatePaths(cwd, parser)
data = generatePaths(cwd, parser)
# Add the client information to the generation.
data = parser.data
data['info']['x-python'] = {
'client': """# Create a client with your token.
from kittycad import Client
@ -48,7 +47,7 @@ client = ClientFromEnv()""",
f.close()
def generatePaths(cwd: str, parser: OpenApiParser):
def generatePaths(cwd: str, parser: OpenApiParser) -> dict:
# Make sure we have the directory.
path = os.path.join(cwd, 'kittycad', 'api')
os.makedirs(path, exist_ok=True)
@ -88,7 +87,9 @@ def generatePaths(cwd: str, parser: OpenApiParser):
for p in paths:
for method in paths[p]:
endpoint = paths[p][method]
generatePath(path, p, method, endpoint, data)
data = generatePath(path, p, method, endpoint, data)
return data
def generatePath(
@ -96,9 +97,11 @@ def generatePath(
name: str,
method: str,
endpoint: dict,
data: dict):
data: dict) -> dict:
# Generate the path.
file_name = camel_to_snake(endpoint['operationId']) + '.py'
fn_name = camel_to_snake(endpoint['operationId'])
file_name = fn_name + '.py'
tag_name = ''
# Add the tag to the path if it exists.
if 'tags' in endpoint:
tag_name = endpoint['tags'][0]
@ -113,6 +116,27 @@ def generatePath(
request_body_refs = getRequestBodyRefs(endpoint)
request_body_type = getRequestBodyType(endpoint)
success_type = endoint_refs[0]
example = """from kittycad.models import """ + success_type + """
from kittycad.api."""+tag_name+""" import """+fn_name+"""
from kittycad.types import Response
fc: """ + success_type + """ = """+fn_name""".sync(client=client, id="<uuid_of_your_conversion>")
# OR if you need more info (e.g. status_code)
response: Response[""" + success_type + """] = """+fn_name""".sync_detailed(client=client, id="<uuid_of_your_conversion>")
# OR run async
fc: """ + success_type + """ = await """+fn_name""".asyncio(client=client, id="<uuid_of_your_conversion>")
# OR run async with more info
response: Response[""" + success_type + """] = await """+fn_name""".asyncio_detailed(client=client, id="<uuid_of_your_conversion>")"""
# Add our example to our json output.
data['paths'][name][method]['x-python'] = {
'example': example,
}
# Add our imports.
f.write("from typing import Any, Dict, Optional, Union\n")
f.write("\n")
@ -544,6 +568,8 @@ def generatePath(
# Close the file.
f.close()
return data
def generateTypes(cwd: str, parser: OpenApiParser):
# Make sure we have the directory.