archastro.platform.v1.resources.kv
1# Copyright (c) 2026 ArchAstro Inc. All Rights Reserved. 2# This file is auto-generated by @archastro/sdk-generator. Do not edit. 3# Content hash: bc46a156c11b 4 5from __future__ import annotations 6 7from typing import Required, TypedDict 8 9from ...runtime.http_client import HttpClient, SyncHttpClient 10from ...types.common import KeyValueStorageEntry, KeyValueStorageEntryPage 11 12 13class KvCreateInput(TypedDict, total=False): 14 "Create a key-value storage entry" 15 16 key: Required[str] 17 "Storage key for the entry. Must be a non-empty string unique to this user." 18 user: str | None 19 "Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers." 20 value: Required[str] 21 "Value to store under `key`. Must be a non-empty string." 22 23 24class KvUpsertInput(TypedDict, total=False): 25 "Create or update a key-value storage entry" 26 27 user: str | None 28 "Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers." 29 value: Required[str] 30 "New value to store under `key`. Must be a non-empty string. Replaces any existing value." 31 32 33class AsyncKvResource: 34 def __init__(self, http: HttpClient): 35 self._http = http 36 37 async def list( 38 self, 39 *, 40 page: int | None = None, 41 page_size: int | None = None, 42 user: str | None = None, 43 user_search: str | None = None, 44 key: str | None = None, 45 ) -> KeyValueStorageEntryPage: 46 """ 47 List key-value storage entries 48 Returns key-value storage entries in one of two modes depending on the caller's 49 auth scope. 50 **User-JWT callers** receive a flat list of all their own entries with no 51 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 52 params are ignored. 53 **Developer and server-to-server callers** receive a page-based paginated 54 response across all users within the caller's app. Use `user` to scope results 55 to a single user, `user_search` to do a substring match on email or full name, 56 and `key` to filter entries whose key starts with the given prefix. Results are 57 ordered by creation time descending. 58 59 Args: 60 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 61 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 62 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 63 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 64 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 65 66 Returns: 67 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 68 """ 69 query: dict[str, object] = {} 70 if page is not None: 71 query["page"] = page 72 if page_size is not None: 73 query["page_size"] = page_size 74 if user is not None: 75 query["user"] = user 76 if user_search is not None: 77 query["user_search"] = user_search 78 if key is not None: 79 query["key"] = key 80 return await self._http.request( 81 "/api/v1/kv", 82 query=query, 83 response_type=KeyValueStorageEntryPage, 84 ) 85 86 async def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 87 """ 88 Create a key-value storage entry 89 Creates a new key-value storage entry for the target user under the given key. 90 The key must not already exist for this user; use the upsert endpoint to create 91 or overwrite in a single call. 92 End-user (user-JWT) callers always write to their own storage. Developer and 93 server-to-server callers must supply a `user` param identifying the target user 94 within their app's scope. Attempting to write for a user in a different app 95 returns 404. 96 97 Args: 98 input: Request body. 99 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 100 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 101 input.value: Value to store under `key`. Must be a non-empty string. 102 103 Returns: 104 The newly created key-value storage entry. 105 """ 106 return await self._http.request( 107 "/api/v1/kv", 108 method="POST", 109 body=input, 110 response_type=KeyValueStorageEntry, 111 ) 112 113 async def delete(self, key: str) -> None: 114 """ 115 Delete a key-value storage entry 116 Permanently deletes the key-value storage entry identified by `key` for the 117 target user. Returns 204 No Content on success and 404 if the entry does not 118 exist. 119 End-user (user-JWT) callers can only delete entries they own. Developer and 120 server-to-server callers must supply a `user` param identifying the target user 121 within their app's scope. 122 123 Args: 124 key: Storage key of the entry to delete. Must be a non-empty string. 125 126 Returns: 127 Empty response body. HTTP 204 No Content on success. 128 """ 129 await self._http.request(f"/api/v1/kv/{key}", method="DELETE") 130 131 async def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 132 """ 133 Retrieve a key-value storage entry 134 Returns the key-value storage entry identified by `key` for the target user. 135 Returns 404 if no entry exists for that key. 136 End-user (user-JWT) callers retrieve entries from their own storage. Developer 137 and server-to-server callers must supply a `user` param identifying the target 138 user within their app's scope. 139 140 Args: 141 key: Storage key of the entry to retrieve. Must be a non-empty string. 142 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 143 144 Returns: 145 The key-value storage entry for the given key. 146 """ 147 query: dict[str, object] = {} 148 if user is not None: 149 query["user"] = user 150 return await self._http.request( 151 f"/api/v1/kv/{key}", 152 query=query, 153 response_type=KeyValueStorageEntry, 154 ) 155 156 async def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 157 """ 158 Create or update a key-value storage entry 159 Creates a new key-value storage entry for the given `key`, or overwrites the 160 value if an entry already exists. This is the idempotent alternative to the 161 create endpoint: safe to call regardless of whether the key already exists. 162 End-user (user-JWT) callers always write to their own storage. Developer and 163 server-to-server callers must supply a `user` param identifying the target user 164 within their app's scope. Attempting to write for a user in a different app 165 returns 404. 166 167 Args: 168 key: Storage key to create or overwrite. Must be a non-empty string. 169 input: Request body. 170 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 171 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 172 173 Returns: 174 The created or updated key-value storage entry. 175 """ 176 return await self._http.request( 177 f"/api/v1/kv/{key}", 178 method="PUT", 179 body=input, 180 response_type=KeyValueStorageEntry, 181 ) 182 183 184class KvResource: 185 def __init__(self, http: SyncHttpClient): 186 self._http = http 187 188 def list( 189 self, 190 *, 191 page: int | None = None, 192 page_size: int | None = None, 193 user: str | None = None, 194 user_search: str | None = None, 195 key: str | None = None, 196 ) -> KeyValueStorageEntryPage: 197 """ 198 List key-value storage entries 199 Returns key-value storage entries in one of two modes depending on the caller's 200 auth scope. 201 **User-JWT callers** receive a flat list of all their own entries with no 202 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 203 params are ignored. 204 **Developer and server-to-server callers** receive a page-based paginated 205 response across all users within the caller's app. Use `user` to scope results 206 to a single user, `user_search` to do a substring match on email or full name, 207 and `key` to filter entries whose key starts with the given prefix. Results are 208 ordered by creation time descending. 209 210 Args: 211 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 212 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 213 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 214 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 215 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 216 217 Returns: 218 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 219 """ 220 query: dict[str, object] = {} 221 if page is not None: 222 query["page"] = page 223 if page_size is not None: 224 query["page_size"] = page_size 225 if user is not None: 226 query["user"] = user 227 if user_search is not None: 228 query["user_search"] = user_search 229 if key is not None: 230 query["key"] = key 231 return self._http.request( 232 "/api/v1/kv", 233 query=query, 234 response_type=KeyValueStorageEntryPage, 235 ) 236 237 def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 238 """ 239 Create a key-value storage entry 240 Creates a new key-value storage entry for the target user under the given key. 241 The key must not already exist for this user; use the upsert endpoint to create 242 or overwrite in a single call. 243 End-user (user-JWT) callers always write to their own storage. Developer and 244 server-to-server callers must supply a `user` param identifying the target user 245 within their app's scope. Attempting to write for a user in a different app 246 returns 404. 247 248 Args: 249 input: Request body. 250 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 251 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 252 input.value: Value to store under `key`. Must be a non-empty string. 253 254 Returns: 255 The newly created key-value storage entry. 256 """ 257 return self._http.request( 258 "/api/v1/kv", 259 method="POST", 260 body=input, 261 response_type=KeyValueStorageEntry, 262 ) 263 264 def delete(self, key: str) -> None: 265 """ 266 Delete a key-value storage entry 267 Permanently deletes the key-value storage entry identified by `key` for the 268 target user. Returns 204 No Content on success and 404 if the entry does not 269 exist. 270 End-user (user-JWT) callers can only delete entries they own. Developer and 271 server-to-server callers must supply a `user` param identifying the target user 272 within their app's scope. 273 274 Args: 275 key: Storage key of the entry to delete. Must be a non-empty string. 276 277 Returns: 278 Empty response body. HTTP 204 No Content on success. 279 """ 280 self._http.request(f"/api/v1/kv/{key}", method="DELETE") 281 282 def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 283 """ 284 Retrieve a key-value storage entry 285 Returns the key-value storage entry identified by `key` for the target user. 286 Returns 404 if no entry exists for that key. 287 End-user (user-JWT) callers retrieve entries from their own storage. Developer 288 and server-to-server callers must supply a `user` param identifying the target 289 user within their app's scope. 290 291 Args: 292 key: Storage key of the entry to retrieve. Must be a non-empty string. 293 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 294 295 Returns: 296 The key-value storage entry for the given key. 297 """ 298 query: dict[str, object] = {} 299 if user is not None: 300 query["user"] = user 301 return self._http.request( 302 f"/api/v1/kv/{key}", 303 query=query, 304 response_type=KeyValueStorageEntry, 305 ) 306 307 def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 308 """ 309 Create or update a key-value storage entry 310 Creates a new key-value storage entry for the given `key`, or overwrites the 311 value if an entry already exists. This is the idempotent alternative to the 312 create endpoint: safe to call regardless of whether the key already exists. 313 End-user (user-JWT) callers always write to their own storage. Developer and 314 server-to-server callers must supply a `user` param identifying the target user 315 within their app's scope. Attempting to write for a user in a different app 316 returns 404. 317 318 Args: 319 key: Storage key to create or overwrite. Must be a non-empty string. 320 input: Request body. 321 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 322 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 323 324 Returns: 325 The created or updated key-value storage entry. 326 """ 327 return self._http.request( 328 f"/api/v1/kv/{key}", 329 method="PUT", 330 body=input, 331 response_type=KeyValueStorageEntry, 332 )
14class KvCreateInput(TypedDict, total=False): 15 "Create a key-value storage entry" 16 17 key: Required[str] 18 "Storage key for the entry. Must be a non-empty string unique to this user." 19 user: str | None 20 "Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers." 21 value: Required[str] 22 "Value to store under `key`. Must be a non-empty string."
Create a key-value storage entry
25class KvUpsertInput(TypedDict, total=False): 26 "Create or update a key-value storage entry" 27 28 user: str | None 29 "Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers." 30 value: Required[str] 31 "New value to store under `key`. Must be a non-empty string. Replaces any existing value."
Create or update a key-value storage entry
34class AsyncKvResource: 35 def __init__(self, http: HttpClient): 36 self._http = http 37 38 async def list( 39 self, 40 *, 41 page: int | None = None, 42 page_size: int | None = None, 43 user: str | None = None, 44 user_search: str | None = None, 45 key: str | None = None, 46 ) -> KeyValueStorageEntryPage: 47 """ 48 List key-value storage entries 49 Returns key-value storage entries in one of two modes depending on the caller's 50 auth scope. 51 **User-JWT callers** receive a flat list of all their own entries with no 52 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 53 params are ignored. 54 **Developer and server-to-server callers** receive a page-based paginated 55 response across all users within the caller's app. Use `user` to scope results 56 to a single user, `user_search` to do a substring match on email or full name, 57 and `key` to filter entries whose key starts with the given prefix. Results are 58 ordered by creation time descending. 59 60 Args: 61 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 62 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 63 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 64 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 65 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 66 67 Returns: 68 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 69 """ 70 query: dict[str, object] = {} 71 if page is not None: 72 query["page"] = page 73 if page_size is not None: 74 query["page_size"] = page_size 75 if user is not None: 76 query["user"] = user 77 if user_search is not None: 78 query["user_search"] = user_search 79 if key is not None: 80 query["key"] = key 81 return await self._http.request( 82 "/api/v1/kv", 83 query=query, 84 response_type=KeyValueStorageEntryPage, 85 ) 86 87 async def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 88 """ 89 Create a key-value storage entry 90 Creates a new key-value storage entry for the target user under the given key. 91 The key must not already exist for this user; use the upsert endpoint to create 92 or overwrite in a single call. 93 End-user (user-JWT) callers always write to their own storage. Developer and 94 server-to-server callers must supply a `user` param identifying the target user 95 within their app's scope. Attempting to write for a user in a different app 96 returns 404. 97 98 Args: 99 input: Request body. 100 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 101 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 102 input.value: Value to store under `key`. Must be a non-empty string. 103 104 Returns: 105 The newly created key-value storage entry. 106 """ 107 return await self._http.request( 108 "/api/v1/kv", 109 method="POST", 110 body=input, 111 response_type=KeyValueStorageEntry, 112 ) 113 114 async def delete(self, key: str) -> None: 115 """ 116 Delete a key-value storage entry 117 Permanently deletes the key-value storage entry identified by `key` for the 118 target user. Returns 204 No Content on success and 404 if the entry does not 119 exist. 120 End-user (user-JWT) callers can only delete entries they own. Developer and 121 server-to-server callers must supply a `user` param identifying the target user 122 within their app's scope. 123 124 Args: 125 key: Storage key of the entry to delete. Must be a non-empty string. 126 127 Returns: 128 Empty response body. HTTP 204 No Content on success. 129 """ 130 await self._http.request(f"/api/v1/kv/{key}", method="DELETE") 131 132 async def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 133 """ 134 Retrieve a key-value storage entry 135 Returns the key-value storage entry identified by `key` for the target user. 136 Returns 404 if no entry exists for that key. 137 End-user (user-JWT) callers retrieve entries from their own storage. Developer 138 and server-to-server callers must supply a `user` param identifying the target 139 user within their app's scope. 140 141 Args: 142 key: Storage key of the entry to retrieve. Must be a non-empty string. 143 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 144 145 Returns: 146 The key-value storage entry for the given key. 147 """ 148 query: dict[str, object] = {} 149 if user is not None: 150 query["user"] = user 151 return await self._http.request( 152 f"/api/v1/kv/{key}", 153 query=query, 154 response_type=KeyValueStorageEntry, 155 ) 156 157 async def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 158 """ 159 Create or update a key-value storage entry 160 Creates a new key-value storage entry for the given `key`, or overwrites the 161 value if an entry already exists. This is the idempotent alternative to the 162 create endpoint: safe to call regardless of whether the key already exists. 163 End-user (user-JWT) callers always write to their own storage. Developer and 164 server-to-server callers must supply a `user` param identifying the target user 165 within their app's scope. Attempting to write for a user in a different app 166 returns 404. 167 168 Args: 169 key: Storage key to create or overwrite. Must be a non-empty string. 170 input: Request body. 171 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 172 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 173 174 Returns: 175 The created or updated key-value storage entry. 176 """ 177 return await self._http.request( 178 f"/api/v1/kv/{key}", 179 method="PUT", 180 body=input, 181 response_type=KeyValueStorageEntry, 182 )
38 async def list( 39 self, 40 *, 41 page: int | None = None, 42 page_size: int | None = None, 43 user: str | None = None, 44 user_search: str | None = None, 45 key: str | None = None, 46 ) -> KeyValueStorageEntryPage: 47 """ 48 List key-value storage entries 49 Returns key-value storage entries in one of two modes depending on the caller's 50 auth scope. 51 **User-JWT callers** receive a flat list of all their own entries with no 52 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 53 params are ignored. 54 **Developer and server-to-server callers** receive a page-based paginated 55 response across all users within the caller's app. Use `user` to scope results 56 to a single user, `user_search` to do a substring match on email or full name, 57 and `key` to filter entries whose key starts with the given prefix. Results are 58 ordered by creation time descending. 59 60 Args: 61 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 62 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 63 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 64 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 65 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 66 67 Returns: 68 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 69 """ 70 query: dict[str, object] = {} 71 if page is not None: 72 query["page"] = page 73 if page_size is not None: 74 query["page_size"] = page_size 75 if user is not None: 76 query["user"] = user 77 if user_search is not None: 78 query["user_search"] = user_search 79 if key is not None: 80 query["key"] = key 81 return await self._http.request( 82 "/api/v1/kv", 83 query=query, 84 response_type=KeyValueStorageEntryPage, 85 )
List key-value storage entries
Returns key-value storage entries in one of two modes depending on the caller's
auth scope.
User-JWT callers receive a flat list of all their own entries with no
pagination fields. The page, page_size, user, user_search, and key
params are ignored.
Developer and server-to-server callers receive a page-based paginated
response across all users within the caller's app. Use user to scope results
to a single user, user_search to do a substring match on email or full name,
and key to filter entries whose key starts with the given prefix. Results are
ordered by creation time descending.
Arguments:
- page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1.
- page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100.
- user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only.
- user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only.
- key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only.
Returns:
Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers.
87 async def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 88 """ 89 Create a key-value storage entry 90 Creates a new key-value storage entry for the target user under the given key. 91 The key must not already exist for this user; use the upsert endpoint to create 92 or overwrite in a single call. 93 End-user (user-JWT) callers always write to their own storage. Developer and 94 server-to-server callers must supply a `user` param identifying the target user 95 within their app's scope. Attempting to write for a user in a different app 96 returns 404. 97 98 Args: 99 input: Request body. 100 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 101 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 102 input.value: Value to store under `key`. Must be a non-empty string. 103 104 Returns: 105 The newly created key-value storage entry. 106 """ 107 return await self._http.request( 108 "/api/v1/kv", 109 method="POST", 110 body=input, 111 response_type=KeyValueStorageEntry, 112 )
Create a key-value storage entry
Creates a new key-value storage entry for the target user under the given key.
The key must not already exist for this user; use the upsert endpoint to create
or overwrite in a single call.
End-user (user-JWT) callers always write to their own storage. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope. Attempting to write for a user in a different app
returns 404.
Arguments:
- input: Request body.
- input.key: Storage key for the entry. Must be a non-empty string unique to this user.
- input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
- input.value: Value to store under
key. Must be a non-empty string.
Returns:
The newly created key-value storage entry.
114 async def delete(self, key: str) -> None: 115 """ 116 Delete a key-value storage entry 117 Permanently deletes the key-value storage entry identified by `key` for the 118 target user. Returns 204 No Content on success and 404 if the entry does not 119 exist. 120 End-user (user-JWT) callers can only delete entries they own. Developer and 121 server-to-server callers must supply a `user` param identifying the target user 122 within their app's scope. 123 124 Args: 125 key: Storage key of the entry to delete. Must be a non-empty string. 126 127 Returns: 128 Empty response body. HTTP 204 No Content on success. 129 """ 130 await self._http.request(f"/api/v1/kv/{key}", method="DELETE")
Delete a key-value storage entry
Permanently deletes the key-value storage entry identified by key for the
target user. Returns 204 No Content on success and 404 if the entry does not
exist.
End-user (user-JWT) callers can only delete entries they own. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope.
Arguments:
- key: Storage key of the entry to delete. Must be a non-empty string.
Returns:
Empty response body. HTTP 204 No Content on success.
132 async def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 133 """ 134 Retrieve a key-value storage entry 135 Returns the key-value storage entry identified by `key` for the target user. 136 Returns 404 if no entry exists for that key. 137 End-user (user-JWT) callers retrieve entries from their own storage. Developer 138 and server-to-server callers must supply a `user` param identifying the target 139 user within their app's scope. 140 141 Args: 142 key: Storage key of the entry to retrieve. Must be a non-empty string. 143 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 144 145 Returns: 146 The key-value storage entry for the given key. 147 """ 148 query: dict[str, object] = {} 149 if user is not None: 150 query["user"] = user 151 return await self._http.request( 152 f"/api/v1/kv/{key}", 153 query=query, 154 response_type=KeyValueStorageEntry, 155 )
Retrieve a key-value storage entry
Returns the key-value storage entry identified by key for the target user.
Returns 404 if no entry exists for that key.
End-user (user-JWT) callers retrieve entries from their own storage. Developer
and server-to-server callers must supply a user param identifying the target
user within their app's scope.
Arguments:
- key: Storage key of the entry to retrieve. Must be a non-empty string.
- user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
Returns:
The key-value storage entry for the given key.
157 async def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 158 """ 159 Create or update a key-value storage entry 160 Creates a new key-value storage entry for the given `key`, or overwrites the 161 value if an entry already exists. This is the idempotent alternative to the 162 create endpoint: safe to call regardless of whether the key already exists. 163 End-user (user-JWT) callers always write to their own storage. Developer and 164 server-to-server callers must supply a `user` param identifying the target user 165 within their app's scope. Attempting to write for a user in a different app 166 returns 404. 167 168 Args: 169 key: Storage key to create or overwrite. Must be a non-empty string. 170 input: Request body. 171 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 172 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 173 174 Returns: 175 The created or updated key-value storage entry. 176 """ 177 return await self._http.request( 178 f"/api/v1/kv/{key}", 179 method="PUT", 180 body=input, 181 response_type=KeyValueStorageEntry, 182 )
Create or update a key-value storage entry
Creates a new key-value storage entry for the given key, or overwrites the
value if an entry already exists. This is the idempotent alternative to the
create endpoint: safe to call regardless of whether the key already exists.
End-user (user-JWT) callers always write to their own storage. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope. Attempting to write for a user in a different app
returns 404.
Arguments:
- key: Storage key to create or overwrite. Must be a non-empty string.
- input: Request body.
- input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
- input.value: New value to store under
key. Must be a non-empty string. Replaces any existing value.
Returns:
The created or updated key-value storage entry.
185class KvResource: 186 def __init__(self, http: SyncHttpClient): 187 self._http = http 188 189 def list( 190 self, 191 *, 192 page: int | None = None, 193 page_size: int | None = None, 194 user: str | None = None, 195 user_search: str | None = None, 196 key: str | None = None, 197 ) -> KeyValueStorageEntryPage: 198 """ 199 List key-value storage entries 200 Returns key-value storage entries in one of two modes depending on the caller's 201 auth scope. 202 **User-JWT callers** receive a flat list of all their own entries with no 203 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 204 params are ignored. 205 **Developer and server-to-server callers** receive a page-based paginated 206 response across all users within the caller's app. Use `user` to scope results 207 to a single user, `user_search` to do a substring match on email or full name, 208 and `key` to filter entries whose key starts with the given prefix. Results are 209 ordered by creation time descending. 210 211 Args: 212 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 213 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 214 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 215 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 216 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 217 218 Returns: 219 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 220 """ 221 query: dict[str, object] = {} 222 if page is not None: 223 query["page"] = page 224 if page_size is not None: 225 query["page_size"] = page_size 226 if user is not None: 227 query["user"] = user 228 if user_search is not None: 229 query["user_search"] = user_search 230 if key is not None: 231 query["key"] = key 232 return self._http.request( 233 "/api/v1/kv", 234 query=query, 235 response_type=KeyValueStorageEntryPage, 236 ) 237 238 def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 239 """ 240 Create a key-value storage entry 241 Creates a new key-value storage entry for the target user under the given key. 242 The key must not already exist for this user; use the upsert endpoint to create 243 or overwrite in a single call. 244 End-user (user-JWT) callers always write to their own storage. Developer and 245 server-to-server callers must supply a `user` param identifying the target user 246 within their app's scope. Attempting to write for a user in a different app 247 returns 404. 248 249 Args: 250 input: Request body. 251 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 252 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 253 input.value: Value to store under `key`. Must be a non-empty string. 254 255 Returns: 256 The newly created key-value storage entry. 257 """ 258 return self._http.request( 259 "/api/v1/kv", 260 method="POST", 261 body=input, 262 response_type=KeyValueStorageEntry, 263 ) 264 265 def delete(self, key: str) -> None: 266 """ 267 Delete a key-value storage entry 268 Permanently deletes the key-value storage entry identified by `key` for the 269 target user. Returns 204 No Content on success and 404 if the entry does not 270 exist. 271 End-user (user-JWT) callers can only delete entries they own. Developer and 272 server-to-server callers must supply a `user` param identifying the target user 273 within their app's scope. 274 275 Args: 276 key: Storage key of the entry to delete. Must be a non-empty string. 277 278 Returns: 279 Empty response body. HTTP 204 No Content on success. 280 """ 281 self._http.request(f"/api/v1/kv/{key}", method="DELETE") 282 283 def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 284 """ 285 Retrieve a key-value storage entry 286 Returns the key-value storage entry identified by `key` for the target user. 287 Returns 404 if no entry exists for that key. 288 End-user (user-JWT) callers retrieve entries from their own storage. Developer 289 and server-to-server callers must supply a `user` param identifying the target 290 user within their app's scope. 291 292 Args: 293 key: Storage key of the entry to retrieve. Must be a non-empty string. 294 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 295 296 Returns: 297 The key-value storage entry for the given key. 298 """ 299 query: dict[str, object] = {} 300 if user is not None: 301 query["user"] = user 302 return self._http.request( 303 f"/api/v1/kv/{key}", 304 query=query, 305 response_type=KeyValueStorageEntry, 306 ) 307 308 def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 309 """ 310 Create or update a key-value storage entry 311 Creates a new key-value storage entry for the given `key`, or overwrites the 312 value if an entry already exists. This is the idempotent alternative to the 313 create endpoint: safe to call regardless of whether the key already exists. 314 End-user (user-JWT) callers always write to their own storage. Developer and 315 server-to-server callers must supply a `user` param identifying the target user 316 within their app's scope. Attempting to write for a user in a different app 317 returns 404. 318 319 Args: 320 key: Storage key to create or overwrite. Must be a non-empty string. 321 input: Request body. 322 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 323 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 324 325 Returns: 326 The created or updated key-value storage entry. 327 """ 328 return self._http.request( 329 f"/api/v1/kv/{key}", 330 method="PUT", 331 body=input, 332 response_type=KeyValueStorageEntry, 333 )
189 def list( 190 self, 191 *, 192 page: int | None = None, 193 page_size: int | None = None, 194 user: str | None = None, 195 user_search: str | None = None, 196 key: str | None = None, 197 ) -> KeyValueStorageEntryPage: 198 """ 199 List key-value storage entries 200 Returns key-value storage entries in one of two modes depending on the caller's 201 auth scope. 202 **User-JWT callers** receive a flat list of all their own entries with no 203 pagination fields. The `page`, `page_size`, `user`, `user_search`, and `key` 204 params are ignored. 205 **Developer and server-to-server callers** receive a page-based paginated 206 response across all users within the caller's app. Use `user` to scope results 207 to a single user, `user_search` to do a substring match on email or full name, 208 and `key` to filter entries whose key starts with the given prefix. Results are 209 ordered by creation time descending. 210 211 Args: 212 page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1. 213 page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100. 214 user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only. 215 user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only. 216 key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only. 217 218 Returns: 219 Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers. 220 """ 221 query: dict[str, object] = {} 222 if page is not None: 223 query["page"] = page 224 if page_size is not None: 225 query["page_size"] = page_size 226 if user is not None: 227 query["user"] = user 228 if user_search is not None: 229 query["user_search"] = user_search 230 if key is not None: 231 query["key"] = key 232 return self._http.request( 233 "/api/v1/kv", 234 query=query, 235 response_type=KeyValueStorageEntryPage, 236 )
List key-value storage entries
Returns key-value storage entries in one of two modes depending on the caller's
auth scope.
User-JWT callers receive a flat list of all their own entries with no
pagination fields. The page, page_size, user, user_search, and key
params are ignored.
Developer and server-to-server callers receive a page-based paginated
response across all users within the caller's app. Use user to scope results
to a single user, user_search to do a substring match on email or full name,
and key to filter entries whose key starts with the given prefix. Results are
ordered by creation time descending.
Arguments:
- page: Page number to retrieve. Applies to developer and server-to-server callers only. Defaults to 1.
- page_size: Number of entries per page. Applies to developer and server-to-server callers only. Defaults to 25; maximum is 100.
- user: Filter results to entries belonging to this user ID. Applies to developer and server-to-server callers only.
- user_search: Substring match against user email address and full name. Applies to developer and server-to-server callers only.
- key: Prefix filter on the storage key. Returns only entries whose key starts with this string. Applies to developer and server-to-server callers only.
Returns:
Key-value storage entries for the current page, with pagination metadata for developer and server-to-server callers.
238 def create(self, input: KvCreateInput) -> KeyValueStorageEntry: 239 """ 240 Create a key-value storage entry 241 Creates a new key-value storage entry for the target user under the given key. 242 The key must not already exist for this user; use the upsert endpoint to create 243 or overwrite in a single call. 244 End-user (user-JWT) callers always write to their own storage. Developer and 245 server-to-server callers must supply a `user` param identifying the target user 246 within their app's scope. Attempting to write for a user in a different app 247 returns 404. 248 249 Args: 250 input: Request body. 251 input.key: Storage key for the entry. Must be a non-empty string unique to this user. 252 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 253 input.value: Value to store under `key`. Must be a non-empty string. 254 255 Returns: 256 The newly created key-value storage entry. 257 """ 258 return self._http.request( 259 "/api/v1/kv", 260 method="POST", 261 body=input, 262 response_type=KeyValueStorageEntry, 263 )
Create a key-value storage entry
Creates a new key-value storage entry for the target user under the given key.
The key must not already exist for this user; use the upsert endpoint to create
or overwrite in a single call.
End-user (user-JWT) callers always write to their own storage. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope. Attempting to write for a user in a different app
returns 404.
Arguments:
- input: Request body.
- input.key: Storage key for the entry. Must be a non-empty string unique to this user.
- input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
- input.value: Value to store under
key. Must be a non-empty string.
Returns:
The newly created key-value storage entry.
265 def delete(self, key: str) -> None: 266 """ 267 Delete a key-value storage entry 268 Permanently deletes the key-value storage entry identified by `key` for the 269 target user. Returns 204 No Content on success and 404 if the entry does not 270 exist. 271 End-user (user-JWT) callers can only delete entries they own. Developer and 272 server-to-server callers must supply a `user` param identifying the target user 273 within their app's scope. 274 275 Args: 276 key: Storage key of the entry to delete. Must be a non-empty string. 277 278 Returns: 279 Empty response body. HTTP 204 No Content on success. 280 """ 281 self._http.request(f"/api/v1/kv/{key}", method="DELETE")
Delete a key-value storage entry
Permanently deletes the key-value storage entry identified by key for the
target user. Returns 204 No Content on success and 404 if the entry does not
exist.
End-user (user-JWT) callers can only delete entries they own. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope.
Arguments:
- key: Storage key of the entry to delete. Must be a non-empty string.
Returns:
Empty response body. HTTP 204 No Content on success.
283 def get(self, key: str, *, user: str | None = None) -> KeyValueStorageEntry: 284 """ 285 Retrieve a key-value storage entry 286 Returns the key-value storage entry identified by `key` for the target user. 287 Returns 404 if no entry exists for that key. 288 End-user (user-JWT) callers retrieve entries from their own storage. Developer 289 and server-to-server callers must supply a `user` param identifying the target 290 user within their app's scope. 291 292 Args: 293 key: Storage key of the entry to retrieve. Must be a non-empty string. 294 user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 295 296 Returns: 297 The key-value storage entry for the given key. 298 """ 299 query: dict[str, object] = {} 300 if user is not None: 301 query["user"] = user 302 return self._http.request( 303 f"/api/v1/kv/{key}", 304 query=query, 305 response_type=KeyValueStorageEntry, 306 )
Retrieve a key-value storage entry
Returns the key-value storage entry identified by key for the target user.
Returns 404 if no entry exists for that key.
End-user (user-JWT) callers retrieve entries from their own storage. Developer
and server-to-server callers must supply a user param identifying the target
user within their app's scope.
Arguments:
- key: Storage key of the entry to retrieve. Must be a non-empty string.
- user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
Returns:
The key-value storage entry for the given key.
308 def upsert(self, key: str, input: KvUpsertInput) -> KeyValueStorageEntry: 309 """ 310 Create or update a key-value storage entry 311 Creates a new key-value storage entry for the given `key`, or overwrites the 312 value if an entry already exists. This is the idempotent alternative to the 313 create endpoint: safe to call regardless of whether the key already exists. 314 End-user (user-JWT) callers always write to their own storage. Developer and 315 server-to-server callers must supply a `user` param identifying the target user 316 within their app's scope. Attempting to write for a user in a different app 317 returns 404. 318 319 Args: 320 key: Storage key to create or overwrite. Must be a non-empty string. 321 input: Request body. 322 input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers. 323 input.value: New value to store under `key`. Must be a non-empty string. Replaces any existing value. 324 325 Returns: 326 The created or updated key-value storage entry. 327 """ 328 return self._http.request( 329 f"/api/v1/kv/{key}", 330 method="PUT", 331 body=input, 332 response_type=KeyValueStorageEntry, 333 )
Create or update a key-value storage entry
Creates a new key-value storage entry for the given key, or overwrites the
value if an entry already exists. This is the idempotent alternative to the
create endpoint: safe to call regardless of whether the key already exists.
End-user (user-JWT) callers always write to their own storage. Developer and
server-to-server callers must supply a user param identifying the target user
within their app's scope. Attempting to write for a user in a different app
returns 404.
Arguments:
- key: Storage key to create or overwrite. Must be a non-empty string.
- input: Request body.
- input.user: Target user ID. Required when calling as a developer or with a server-to-server key; ignored for end-user callers.
- input.value: New value to store under
key. Must be a non-empty string. Replaces any existing value.
Returns:
The created or updated key-value storage entry.