acontext 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- acontext/__init__.py +0 -8
- acontext/agent/__init__.py +2 -0
- acontext/agent/base.py +2 -1
- acontext/agent/disk.py +25 -18
- acontext/agent/prompts.py +99 -0
- acontext/agent/sandbox.py +547 -0
- acontext/agent/skill.py +35 -44
- acontext/agent/text_editor.py +449 -0
- acontext/async_client.py +4 -5
- acontext/client.py +4 -5
- acontext/client_types.py +2 -0
- acontext/resources/__init__.py +0 -8
- acontext/resources/async_sandboxes.py +27 -0
- acontext/resources/async_sessions.py +0 -41
- acontext/resources/async_skills.py +40 -0
- acontext/resources/async_users.py +2 -2
- acontext/resources/sandboxes.py +27 -0
- acontext/resources/sessions.py +0 -41
- acontext/resources/skills.py +40 -0
- acontext/resources/users.py +2 -2
- acontext/types/__init__.py +8 -22
- acontext/types/sandbox.py +27 -0
- acontext/types/session.py +0 -16
- acontext/types/skill.py +11 -0
- acontext/types/tool.py +0 -6
- acontext/types/user.py +0 -1
- {acontext-0.1.3.dist-info → acontext-0.1.5.dist-info}/METADATA +1 -1
- acontext-0.1.5.dist-info/RECORD +41 -0
- acontext/resources/async_blocks.py +0 -164
- acontext/resources/async_spaces.py +0 -200
- acontext/resources/blocks.py +0 -163
- acontext/resources/spaces.py +0 -198
- acontext/types/block.py +0 -26
- acontext/types/space.py +0 -70
- acontext-0.1.3.dist-info/RECORD +0 -44
- {acontext-0.1.3.dist-info → acontext-0.1.5.dist-info}/WHEEL +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Block endpoints (async).
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from collections.abc import Mapping
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
from ..client_types import AsyncRequesterProtocol
|
|
9
|
-
from ..types.block import Block
|
|
10
|
-
from ..types.tool import InsertBlockResponse
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class AsyncBlocksAPI:
|
|
14
|
-
def __init__(self, requester: AsyncRequesterProtocol) -> None:
|
|
15
|
-
self._requester = requester
|
|
16
|
-
|
|
17
|
-
async def list(
|
|
18
|
-
self,
|
|
19
|
-
space_id: str,
|
|
20
|
-
*,
|
|
21
|
-
parent_id: str | None = None,
|
|
22
|
-
block_type: str | None = None,
|
|
23
|
-
) -> list[Block]:
|
|
24
|
-
"""List blocks in a space.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
space_id: The UUID of the space.
|
|
28
|
-
parent_id: Filter blocks by parent ID. Defaults to None.
|
|
29
|
-
block_type: Filter blocks by type (e.g., "page", "folder", "text", "sop"). Defaults to None.
|
|
30
|
-
|
|
31
|
-
Returns:
|
|
32
|
-
List of Block objects.
|
|
33
|
-
"""
|
|
34
|
-
params: dict[str, Any] = {}
|
|
35
|
-
if parent_id is not None:
|
|
36
|
-
params["parent_id"] = parent_id
|
|
37
|
-
if block_type is not None:
|
|
38
|
-
params["type"] = block_type
|
|
39
|
-
data = await self._requester.request("GET", f"/space/{space_id}/block", params=params or None)
|
|
40
|
-
return [Block.model_validate(item) for item in data]
|
|
41
|
-
|
|
42
|
-
async def create(
|
|
43
|
-
self,
|
|
44
|
-
space_id: str,
|
|
45
|
-
*,
|
|
46
|
-
block_type: str,
|
|
47
|
-
parent_id: str | None = None,
|
|
48
|
-
title: str | None = None,
|
|
49
|
-
props: Mapping[str, Any] | None = None,
|
|
50
|
-
) -> InsertBlockResponse:
|
|
51
|
-
"""Create a new block in a space.
|
|
52
|
-
|
|
53
|
-
Args:
|
|
54
|
-
space_id: The UUID of the space.
|
|
55
|
-
block_type: The type of block (e.g., "page", "folder", "text", "sop").
|
|
56
|
-
parent_id: Optional parent block ID. Defaults to None.
|
|
57
|
-
title: Optional block title. Defaults to None.
|
|
58
|
-
props: Optional block properties dictionary. Defaults to None.
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
InsertBlockResponse containing the new block ID.
|
|
62
|
-
"""
|
|
63
|
-
payload: dict[str, Any] = {"type": block_type}
|
|
64
|
-
if parent_id is not None:
|
|
65
|
-
payload["parent_id"] = parent_id
|
|
66
|
-
if title is not None:
|
|
67
|
-
payload["title"] = title
|
|
68
|
-
if props is not None:
|
|
69
|
-
payload["props"] = props
|
|
70
|
-
data = await self._requester.request("POST", f"/space/{space_id}/block", json_data=payload)
|
|
71
|
-
return InsertBlockResponse.model_validate(data)
|
|
72
|
-
|
|
73
|
-
async def delete(self, space_id: str, block_id: str) -> None:
|
|
74
|
-
"""Delete a block by its ID.
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
space_id: The UUID of the space.
|
|
78
|
-
block_id: The UUID of the block to delete.
|
|
79
|
-
"""
|
|
80
|
-
await self._requester.request("DELETE", f"/space/{space_id}/block/{block_id}")
|
|
81
|
-
|
|
82
|
-
async def get_properties(self, space_id: str, block_id: str) -> Block:
|
|
83
|
-
"""Get block properties.
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
space_id: The UUID of the space.
|
|
87
|
-
block_id: The UUID of the block.
|
|
88
|
-
|
|
89
|
-
Returns:
|
|
90
|
-
Block object containing the properties.
|
|
91
|
-
"""
|
|
92
|
-
data = await self._requester.request("GET", f"/space/{space_id}/block/{block_id}/properties")
|
|
93
|
-
return Block.model_validate(data)
|
|
94
|
-
|
|
95
|
-
async def update_properties(
|
|
96
|
-
self,
|
|
97
|
-
space_id: str,
|
|
98
|
-
block_id: str,
|
|
99
|
-
*,
|
|
100
|
-
title: str | None = None,
|
|
101
|
-
props: Mapping[str, Any] | None = None,
|
|
102
|
-
) -> None:
|
|
103
|
-
"""Update block properties.
|
|
104
|
-
|
|
105
|
-
Args:
|
|
106
|
-
space_id: The UUID of the space.
|
|
107
|
-
block_id: The UUID of the block.
|
|
108
|
-
title: Optional block title. Defaults to None.
|
|
109
|
-
props: Optional block properties dictionary. Defaults to None.
|
|
110
|
-
|
|
111
|
-
Raises:
|
|
112
|
-
ValueError: If both title and props are None.
|
|
113
|
-
"""
|
|
114
|
-
payload: dict[str, Any] = {}
|
|
115
|
-
if title is not None:
|
|
116
|
-
payload["title"] = title
|
|
117
|
-
if props is not None:
|
|
118
|
-
payload["props"] = props
|
|
119
|
-
if not payload:
|
|
120
|
-
raise ValueError("title or props must be provided")
|
|
121
|
-
await self._requester.request("PUT", f"/space/{space_id}/block/{block_id}/properties", json_data=payload)
|
|
122
|
-
|
|
123
|
-
async def move(
|
|
124
|
-
self,
|
|
125
|
-
space_id: str,
|
|
126
|
-
block_id: str,
|
|
127
|
-
*,
|
|
128
|
-
parent_id: str | None = None,
|
|
129
|
-
sort: int | None = None,
|
|
130
|
-
) -> None:
|
|
131
|
-
"""Move a block by updating its parent or sort order.
|
|
132
|
-
|
|
133
|
-
Args:
|
|
134
|
-
space_id: The UUID of the space.
|
|
135
|
-
block_id: The UUID of the block to move.
|
|
136
|
-
parent_id: Optional new parent block ID. Defaults to None.
|
|
137
|
-
sort: Optional new sort order. Defaults to None.
|
|
138
|
-
|
|
139
|
-
Raises:
|
|
140
|
-
ValueError: If both parent_id and sort are None.
|
|
141
|
-
"""
|
|
142
|
-
payload: dict[str, Any] = {}
|
|
143
|
-
if parent_id is not None:
|
|
144
|
-
payload["parent_id"] = parent_id
|
|
145
|
-
if sort is not None:
|
|
146
|
-
payload["sort"] = sort
|
|
147
|
-
if not payload:
|
|
148
|
-
raise ValueError("parent_id or sort must be provided")
|
|
149
|
-
await self._requester.request("PUT", f"/space/{space_id}/block/{block_id}/move", json_data=payload)
|
|
150
|
-
|
|
151
|
-
async def update_sort(self, space_id: str, block_id: str, *, sort: int) -> None:
|
|
152
|
-
"""Update block sort order.
|
|
153
|
-
|
|
154
|
-
Args:
|
|
155
|
-
space_id: The UUID of the space.
|
|
156
|
-
block_id: The UUID of the block.
|
|
157
|
-
sort: The new sort order.
|
|
158
|
-
"""
|
|
159
|
-
await self._requester.request(
|
|
160
|
-
"PUT",
|
|
161
|
-
f"/space/{space_id}/block/{block_id}/sort",
|
|
162
|
-
json_data={"sort": sort},
|
|
163
|
-
)
|
|
164
|
-
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Spaces endpoints (async).
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from collections.abc import Mapping
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
from .._utils import build_params
|
|
9
|
-
from ..client_types import AsyncRequesterProtocol
|
|
10
|
-
from ..types.space import (
|
|
11
|
-
ExperienceConfirmation,
|
|
12
|
-
ListExperienceConfirmationsOutput,
|
|
13
|
-
ListSpacesOutput,
|
|
14
|
-
Space,
|
|
15
|
-
SpaceSearchResult,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class AsyncSpacesAPI:
|
|
20
|
-
def __init__(self, requester: AsyncRequesterProtocol) -> None:
|
|
21
|
-
self._requester = requester
|
|
22
|
-
|
|
23
|
-
async def list(
|
|
24
|
-
self,
|
|
25
|
-
*,
|
|
26
|
-
user: str | None = None,
|
|
27
|
-
limit: int | None = None,
|
|
28
|
-
cursor: str | None = None,
|
|
29
|
-
time_desc: bool | None = None,
|
|
30
|
-
) -> ListSpacesOutput:
|
|
31
|
-
"""List all spaces in the project.
|
|
32
|
-
|
|
33
|
-
Args:
|
|
34
|
-
user: Filter by user identifier. Defaults to None.
|
|
35
|
-
limit: Maximum number of spaces to return. Defaults to None.
|
|
36
|
-
cursor: Cursor for pagination. Defaults to None.
|
|
37
|
-
time_desc: Order by created_at descending if True, ascending if False. Defaults to None.
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
ListSpacesOutput containing the list of spaces and pagination information.
|
|
41
|
-
"""
|
|
42
|
-
params = build_params(user=user, limit=limit, cursor=cursor, time_desc=time_desc)
|
|
43
|
-
data = await self._requester.request("GET", "/space", params=params or None)
|
|
44
|
-
return ListSpacesOutput.model_validate(data)
|
|
45
|
-
|
|
46
|
-
async def create(
|
|
47
|
-
self,
|
|
48
|
-
*,
|
|
49
|
-
user: str | None = None,
|
|
50
|
-
configs: Mapping[str, Any] | None = None,
|
|
51
|
-
) -> Space:
|
|
52
|
-
"""Create a new space.
|
|
53
|
-
|
|
54
|
-
Args:
|
|
55
|
-
user: Optional user identifier string. Defaults to None.
|
|
56
|
-
configs: Optional space configuration dictionary. Defaults to None.
|
|
57
|
-
|
|
58
|
-
Returns:
|
|
59
|
-
The created Space object.
|
|
60
|
-
"""
|
|
61
|
-
payload: dict[str, Any] = {}
|
|
62
|
-
if user is not None:
|
|
63
|
-
payload["user"] = user
|
|
64
|
-
if configs is not None:
|
|
65
|
-
payload["configs"] = configs
|
|
66
|
-
data = await self._requester.request("POST", "/space", json_data=payload)
|
|
67
|
-
return Space.model_validate(data)
|
|
68
|
-
|
|
69
|
-
async def delete(self, space_id: str) -> None:
|
|
70
|
-
"""Delete a space by its ID.
|
|
71
|
-
|
|
72
|
-
Args:
|
|
73
|
-
space_id: The UUID of the space to delete.
|
|
74
|
-
"""
|
|
75
|
-
await self._requester.request("DELETE", f"/space/{space_id}")
|
|
76
|
-
|
|
77
|
-
async def update_configs(
|
|
78
|
-
self,
|
|
79
|
-
space_id: str,
|
|
80
|
-
*,
|
|
81
|
-
configs: Mapping[str, Any],
|
|
82
|
-
) -> None:
|
|
83
|
-
"""Update space configurations.
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
space_id: The UUID of the space.
|
|
87
|
-
configs: Space configuration dictionary.
|
|
88
|
-
"""
|
|
89
|
-
payload = {"configs": configs}
|
|
90
|
-
await self._requester.request(
|
|
91
|
-
"PUT", f"/space/{space_id}/configs", json_data=payload
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
async def get_configs(self, space_id: str) -> Space:
|
|
95
|
-
"""Get space configurations.
|
|
96
|
-
|
|
97
|
-
Args:
|
|
98
|
-
space_id: The UUID of the space.
|
|
99
|
-
|
|
100
|
-
Returns:
|
|
101
|
-
Space object containing the configurations.
|
|
102
|
-
"""
|
|
103
|
-
data = await self._requester.request("GET", f"/space/{space_id}/configs")
|
|
104
|
-
return Space.model_validate(data)
|
|
105
|
-
|
|
106
|
-
async def experience_search(
|
|
107
|
-
self,
|
|
108
|
-
space_id: str,
|
|
109
|
-
*,
|
|
110
|
-
query: str,
|
|
111
|
-
limit: int | None = None,
|
|
112
|
-
mode: str | None = None,
|
|
113
|
-
semantic_threshold: float | None = None,
|
|
114
|
-
max_iterations: int | None = None,
|
|
115
|
-
) -> SpaceSearchResult:
|
|
116
|
-
"""Perform experience search within a space.
|
|
117
|
-
|
|
118
|
-
This is the most advanced search option that can operate in two modes:
|
|
119
|
-
- fast: Quick semantic search (default)
|
|
120
|
-
- agentic: Iterative search with AI-powered refinement
|
|
121
|
-
|
|
122
|
-
Args:
|
|
123
|
-
space_id: The UUID of the space.
|
|
124
|
-
query: The search query string.
|
|
125
|
-
limit: Maximum number of results to return (1-50, default 10).
|
|
126
|
-
mode: Search mode, either "fast" or "agentic" (default "fast").
|
|
127
|
-
semantic_threshold: Cosine distance threshold (0=identical, 2=opposite).
|
|
128
|
-
max_iterations: Maximum iterations for agentic search (1-100, default 16).
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
SpaceSearchResult containing cited blocks and optional final answer.
|
|
132
|
-
"""
|
|
133
|
-
params = build_params(
|
|
134
|
-
query=query,
|
|
135
|
-
limit=limit,
|
|
136
|
-
mode=mode,
|
|
137
|
-
semantic_threshold=semantic_threshold,
|
|
138
|
-
max_iterations=max_iterations,
|
|
139
|
-
)
|
|
140
|
-
data = await self._requester.request(
|
|
141
|
-
"GET", f"/space/{space_id}/experience_search", params=params or None
|
|
142
|
-
)
|
|
143
|
-
return SpaceSearchResult.model_validate(data)
|
|
144
|
-
|
|
145
|
-
async def get_unconfirmed_experiences(
|
|
146
|
-
self,
|
|
147
|
-
space_id: str,
|
|
148
|
-
*,
|
|
149
|
-
limit: int | None = None,
|
|
150
|
-
cursor: str | None = None,
|
|
151
|
-
time_desc: bool | None = None,
|
|
152
|
-
) -> ListExperienceConfirmationsOutput:
|
|
153
|
-
"""Get all unconfirmed experiences in a space with cursor-based pagination.
|
|
154
|
-
|
|
155
|
-
Args:
|
|
156
|
-
space_id: The UUID of the space.
|
|
157
|
-
limit: Maximum number of confirmations to return (1-200, default 20).
|
|
158
|
-
cursor: Cursor for pagination. Use the cursor from the previous response to get the next page.
|
|
159
|
-
time_desc: Order by created_at descending if True, ascending if False (default False).
|
|
160
|
-
|
|
161
|
-
Returns:
|
|
162
|
-
ListExperienceConfirmationsOutput containing the list of experience confirmations and pagination information.
|
|
163
|
-
"""
|
|
164
|
-
params = build_params(limit=limit, cursor=cursor, time_desc=time_desc)
|
|
165
|
-
data = await self._requester.request(
|
|
166
|
-
"GET",
|
|
167
|
-
f"/space/{space_id}/experience_confirmations",
|
|
168
|
-
params=params or None,
|
|
169
|
-
)
|
|
170
|
-
return ListExperienceConfirmationsOutput.model_validate(data)
|
|
171
|
-
|
|
172
|
-
async def confirm_experience(
|
|
173
|
-
self,
|
|
174
|
-
space_id: str,
|
|
175
|
-
experience_id: str,
|
|
176
|
-
*,
|
|
177
|
-
save: bool,
|
|
178
|
-
) -> ExperienceConfirmation | None:
|
|
179
|
-
"""Confirm an experience confirmation.
|
|
180
|
-
|
|
181
|
-
If save is False, delete the row. If save is True, get the data first,
|
|
182
|
-
then delete the row.
|
|
183
|
-
|
|
184
|
-
Args:
|
|
185
|
-
space_id: The UUID of the space.
|
|
186
|
-
experience_id: The UUID of the experience confirmation.
|
|
187
|
-
save: If True, get data before deleting. If False, just delete.
|
|
188
|
-
|
|
189
|
-
Returns:
|
|
190
|
-
ExperienceConfirmation object if save is True, None otherwise.
|
|
191
|
-
"""
|
|
192
|
-
payload = {"save": save}
|
|
193
|
-
data = await self._requester.request(
|
|
194
|
-
"PUT",
|
|
195
|
-
f"/space/{space_id}/experience_confirmations/{experience_id}",
|
|
196
|
-
json_data=payload,
|
|
197
|
-
)
|
|
198
|
-
if data is None:
|
|
199
|
-
return None
|
|
200
|
-
return ExperienceConfirmation.model_validate(data)
|
acontext/resources/blocks.py
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Block endpoints.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from collections.abc import Mapping
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
from ..client_types import RequesterProtocol
|
|
9
|
-
from ..types.block import Block
|
|
10
|
-
from ..types.tool import InsertBlockResponse
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class BlocksAPI:
|
|
14
|
-
def __init__(self, requester: RequesterProtocol) -> None:
|
|
15
|
-
self._requester = requester
|
|
16
|
-
|
|
17
|
-
def list(
|
|
18
|
-
self,
|
|
19
|
-
space_id: str,
|
|
20
|
-
*,
|
|
21
|
-
parent_id: str | None = None,
|
|
22
|
-
block_type: str | None = None,
|
|
23
|
-
) -> list[Block]:
|
|
24
|
-
"""List blocks in a space.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
space_id: The UUID of the space.
|
|
28
|
-
parent_id: Filter blocks by parent ID. Defaults to None.
|
|
29
|
-
block_type: Filter blocks by type (e.g., "page", "folder", "text", "sop"). Defaults to None.
|
|
30
|
-
|
|
31
|
-
Returns:
|
|
32
|
-
List of Block objects.
|
|
33
|
-
"""
|
|
34
|
-
params: dict[str, Any] = {}
|
|
35
|
-
if parent_id is not None:
|
|
36
|
-
params["parent_id"] = parent_id
|
|
37
|
-
if block_type is not None:
|
|
38
|
-
params["type"] = block_type
|
|
39
|
-
data = self._requester.request("GET", f"/space/{space_id}/block", params=params or None)
|
|
40
|
-
return [Block.model_validate(item) for item in data]
|
|
41
|
-
|
|
42
|
-
def create(
|
|
43
|
-
self,
|
|
44
|
-
space_id: str,
|
|
45
|
-
*,
|
|
46
|
-
block_type: str,
|
|
47
|
-
parent_id: str | None = None,
|
|
48
|
-
title: str | None = None,
|
|
49
|
-
props: Mapping[str, Any] | None = None,
|
|
50
|
-
) -> InsertBlockResponse:
|
|
51
|
-
"""Create a new block in a space.
|
|
52
|
-
|
|
53
|
-
Args:
|
|
54
|
-
space_id: The UUID of the space.
|
|
55
|
-
block_type: The type of block (e.g., "page", "folder", "text", "sop").
|
|
56
|
-
parent_id: Optional parent block ID. Defaults to None.
|
|
57
|
-
title: Optional block title. Defaults to None.
|
|
58
|
-
props: Optional block properties dictionary. Defaults to None.
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
InsertBlockResponse containing the new block ID.
|
|
62
|
-
"""
|
|
63
|
-
payload: dict[str, Any] = {"type": block_type}
|
|
64
|
-
if parent_id is not None:
|
|
65
|
-
payload["parent_id"] = parent_id
|
|
66
|
-
if title is not None:
|
|
67
|
-
payload["title"] = title
|
|
68
|
-
if props is not None:
|
|
69
|
-
payload["props"] = props
|
|
70
|
-
data = self._requester.request("POST", f"/space/{space_id}/block", json_data=payload)
|
|
71
|
-
return InsertBlockResponse.model_validate(data)
|
|
72
|
-
|
|
73
|
-
def delete(self, space_id: str, block_id: str) -> None:
|
|
74
|
-
"""Delete a block by its ID.
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
space_id: The UUID of the space.
|
|
78
|
-
block_id: The UUID of the block to delete.
|
|
79
|
-
"""
|
|
80
|
-
self._requester.request("DELETE", f"/space/{space_id}/block/{block_id}")
|
|
81
|
-
|
|
82
|
-
def get_properties(self, space_id: str, block_id: str) -> Block:
|
|
83
|
-
"""Get block properties.
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
space_id: The UUID of the space.
|
|
87
|
-
block_id: The UUID of the block.
|
|
88
|
-
|
|
89
|
-
Returns:
|
|
90
|
-
Block object containing the properties.
|
|
91
|
-
"""
|
|
92
|
-
data = self._requester.request("GET", f"/space/{space_id}/block/{block_id}/properties")
|
|
93
|
-
return Block.model_validate(data)
|
|
94
|
-
|
|
95
|
-
def update_properties(
|
|
96
|
-
self,
|
|
97
|
-
space_id: str,
|
|
98
|
-
block_id: str,
|
|
99
|
-
*,
|
|
100
|
-
title: str | None = None,
|
|
101
|
-
props: Mapping[str, Any] | None = None,
|
|
102
|
-
) -> None:
|
|
103
|
-
"""Update block properties.
|
|
104
|
-
|
|
105
|
-
Args:
|
|
106
|
-
space_id: The UUID of the space.
|
|
107
|
-
block_id: The UUID of the block.
|
|
108
|
-
title: Optional block title. Defaults to None.
|
|
109
|
-
props: Optional block properties dictionary. Defaults to None.
|
|
110
|
-
|
|
111
|
-
Raises:
|
|
112
|
-
ValueError: If both title and props are None.
|
|
113
|
-
"""
|
|
114
|
-
payload: dict[str, Any] = {}
|
|
115
|
-
if title is not None:
|
|
116
|
-
payload["title"] = title
|
|
117
|
-
if props is not None:
|
|
118
|
-
payload["props"] = props
|
|
119
|
-
if not payload:
|
|
120
|
-
raise ValueError("title or props must be provided")
|
|
121
|
-
self._requester.request("PUT", f"/space/{space_id}/block/{block_id}/properties", json_data=payload)
|
|
122
|
-
|
|
123
|
-
def move(
|
|
124
|
-
self,
|
|
125
|
-
space_id: str,
|
|
126
|
-
block_id: str,
|
|
127
|
-
*,
|
|
128
|
-
parent_id: str | None = None,
|
|
129
|
-
sort: int | None = None,
|
|
130
|
-
) -> None:
|
|
131
|
-
"""Move a block by updating its parent or sort order.
|
|
132
|
-
|
|
133
|
-
Args:
|
|
134
|
-
space_id: The UUID of the space.
|
|
135
|
-
block_id: The UUID of the block to move.
|
|
136
|
-
parent_id: Optional new parent block ID. Defaults to None.
|
|
137
|
-
sort: Optional new sort order. Defaults to None.
|
|
138
|
-
|
|
139
|
-
Raises:
|
|
140
|
-
ValueError: If both parent_id and sort are None.
|
|
141
|
-
"""
|
|
142
|
-
payload: dict[str, Any] = {}
|
|
143
|
-
if parent_id is not None:
|
|
144
|
-
payload["parent_id"] = parent_id
|
|
145
|
-
if sort is not None:
|
|
146
|
-
payload["sort"] = sort
|
|
147
|
-
if not payload:
|
|
148
|
-
raise ValueError("parent_id or sort must be provided")
|
|
149
|
-
self._requester.request("PUT", f"/space/{space_id}/block/{block_id}/move", json_data=payload)
|
|
150
|
-
|
|
151
|
-
def update_sort(self, space_id: str, block_id: str, *, sort: int) -> None:
|
|
152
|
-
"""Update block sort order.
|
|
153
|
-
|
|
154
|
-
Args:
|
|
155
|
-
space_id: The UUID of the space.
|
|
156
|
-
block_id: The UUID of the block.
|
|
157
|
-
sort: The new sort order.
|
|
158
|
-
"""
|
|
159
|
-
self._requester.request(
|
|
160
|
-
"PUT",
|
|
161
|
-
f"/space/{space_id}/block/{block_id}/sort",
|
|
162
|
-
json_data={"sort": sort},
|
|
163
|
-
)
|