Visitar URL original
feat(api): api update · unlayer/unlayer-python@3901e44 · GitHub
Skip to content

Commit 3901e44

Browse files
feat(api): api update
1 parent e90df1d commit 3901e44

16 files changed

Lines changed: 120 additions & 142 deletions

‎.stats.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-579dff50df9d2d3be275dc58817917d2efec68100883d139ae7d62908a24e5d6.yml
3-
openapi_spec_hash: 8583074e5ea7cc31410a42c2c4550d7c
4-
config_hash: 3c023f8805c0765c987ddcee566aabef
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-e77bc881d5cb6c68be6f3d3861ed021b99f6cde45ee28d3511abe284d888262e.yml
3+
openapi_spec_hash: 7e7fae1b919c5d337e8b22be2a24d3ed
4+
config_hash: ea554d62bfbb5e8ea43ebf0a274dec31

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ client = Unlayer()
134134

135135
all_templates = []
136136
# Automatically fetches more pages as needed.
137-
for template in client.project.templates.list(
137+
for template in client.templates.list(
138138
project_id="your-project-id",
139139
limit=10,
140140
):
@@ -155,7 +155,7 @@ client = AsyncUnlayer()
155155
async def main() -> None:
156156
all_templates = []
157157
# Iterate through items across all pages, issuing requests as needed.
158-
async for template in client.project.templates.list(
158+
async for template in client.templates.list(
159159
project_id="your-project-id",
160160
limit=10,
161161
):
@@ -169,7 +169,7 @@ asyncio.run(main())
169169
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
170170

171171
```python
172-
first_page = await client.project.templates.list(
172+
first_page = await client.templates.list(
173173
project_id="your-project-id",
174174
limit=10,
175175
)
@@ -184,7 +184,7 @@ if first_page.has_next_page():
184184
Or just work directly with the returned data:
185185

186186
```python
187-
first_page = await client.project.templates.list(
187+
first_page = await client.templates.list(
188188
project_id="your-project-id",
189189
limit=10,
190190
)

‎api.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ from unlayer.types import ProjectRetrieveResponse
3434

3535
Methods:
3636

37-
- <code title="get /v3/project">client.project.<a href="./src/unlayer/resources/project/project.py">retrieve</a>(\*\*<a href="src/unlayer/types/project_retrieve_params.py">params</a>) -> <a href="./src/unlayer/types/project_retrieve_response.py">ProjectRetrieveResponse</a></code>
37+
- <code title="get /v3/project">client.project.<a href="./src/unlayer/resources/project.py">retrieve</a>(\*\*<a href="src/unlayer/types/project_retrieve_params.py">params</a>) -> <a href="./src/unlayer/types/project_retrieve_response.py">ProjectRetrieveResponse</a></code>
3838

39-
## Templates
39+
# Templates
4040

4141
Types:
4242

4343
```python
44-
from unlayer.types.project import TemplateRetrieveResponse, TemplateListResponse
44+
from unlayer.types import TemplateRetrieveResponse, TemplateListResponse
4545
```
4646

4747
Methods:
4848

49-
- <code title="get /v3/project/templates/{id}">client.project.templates.<a href="./src/unlayer/resources/project/templates.py">retrieve</a>(id, \*\*<a href="src/unlayer/types/project/template_retrieve_params.py">params</a>) -> <a href="./src/unlayer/types/project/template_retrieve_response.py">TemplateRetrieveResponse</a></code>
50-
- <code title="get /v3/project/templates">client.project.templates.<a href="./src/unlayer/resources/project/templates.py">list</a>(\*\*<a href="src/unlayer/types/project/template_list_params.py">params</a>) -> <a href="./src/unlayer/types/project/template_list_response.py">SyncCursorPage[TemplateListResponse]</a></code>
49+
- <code title="get /v3/templates/{id}">client.templates.<a href="./src/unlayer/resources/templates.py">retrieve</a>(id, \*\*<a href="src/unlayer/types/template_retrieve_params.py">params</a>) -> <a href="./src/unlayer/types/template_retrieve_response.py">TemplateRetrieveResponse</a></code>
50+
- <code title="get /v3/templates">client.templates.<a href="./src/unlayer/resources/templates.py">list</a>(\*\*<a href="src/unlayer/types/template_list_params.py">params</a>) -> <a href="./src/unlayer/types/template_list_response.py">SyncCursorPage[TemplateListResponse]</a></code>
5151

5252
# Workspaces
5353

‎src/unlayer/_client.py‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
)
3232

3333
if TYPE_CHECKING:
34-
from .resources import convert, project, workspaces
34+
from .resources import convert, project, templates, workspaces
35+
from .resources.project import ProjectResource, AsyncProjectResource
36+
from .resources.templates import TemplatesResource, AsyncTemplatesResource
3537
from .resources.workspaces import WorkspacesResource, AsyncWorkspacesResource
3638
from .resources.convert.convert import ConvertResource, AsyncConvertResource
37-
from .resources.project.project import ProjectResource, AsyncProjectResource
3839

3940
__all__ = [
4041
"ENVIRONMENTS",
@@ -147,6 +148,12 @@ def project(self) -> ProjectResource:
147148

148149
return ProjectResource(self)
149150

151+
@cached_property
152+
def templates(self) -> TemplatesResource:
153+
from .resources.templates import TemplatesResource
154+
155+
return TemplatesResource(self)
156+
150157
@cached_property
151158
def workspaces(self) -> WorkspacesResource:
152159
from .resources.workspaces import WorkspacesResource
@@ -359,6 +366,12 @@ def project(self) -> AsyncProjectResource:
359366

360367
return AsyncProjectResource(self)
361368

369+
@cached_property
370+
def templates(self) -> AsyncTemplatesResource:
371+
from .resources.templates import AsyncTemplatesResource
372+
373+
return AsyncTemplatesResource(self)
374+
362375
@cached_property
363376
def workspaces(self) -> AsyncWorkspacesResource:
364377
from .resources.workspaces import AsyncWorkspacesResource
@@ -498,6 +511,12 @@ def project(self) -> project.ProjectResourceWithRawResponse:
498511

499512
return ProjectResourceWithRawResponse(self._client.project)
500513

514+
@cached_property
515+
def templates(self) -> templates.TemplatesResourceWithRawResponse:
516+
from .resources.templates import TemplatesResourceWithRawResponse
517+
518+
return TemplatesResourceWithRawResponse(self._client.templates)
519+
501520
@cached_property
502521
def workspaces(self) -> workspaces.WorkspacesResourceWithRawResponse:
503522
from .resources.workspaces import WorkspacesResourceWithRawResponse
@@ -523,6 +542,12 @@ def project(self) -> project.AsyncProjectResourceWithRawResponse:
523542

524543
return AsyncProjectResourceWithRawResponse(self._client.project)
525544

545+
@cached_property
546+
def templates(self) -> templates.AsyncTemplatesResourceWithRawResponse:
547+
from .resources.templates import AsyncTemplatesResourceWithRawResponse
548+
549+
return AsyncTemplatesResourceWithRawResponse(self._client.templates)
550+
526551
@cached_property
527552
def workspaces(self) -> workspaces.AsyncWorkspacesResourceWithRawResponse:
528553
from .resources.workspaces import AsyncWorkspacesResourceWithRawResponse
@@ -548,6 +573,12 @@ def project(self) -> project.ProjectResourceWithStreamingResponse:
548573

549574
return ProjectResourceWithStreamingResponse(self._client.project)
550575

576+
@cached_property
577+
def templates(self) -> templates.TemplatesResourceWithStreamingResponse:
578+
from .resources.templates import TemplatesResourceWithStreamingResponse
579+
580+
return TemplatesResourceWithStreamingResponse(self._client.templates)
581+
551582
@cached_property
552583
def workspaces(self) -> workspaces.WorkspacesResourceWithStreamingResponse:
553584
from .resources.workspaces import WorkspacesResourceWithStreamingResponse
@@ -573,6 +604,12 @@ def project(self) -> project.AsyncProjectResourceWithStreamingResponse:
573604

574605
return AsyncProjectResourceWithStreamingResponse(self._client.project)
575606

607+
@cached_property
608+
def templates(self) -> templates.AsyncTemplatesResourceWithStreamingResponse:
609+
from .resources.templates import AsyncTemplatesResourceWithStreamingResponse
610+
611+
return AsyncTemplatesResourceWithStreamingResponse(self._client.templates)
612+
576613
@cached_property
577614
def workspaces(self) -> workspaces.AsyncWorkspacesResourceWithStreamingResponse:
578615
from .resources.workspaces import AsyncWorkspacesResourceWithStreamingResponse

‎src/unlayer/resources/__init__.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
ProjectResourceWithStreamingResponse,
1717
AsyncProjectResourceWithStreamingResponse,
1818
)
19+
from .templates import (
20+
TemplatesResource,
21+
AsyncTemplatesResource,
22+
TemplatesResourceWithRawResponse,
23+
AsyncTemplatesResourceWithRawResponse,
24+
TemplatesResourceWithStreamingResponse,
25+
AsyncTemplatesResourceWithStreamingResponse,
26+
)
1927
from .workspaces import (
2028
WorkspacesResource,
2129
AsyncWorkspacesResource,
@@ -38,6 +46,12 @@
3846
"AsyncProjectResourceWithRawResponse",
3947
"ProjectResourceWithStreamingResponse",
4048
"AsyncProjectResourceWithStreamingResponse",
49+
"TemplatesResource",
50+
"AsyncTemplatesResource",
51+
"TemplatesResourceWithRawResponse",
52+
"AsyncTemplatesResourceWithRawResponse",
53+
"TemplatesResourceWithStreamingResponse",
54+
"AsyncTemplatesResourceWithStreamingResponse",
4155
"WorkspacesResource",
4256
"AsyncWorkspacesResource",
4357
"WorkspacesResourceWithRawResponse",
Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,24 @@
44

55
import httpx
66

7-
from ...types import project_retrieve_params
8-
from ..._types import Body, Query, Headers, NotGiven, not_given
9-
from ..._utils import maybe_transform, async_maybe_transform
10-
from ..._compat import cached_property
11-
from .templates import (
12-
TemplatesResource,
13-
AsyncTemplatesResource,
14-
TemplatesResourceWithRawResponse,
15-
AsyncTemplatesResourceWithRawResponse,
16-
TemplatesResourceWithStreamingResponse,
17-
AsyncTemplatesResourceWithStreamingResponse,
18-
)
19-
from ..._resource import SyncAPIResource, AsyncAPIResource
20-
from ..._response import (
7+
from ..types import project_retrieve_params
8+
from .._types import Body, Query, Headers, NotGiven, not_given
9+
from .._utils import maybe_transform, async_maybe_transform
10+
from .._compat import cached_property
11+
from .._resource import SyncAPIResource, AsyncAPIResource
12+
from .._response import (
2113
to_raw_response_wrapper,
2214
to_streamed_response_wrapper,
2315
async_to_raw_response_wrapper,
2416
async_to_streamed_response_wrapper,
2517
)
26-
from ..._base_client import make_request_options
27-
from ...types.project_retrieve_response import ProjectRetrieveResponse
18+
from .._base_client import make_request_options
19+
from ..types.project_retrieve_response import ProjectRetrieveResponse
2820

2921
__all__ = ["ProjectResource", "AsyncProjectResource"]
3022

3123

3224
class ProjectResource(SyncAPIResource):
33-
@cached_property
34-
def templates(self) -> TemplatesResource:
35-
return TemplatesResource(self._client)
36-
3725
@cached_property
3826
def with_raw_response(self) -> ProjectResourceWithRawResponse:
3927
"""
@@ -92,10 +80,6 @@ def retrieve(
9280

9381

9482
class AsyncProjectResource(AsyncAPIResource):
95-
@cached_property
96-
def templates(self) -> AsyncTemplatesResource:
97-
return AsyncTemplatesResource(self._client)
98-
9983
@cached_property
10084
def with_raw_response(self) -> AsyncProjectResourceWithRawResponse:
10185
"""
@@ -163,10 +147,6 @@ def __init__(self, project: ProjectResource) -> None:
163147
project.retrieve,
164148
)
165149

166-
@cached_property
167-
def templates(self) -> TemplatesResourceWithRawResponse:
168-
return TemplatesResourceWithRawResponse(self._project.templates)
169-
170150

171151
class AsyncProjectResourceWithRawResponse:
172152
def __init__(self, project: AsyncProjectResource) -> None:
@@ -176,10 +156,6 @@ def __init__(self, project: AsyncProjectResource) -> None:
176156
project.retrieve,
177157
)
178158

179-
@cached_property
180-
def templates(self) -> AsyncTemplatesResourceWithRawResponse:
181-
return AsyncTemplatesResourceWithRawResponse(self._project.templates)
182-
183159

184160
class ProjectResourceWithStreamingResponse:
185161
def __init__(self, project: ProjectResource) -> None:
@@ -189,10 +165,6 @@ def __init__(self, project: ProjectResource) -> None:
189165
project.retrieve,
190166
)
191167

192-
@cached_property
193-
def templates(self) -> TemplatesResourceWithStreamingResponse:
194-
return TemplatesResourceWithStreamingResponse(self._project.templates)
195-
196168

197169
class AsyncProjectResourceWithStreamingResponse:
198170
def __init__(self, project: AsyncProjectResource) -> None:
@@ -201,7 +173,3 @@ def __init__(self, project: AsyncProjectResource) -> None:
201173
self.retrieve = async_to_streamed_response_wrapper(
202174
project.retrieve,
203175
)
204-
205-
@cached_property
206-
def templates(self) -> AsyncTemplatesResourceWithStreamingResponse:
207-
return AsyncTemplatesResourceWithStreamingResponse(self._project.templates)

‎src/unlayer/resources/project/__init__.py‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)