Skip to content

Commit d8c02a2

Browse files
feat(api): api update
1 parent 0a6f60a commit d8c02a2

13 files changed

Lines changed: 777 additions & 8 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-48f00d1c04c23fb4d1cb7cf4af4f56b0c920d758c1f06e06e5373e5b15e9c27d.yml
3-
openapi_spec_hash: 6ee2a94bb9840aceb4a6161c724ce46c
4-
config_hash: c8d97d58d67dad9eeb65eb58fc781724
1+
configured_endpoints: 8
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-a1351fe18005248184e11e2c1d6e4a8df7ecfd0092f9fcfeabaa025a2c5b4986.yml
3+
openapi_spec_hash: 3633a7fdec0e4c3d72dcbadeebaea907
4+
config_hash: 6f1858ca62cea01f7c1c4427b9263c25

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,15 @@ from unlayer import Unlayer
199199

200200
client = Unlayer()
201201

202-
full_to_simple = client.convert.full_to_simple.create(
203-
design={"body": {"foo": "bar"}},
202+
generate = client.ai.generate.create(
203+
display_mode="email",
204+
input=[{"type": "text"}],
205+
output={
206+
"block_type": "template",
207+
"type": "json",
208+
},
204209
)
205-
print(full_to_simple.design)
210+
print(generate.output)
206211
```
207212

208213
## Handling errors

api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# AI
2+
3+
## Generate
4+
5+
Types:
6+
7+
```python
8+
from unlayer.types.ai import GenerateCreateResponse
9+
```
10+
11+
Methods:
12+
13+
- <code title="post /v3/ai/generate">client.ai.generate.<a href="./src/unlayer/resources/ai/generate.py">create</a>(\*\*<a href="src/unlayer/types/ai/generate_create_params.py">params</a>) -> <a href="./src/unlayer/types/ai/generate_create_response.py">GenerateCreateResponse</a></code>
14+
115
# Convert
216

317
## FullToSimple

src/unlayer/_client.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
)
3333

3434
if TYPE_CHECKING:
35-
from .resources import convert, projects, templates, workspaces
35+
from .resources import ai, convert, projects, templates, workspaces
36+
from .resources.ai.ai import AIResource, AsyncAIResource
3637
from .resources.projects import ProjectsResource, AsyncProjectsResource
3738
from .resources.templates import TemplatesResource, AsyncTemplatesResource
3839
from .resources.workspaces import WorkspacesResource, AsyncWorkspacesResource
@@ -107,6 +108,12 @@ def __init__(
107108
_strict_response_validation=_strict_response_validation,
108109
)
109110

111+
@cached_property
112+
def ai(self) -> AIResource:
113+
from .resources.ai import AIResource
114+
115+
return AIResource(self)
116+
110117
@cached_property
111118
def convert(self) -> ConvertResource:
112119
from .resources.convert import ConvertResource
@@ -340,6 +347,12 @@ def __init__(
340347
_strict_response_validation=_strict_response_validation,
341348
)
342349

350+
@cached_property
351+
def ai(self) -> AsyncAIResource:
352+
from .resources.ai import AsyncAIResource
353+
354+
return AsyncAIResource(self)
355+
343356
@cached_property
344357
def convert(self) -> AsyncConvertResource:
345358
from .resources.convert import AsyncConvertResource
@@ -513,6 +526,12 @@ class UnlayerWithRawResponse:
513526
def __init__(self, client: Unlayer) -> None:
514527
self._client = client
515528

529+
@cached_property
530+
def ai(self) -> ai.AIResourceWithRawResponse:
531+
from .resources.ai import AIResourceWithRawResponse
532+
533+
return AIResourceWithRawResponse(self._client.ai)
534+
516535
@cached_property
517536
def convert(self) -> convert.ConvertResourceWithRawResponse:
518537
from .resources.convert import ConvertResourceWithRawResponse
@@ -547,6 +566,12 @@ class AsyncUnlayerWithRawResponse:
547566
def __init__(self, client: AsyncUnlayer) -> None:
548567
self._client = client
549568

569+
@cached_property
570+
def ai(self) -> ai.AsyncAIResourceWithRawResponse:
571+
from .resources.ai import AsyncAIResourceWithRawResponse
572+
573+
return AsyncAIResourceWithRawResponse(self._client.ai)
574+
550575
@cached_property
551576
def convert(self) -> convert.AsyncConvertResourceWithRawResponse:
552577
from .resources.convert import AsyncConvertResourceWithRawResponse
@@ -581,6 +606,12 @@ class UnlayerWithStreamedResponse:
581606
def __init__(self, client: Unlayer) -> None:
582607
self._client = client
583608

609+
@cached_property
610+
def ai(self) -> ai.AIResourceWithStreamingResponse:
611+
from .resources.ai import AIResourceWithStreamingResponse
612+
613+
return AIResourceWithStreamingResponse(self._client.ai)
614+
584615
@cached_property
585616
def convert(self) -> convert.ConvertResourceWithStreamingResponse:
586617
from .resources.convert import ConvertResourceWithStreamingResponse
@@ -615,6 +646,12 @@ class AsyncUnlayerWithStreamedResponse:
615646
def __init__(self, client: AsyncUnlayer) -> None:
616647
self._client = client
617648

649+
@cached_property
650+
def ai(self) -> ai.AsyncAIResourceWithStreamingResponse:
651+
from .resources.ai import AsyncAIResourceWithStreamingResponse
652+
653+
return AsyncAIResourceWithStreamingResponse(self._client.ai)
654+
618655
@cached_property
619656
def convert(self) -> convert.AsyncConvertResourceWithStreamingResponse:
620657
from .resources.convert import AsyncConvertResourceWithStreamingResponse

src/unlayer/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from .ai import (
4+
AIResource,
5+
AsyncAIResource,
6+
AIResourceWithRawResponse,
7+
AsyncAIResourceWithRawResponse,
8+
AIResourceWithStreamingResponse,
9+
AsyncAIResourceWithStreamingResponse,
10+
)
311
from .convert import (
412
ConvertResource,
513
AsyncConvertResource,
@@ -34,6 +42,12 @@
3442
)
3543

3644
__all__ = [
45+
"AIResource",
46+
"AsyncAIResource",
47+
"AIResourceWithRawResponse",
48+
"AsyncAIResourceWithRawResponse",
49+
"AIResourceWithStreamingResponse",
50+
"AsyncAIResourceWithStreamingResponse",
3751
"ConvertResource",
3852
"AsyncConvertResource",
3953
"ConvertResourceWithRawResponse",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .ai import (
4+
AIResource,
5+
AsyncAIResource,
6+
AIResourceWithRawResponse,
7+
AsyncAIResourceWithRawResponse,
8+
AIResourceWithStreamingResponse,
9+
AsyncAIResourceWithStreamingResponse,
10+
)
11+
from .generate import (
12+
GenerateResource,
13+
AsyncGenerateResource,
14+
GenerateResourceWithRawResponse,
15+
AsyncGenerateResourceWithRawResponse,
16+
GenerateResourceWithStreamingResponse,
17+
AsyncGenerateResourceWithStreamingResponse,
18+
)
19+
20+
__all__ = [
21+
"GenerateResource",
22+
"AsyncGenerateResource",
23+
"GenerateResourceWithRawResponse",
24+
"AsyncGenerateResourceWithRawResponse",
25+
"GenerateResourceWithStreamingResponse",
26+
"AsyncGenerateResourceWithStreamingResponse",
27+
"AIResource",
28+
"AsyncAIResource",
29+
"AIResourceWithRawResponse",
30+
"AsyncAIResourceWithRawResponse",
31+
"AIResourceWithStreamingResponse",
32+
"AsyncAIResourceWithStreamingResponse",
33+
]

src/unlayer/resources/ai/ai.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from .generate import (
6+
GenerateResource,
7+
AsyncGenerateResource,
8+
GenerateResourceWithRawResponse,
9+
AsyncGenerateResourceWithRawResponse,
10+
GenerateResourceWithStreamingResponse,
11+
AsyncGenerateResourceWithStreamingResponse,
12+
)
13+
from ..._compat import cached_property
14+
from ..._resource import SyncAPIResource, AsyncAPIResource
15+
16+
__all__ = ["AIResource", "AsyncAIResource"]
17+
18+
19+
class AIResource(SyncAPIResource):
20+
@cached_property
21+
def generate(self) -> GenerateResource:
22+
return GenerateResource(self._client)
23+
24+
@cached_property
25+
def with_raw_response(self) -> AIResourceWithRawResponse:
26+
"""
27+
This property can be used as a prefix for any HTTP method call to return
28+
the raw response object instead of the parsed content.
29+
30+
For more information, see https://www.github.com/unlayer/unlayer-python#accessing-raw-response-data-eg-headers
31+
"""
32+
return AIResourceWithRawResponse(self)
33+
34+
@cached_property
35+
def with_streaming_response(self) -> AIResourceWithStreamingResponse:
36+
"""
37+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38+
39+
For more information, see https://www.github.com/unlayer/unlayer-python#with_streaming_response
40+
"""
41+
return AIResourceWithStreamingResponse(self)
42+
43+
44+
class AsyncAIResource(AsyncAPIResource):
45+
@cached_property
46+
def generate(self) -> AsyncGenerateResource:
47+
return AsyncGenerateResource(self._client)
48+
49+
@cached_property
50+
def with_raw_response(self) -> AsyncAIResourceWithRawResponse:
51+
"""
52+
This property can be used as a prefix for any HTTP method call to return
53+
the raw response object instead of the parsed content.
54+
55+
For more information, see https://www.github.com/unlayer/unlayer-python#accessing-raw-response-data-eg-headers
56+
"""
57+
return AsyncAIResourceWithRawResponse(self)
58+
59+
@cached_property
60+
def with_streaming_response(self) -> AsyncAIResourceWithStreamingResponse:
61+
"""
62+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
63+
64+
For more information, see https://www.github.com/unlayer/unlayer-python#with_streaming_response
65+
"""
66+
return AsyncAIResourceWithStreamingResponse(self)
67+
68+
69+
class AIResourceWithRawResponse:
70+
def __init__(self, ai: AIResource) -> None:
71+
self._ai = ai
72+
73+
@cached_property
74+
def generate(self) -> GenerateResourceWithRawResponse:
75+
return GenerateResourceWithRawResponse(self._ai.generate)
76+
77+
78+
class AsyncAIResourceWithRawResponse:
79+
def __init__(self, ai: AsyncAIResource) -> None:
80+
self._ai = ai
81+
82+
@cached_property
83+
def generate(self) -> AsyncGenerateResourceWithRawResponse:
84+
return AsyncGenerateResourceWithRawResponse(self._ai.generate)
85+
86+
87+
class AIResourceWithStreamingResponse:
88+
def __init__(self, ai: AIResource) -> None:
89+
self._ai = ai
90+
91+
@cached_property
92+
def generate(self) -> GenerateResourceWithStreamingResponse:
93+
return GenerateResourceWithStreamingResponse(self._ai.generate)
94+
95+
96+
class AsyncAIResourceWithStreamingResponse:
97+
def __init__(self, ai: AsyncAIResource) -> None:
98+
self._ai = ai
99+
100+
@cached_property
101+
def generate(self) -> AsyncGenerateResourceWithStreamingResponse:
102+
return AsyncGenerateResourceWithStreamingResponse(self._ai.generate)

0 commit comments

Comments
 (0)