@ -87,6 +87,7 @@ def generatePath(
|
||||
endoint_refs = getEndpointRefs(endpoint, data)
|
||||
parameter_refs = getParameterRefs(endpoint)
|
||||
request_body_refs = getRequestBodyRefs(endpoint)
|
||||
request_body_type = getRequestBodyType(endpoint)
|
||||
|
||||
# Add our imports.
|
||||
f.write("from typing import Any, Dict, Optional, Union\n")
|
||||
@ -141,6 +142,11 @@ def generatePath(
|
||||
": " +
|
||||
parameter_type +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\tbody: " +
|
||||
request_body_type +
|
||||
",\n")
|
||||
f.write("\t*,\n")
|
||||
f.write("\tclient: Client,\n")
|
||||
f.write(") -> Dict[str, Any]:\n")
|
||||
@ -268,6 +274,11 @@ def generatePath(
|
||||
": " +
|
||||
parameter_type +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\tbody: " +
|
||||
request_body_type +
|
||||
",\n")
|
||||
f.write("\t*,\n")
|
||||
f.write("\tclient: Client,\n")
|
||||
f.write(") -> Response[Union[Any, " +
|
||||
@ -294,6 +305,9 @@ def generatePath(
|
||||
"=" +
|
||||
camel_to_snake(parameter_name) +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\t\tbody=body,\n")
|
||||
f.write("\t\tclient=client,\n")
|
||||
f.write("\t)\n")
|
||||
f.write("\n")
|
||||
@ -329,6 +343,11 @@ def generatePath(
|
||||
": " +
|
||||
parameter_type +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\tbody: " +
|
||||
request_body_type +
|
||||
",\n")
|
||||
f.write("\t*,\n")
|
||||
f.write("\tclient: Client,\n")
|
||||
f.write(") -> Optional[Union[Any, " +
|
||||
@ -358,6 +377,9 @@ def generatePath(
|
||||
"=" +
|
||||
camel_to_snake(parameter_name) +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\t\tbody=body,\n")
|
||||
f.write("\t\tclient=client,\n")
|
||||
f.write("\t).parsed\n")
|
||||
|
||||
@ -386,6 +408,11 @@ def generatePath(
|
||||
": " +
|
||||
parameter_type +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\tbody: " +
|
||||
request_body_type +
|
||||
",\n")
|
||||
f.write("\t*,\n")
|
||||
f.write("\tclient: Client,\n")
|
||||
f.write(") -> Response[Union[Any, " +
|
||||
@ -412,6 +439,9 @@ def generatePath(
|
||||
"=" +
|
||||
camel_to_snake(parameter_name) +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\t\tbody=body,\n")
|
||||
f.write("\t\tclient=client,\n")
|
||||
f.write("\t)\n")
|
||||
f.write("\n")
|
||||
@ -445,6 +475,11 @@ def generatePath(
|
||||
": " +
|
||||
parameter_type +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\tbody: " +
|
||||
request_body_type +
|
||||
",\n")
|
||||
f.write("\t*,\n")
|
||||
f.write("\tclient: Client,\n")
|
||||
f.write(") -> Optional[Union[Any, " +
|
||||
@ -475,6 +510,9 @@ def generatePath(
|
||||
"=" +
|
||||
camel_to_snake(parameter_name) +
|
||||
",\n")
|
||||
if request_body_type:
|
||||
f.write(
|
||||
"\t\t\tbody=body,\n")
|
||||
f.write("\t\t\tclient=client,\n")
|
||||
f.write("\t\t)\n")
|
||||
f.write("\t).parsed\n")
|
||||
@ -949,6 +987,27 @@ def getRequestBodyRefs(endpoint: dict) -> [str]:
|
||||
|
||||
return refs
|
||||
|
||||
def getRequestBodyType(endpoint: dict) -> str:
|
||||
type_name = None
|
||||
|
||||
if 'requestBody' in endpoint:
|
||||
requestBody = endpoint['requestBody']
|
||||
if 'content' in requestBody:
|
||||
content = requestBody['content']
|
||||
for content_type in content:
|
||||
if content_type == 'application/json':
|
||||
json = content[content_type]['schema']
|
||||
if '$ref' in json:
|
||||
ref = json['$ref'].replace('#/components/schemas/', '')
|
||||
return ref
|
||||
elif content_type == 'text/plain':
|
||||
return 'bytes'
|
||||
else:
|
||||
print(" unsupported content type: ", content_type)
|
||||
raise Exception("unsupported content type")
|
||||
|
||||
return type_name
|
||||
|
||||
|
||||
def camel_to_snake(name: str):
|
||||
name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
|
@ -6,7 +6,7 @@ import httpx
|
||||
from ...client import AuthenticatedClient
|
||||
from ...models.file_conversion import FileConversion
|
||||
from ...types import Response
|
||||
from ...api.file.file_conversion_by_id import sync as fc_sync, asyncio as fc_asyncio
|
||||
from ...api.file.file_conversion_status import sync as fc_sync, asyncio as fc_asyncio
|
||||
|
||||
|
||||
def sync(
|
@ -12,6 +12,7 @@ from ...types import Response
|
||||
def _get_kwargs(
|
||||
source_format: ValidSourceFileFormat,
|
||||
output_format: ValidOutputFileFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
@ -65,12 +66,14 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
|
||||
def sync_detailed(
|
||||
source_format: ValidSourceFileFormat,
|
||||
output_format: ValidOutputFileFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Union[Any, FileConversion, ErrorMessage]]:
|
||||
kwargs = _get_kwargs(
|
||||
source_format=source_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
@ -85,6 +88,7 @@ def sync_detailed(
|
||||
def sync(
|
||||
source_format: ValidSourceFileFormat,
|
||||
output_format: ValidOutputFileFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, FileConversion, ErrorMessage]]:
|
||||
@ -93,6 +97,7 @@ def sync(
|
||||
return sync_detailed(
|
||||
source_format=source_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
@ -100,12 +105,14 @@ def sync(
|
||||
async def asyncio_detailed(
|
||||
source_format: ValidSourceFileFormat,
|
||||
output_format: ValidOutputFileFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Union[Any, FileConversion, ErrorMessage]]:
|
||||
kwargs = _get_kwargs(
|
||||
source_format=source_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
@ -118,6 +125,7 @@ async def asyncio_detailed(
|
||||
async def asyncio(
|
||||
source_format: ValidSourceFileFormat,
|
||||
output_format: ValidOutputFileFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, FileConversion, ErrorMessage]]:
|
||||
@ -127,6 +135,7 @@ async def asyncio(
|
||||
await asyncio_detailed(
|
||||
source_format=source_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
|
@ -7,7 +7,7 @@ from ...client import AuthenticatedClient
|
||||
from ...models.file_conversion import FileConversion
|
||||
from ...models.valid_file_type import ValidFileType
|
||||
from ...types import Response
|
||||
from ...api.file.file_convert import sync as fc_sync, asyncio as fc_asyncio
|
||||
from ...api.file.post_file_conversion import sync as fc_sync, asyncio as fc_asyncio
|
||||
|
||||
def sync(
|
||||
source_format: ValidFileType,
|
@ -3,16 +3,16 @@ import pytest
|
||||
import asyncio
|
||||
|
||||
from .client import AuthenticatedClientFromEnv
|
||||
from .models import FileConversion, ValidFileType, AuthSession, InstanceMetadata, Message
|
||||
from .api.file import file_convert_with_base64_helper
|
||||
from .api.meta import meta_debug_session, meta_debug_instance, ping
|
||||
from .models import FileConversion, ValidOutputFileFormat, ValidSourceFileFormat, AuthSession, InstanceMetadata, Message
|
||||
from .api.file import post_file_conversion_with_base64_helper
|
||||
from .api.meta import auth_session, instance_metadata, ping
|
||||
|
||||
def test_get_session():
|
||||
# Create our client.
|
||||
client = ClientFromEnv()
|
||||
|
||||
# Get the session.
|
||||
session: AuthSession = meta_debug_session.sync(client=client)
|
||||
session: AuthSession = auth_session.sync(client=client)
|
||||
|
||||
assert session != None
|
||||
|
||||
@ -24,7 +24,7 @@ async def test_get_session_async():
|
||||
client = ClientFromEnv()
|
||||
|
||||
# Get the session.
|
||||
session: AuthSession = await meta_debug_session.asyncio(client=client)
|
||||
session: AuthSession = await auth_session.asyncio(client=client)
|
||||
|
||||
assert session != None
|
||||
|
||||
@ -35,7 +35,7 @@ def test_get_instance():
|
||||
client = ClientFromEnv()
|
||||
|
||||
# Get the instance.
|
||||
instance: InstanceMetadata = meta_debug_instance.sync(client=client)
|
||||
instance: InstanceMetadata = instance_metadata.sync(client=client)
|
||||
|
||||
assert instance != None
|
||||
|
||||
@ -47,7 +47,7 @@ async def test_get_instance_async():
|
||||
client = ClientFromEnv()
|
||||
|
||||
# Get the instance.
|
||||
instance: InstanceMetadata = await meta_debug_instance.asyncio(client=client)
|
||||
instance: InstanceMetadata = await instance_metadata.asyncio(client=client)
|
||||
|
||||
assert instance != None
|
||||
|
||||
@ -86,7 +86,7 @@ def test_file_convert_stl():
|
||||
file.close()
|
||||
|
||||
# Get the fc.
|
||||
fc: FileConversion = file_convert_with_base64_helper.sync(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)
|
||||
fc: FileConversion = post_file_convertsion_with_base64_helper.sync(client=client, content=content, source_format=ValidSourceFileFormat.STL, output_format=ValidOutputFileFormat.OBJ)
|
||||
|
||||
assert fc != None
|
||||
|
||||
@ -103,7 +103,7 @@ async def test_file_convert_stl_async():
|
||||
file.close()
|
||||
|
||||
# Get the fc.
|
||||
fc: FileConversion = await file_convert_with_base64_helper.asyncio(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)
|
||||
fc: FileConversion = await post_file_convertsion_with_base64_helper.asyncio(client=client, content=content, source_format=ValidSourceFileFormat.STL, output_format=ValidOutputFileFormat.OBJ)
|
||||
|
||||
assert fc != None
|
||||
|
||||
|
@ -8,7 +8,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="AuthSession")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class AuthSession:
|
||||
""" """
|
||||
@ -81,15 +80,16 @@ class AuthSession:
|
||||
|
||||
user_id = d.pop("user_id", UNSET)
|
||||
|
||||
|
||||
auth_session = cls(
|
||||
created_at=created_at,
|
||||
email=email,
|
||||
id=id,
|
||||
image=image,
|
||||
ip_address=ip_address,
|
||||
is_valid=is_valid,
|
||||
token=token,
|
||||
user_id=user_id,
|
||||
created_at= created_at,
|
||||
email= email,
|
||||
id= id,
|
||||
image= image,
|
||||
ip_address= ip_address,
|
||||
is_valid= is_valid,
|
||||
token= token,
|
||||
user_id= user_id,
|
||||
)
|
||||
|
||||
auth_session.additional_properties = d
|
||||
|
@ -6,7 +6,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="ErrorMessage")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class ErrorMessage:
|
||||
""" """
|
||||
@ -42,10 +41,11 @@ class ErrorMessage:
|
||||
|
||||
status = d.pop("status", UNSET)
|
||||
|
||||
|
||||
error_message = cls(
|
||||
code=code,
|
||||
message=message,
|
||||
status=status,
|
||||
code= code,
|
||||
message= message,
|
||||
status= status,
|
||||
)
|
||||
|
||||
error_message.additional_properties = d
|
||||
|
@ -11,7 +11,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="FileConversion")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class FileConversion:
|
||||
""" """
|
||||
@ -119,15 +118,16 @@ class FileConversion:
|
||||
else:
|
||||
status = FileConversionStatus(_status)
|
||||
|
||||
|
||||
file_conversion = cls(
|
||||
completed_at=completed_at,
|
||||
created_at=created_at,
|
||||
id=id,
|
||||
output=output,
|
||||
output_format=output_format,
|
||||
src_format=src_format,
|
||||
started_at=started_at,
|
||||
status=status,
|
||||
completed_at= completed_at,
|
||||
created_at= created_at,
|
||||
id= id,
|
||||
output= output,
|
||||
output_format= output_format,
|
||||
src_format= src_format,
|
||||
started_at= started_at,
|
||||
status= status,
|
||||
)
|
||||
|
||||
file_conversion.additional_properties = d
|
||||
|
@ -1,6 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class FileConversionStatus(str, Enum):
|
||||
QUEUED = 'Queued'
|
||||
UPLOADED = 'Uploaded'
|
||||
|
@ -6,7 +6,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="GPUDevice")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class GPUDevice:
|
||||
""" """
|
||||
@ -54,12 +53,13 @@ class GPUDevice:
|
||||
|
||||
peak_memory_bandwidth = d.pop("peak_memory_bandwidth", UNSET)
|
||||
|
||||
|
||||
gpu_device = cls(
|
||||
id=id,
|
||||
memory_bus_width=memory_bus_width,
|
||||
memory_clock_rate=memory_clock_rate,
|
||||
name=name,
|
||||
peak_memory_bandwidth=peak_memory_bandwidth,
|
||||
id= id,
|
||||
memory_bus_width= memory_bus_width,
|
||||
memory_clock_rate= memory_clock_rate,
|
||||
name= name,
|
||||
peak_memory_bandwidth= peak_memory_bandwidth,
|
||||
)
|
||||
|
||||
gpu_device.additional_properties = d
|
||||
|
@ -7,7 +7,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="Instance")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class Instance:
|
||||
""" """
|
||||
@ -98,18 +97,19 @@ class Instance:
|
||||
|
||||
zone = d.pop("zone", UNSET)
|
||||
|
||||
|
||||
instance = cls(
|
||||
cpu_platform=cpu_platform,
|
||||
description=description,
|
||||
environment=environment,
|
||||
git_hash=git_hash,
|
||||
hostname=hostname,
|
||||
id=id,
|
||||
image=image,
|
||||
ip_address=ip_address,
|
||||
machine_type=machine_type,
|
||||
name=name,
|
||||
zone=zone,
|
||||
cpu_platform= cpu_platform,
|
||||
description= description,
|
||||
environment= environment,
|
||||
git_hash= git_hash,
|
||||
hostname= hostname,
|
||||
id= id,
|
||||
image= image,
|
||||
ip_address= ip_address,
|
||||
machine_type= machine_type,
|
||||
name= name,
|
||||
zone= zone,
|
||||
)
|
||||
|
||||
instance.additional_properties = d
|
||||
|
@ -1,6 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class PongEnum(str, Enum):
|
||||
PONG = 'pong'
|
||||
|
||||
|
@ -7,7 +7,6 @@ from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PongMessage")
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class PongMessage:
|
||||
""" """
|
||||
@ -38,8 +37,9 @@ class PongMessage:
|
||||
else:
|
||||
message = PongEnum(_message)
|
||||
|
||||
|
||||
pong_message = cls(
|
||||
message=message,
|
||||
message= message,
|
||||
)
|
||||
|
||||
pong_message.additional_properties = d
|
||||
|
@ -1,6 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ServerEnv(str, Enum):
|
||||
PRODUCTION = 'production'
|
||||
DEVELOPMENT = 'development'
|
||||
|
@ -1,6 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ValidOutputFileFormat(str, Enum):
|
||||
STL = 'stl'
|
||||
OBJ = 'obj'
|
||||
|
@ -1,6 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ValidSourceFileFormat(str, Enum):
|
||||
STL = 'stl'
|
||||
OBJ = 'obj'
|
||||
|
Reference in New Issue
Block a user