volcano-sdk-python 0.16.0__py3-none-any.whl → 0.17.1__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.
@@ -11,7 +11,6 @@ from ._auth_values import (
11
11
  HOSTED_AUTH_ACTIONS,
12
12
  INVALID_AUTH_TRANSPORT,
13
13
  NO_ACTIVE_SESSION,
14
- PATH_SEGMENT_SAFE,
15
14
  UNSUPPORTED_HOSTED_AUTH_ACTION,
16
15
  copy_complete_session,
17
16
  hosted_auth_parameter,
@@ -27,6 +26,7 @@ from ._auth_values import (
27
26
  validate_hosted_auth_callback_state,
28
27
  validate_oauth_callback_state,
29
28
  )
29
+ from ._path_segments import path_identifier
30
30
  from ._transport import (
31
31
  AuthCallOAuthAPITransport,
32
32
  AuthGetOAuthProviderTokenTransport,
@@ -103,7 +103,9 @@ class OAuthAuth(AuthBase):
103
103
  ValueError: A parameter is empty or the action is unsupported.
104
104
 
105
105
  """
106
- project = hosted_auth_parameter(project_id).strip()
106
+ project = path_identifier(
107
+ hosted_auth_parameter(project_id).strip(), "project_id"
108
+ )
107
109
  auth_state = hosted_auth_parameter(state)
108
110
  if action not in HOSTED_AUTH_ACTIONS:
109
111
  raise ValueError(UNSUPPORTED_HOSTED_AUTH_ACTION)
@@ -114,7 +116,7 @@ class OAuthAuth(AuthBase):
114
116
  "state": auth_state,
115
117
  }
116
118
  )
117
- project_path = quote(project, safe=PATH_SEGMENT_SAFE)
119
+ project_path = quote(project)
118
120
  return (
119
121
  f"{self._client.api_base_url()}/projects/{project_path}/auth/hosted?{query}"
120
122
  )
@@ -137,9 +137,6 @@ OAUTH_API_METHODS: frozenset[str] = frozenset({"GET", "POST"})
137
137
  HOSTED_AUTH_ACTIONS: frozenset[str] = frozenset({"login", "signup", "forgot-password"})
138
138
 
139
139
 
140
- PATH_SEGMENT_SAFE = ""
141
-
142
-
143
140
  def is_non_empty_string(value: object) -> bool:
144
141
  return isinstance(value, str) and bool(value.strip())
145
142
 
@@ -5,6 +5,8 @@ from __future__ import annotations
5
5
  from typing import TYPE_CHECKING
6
6
  from uuid import UUID
7
7
 
8
+ from ._path_segments import path_identifier
9
+
8
10
  if TYPE_CHECKING:
9
11
  from collections.abc import Mapping
10
12
 
@@ -15,6 +17,9 @@ _INVALID_IDENTIFIERS = {
15
17
  "execution_id": "execution_id must be a non-empty string",
16
18
  "approval_id": "approval_id must be a non-empty string",
17
19
  }
20
+ # The identifiers sent as URL path segments; an execution name is sent in
21
+ # the X-Volcano-Execution-Name header.
22
+ _PATH_IDENTIFIERS = frozenset(_INVALID_IDENTIFIERS) - {"execution_name"}
18
23
  # The identifiers the transport converts to a UUID before sending. Checked
19
24
  # here so a malformed one is a facade ValidationError rather than a
20
25
  # `badly formed hexadecimal UUID string` raised from inside the transport,
@@ -46,6 +51,8 @@ def identifier(value: object, field: str) -> str:
46
51
  if not isinstance(value, str) or not value.strip():
47
52
  raise ValueError(_INVALID_IDENTIFIERS[field])
48
53
  trimmed = value.strip()
54
+ if field in _PATH_IDENTIFIERS:
55
+ trimmed = path_identifier(trimmed, field)
49
56
  if field not in _UUID_IDENTIFIERS:
50
57
  return trimmed
51
58
  try:
@@ -19,6 +19,7 @@ from ._transport_response import (
19
19
  unparsed_response,
20
20
  )
21
21
  from ._transport_types import HTTP_CREATED, HTTP_OK
22
+ from ._user_agent import user_agent_headers
22
23
  from .errors import (
23
24
  ConflictError,
24
25
  NotFoundError,
@@ -117,7 +118,12 @@ def post_to_platform(api_url: str, request: PlatformRequest) -> object:
117
118
  """
118
119
  url = f"{api_url.removesuffix('/')}{request.path}"
119
120
  content = encode(request.body)
120
- headers = {**_JSON, **request.headers}
121
+ caller_headers = {
122
+ name: value
123
+ for name, value in request.headers.items()
124
+ if name.lower() != "user-agent"
125
+ }
126
+ headers = {**_JSON, **caller_headers, **user_agent_headers()}
121
127
  deadline = monotonic() + _DEADLINE_SECONDS
122
128
  timeout = _REQUEST_TIMEOUT_SECONDS
123
129
  for delay in _RETRY_DELAYS:
@@ -10,6 +10,7 @@ from ._lock_renewer import renewal_delay as _calculate_renewal_delay
10
10
 
11
11
  if TYPE_CHECKING:
12
12
  from _thread import LockType
13
+ from collections.abc import Callable
13
14
 
14
15
  from .models import LockLease
15
16
 
@@ -30,17 +31,23 @@ SUSPEND_AWARE_CLOCK_ID = suspend_aware_clock_id(_clock_id_value)
30
31
  class FallbackClock:
31
32
  """Combine monotonic progress with suspend-aware wall time."""
32
33
 
33
- def __init__(self) -> None:
34
+ def __init__(
35
+ self,
36
+ monotonic: Callable[[], float] = time.monotonic,
37
+ wall: Callable[[], float] = time.time,
38
+ ) -> None:
34
39
  self._lock: LockType = threading.Lock()
35
- self._monotonic: float = time.monotonic()
36
- self._value: float = time.time()
40
+ self._read_monotonic: Callable[[], float] = monotonic
41
+ self._read_wall: Callable[[], float] = wall
42
+ self._monotonic: float = monotonic()
43
+ self._value: float = wall()
37
44
 
38
45
  def __call__(self) -> float:
39
46
  with self._lock:
40
- monotonic = time.monotonic()
47
+ monotonic = self._read_monotonic()
41
48
  elapsed = max(0.0, monotonic - self._monotonic)
42
49
  self._monotonic = monotonic
43
- self._value = max(self._value + elapsed, time.time())
50
+ self._value = max(self._value + elapsed, self._read_wall())
44
51
  return self._value
45
52
 
46
53
 
@@ -0,0 +1,161 @@
1
+ """Keep caller values inside the route they are written into.
2
+
3
+ httpx removes ``.`` and ``..`` segments when it joins a request path to the
4
+ API URL, and Volcano routes on the decoded path, so an encoded ``/`` still
5
+ separates segments there. A value that becomes a dot or empty segment would
6
+ send the request to a different route than the operation intended; an empty
7
+ segment can also turn an item route into its collection route.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import re
13
+ from typing import Final
14
+
15
+ SEGMENT_RULE: Final = 'cannot contain empty, ".", or ".." segments'
16
+ REQUEST_PATH_SEGMENTS: Final = f"Request path {SEGMENT_RULE}"
17
+ STORAGE_PATH_SEGMENTS: Final = f"Storage path {SEGMENT_RULE}"
18
+ INVALID_BUCKET_NAME: Final = 'Bucket name must be 1-64 letters, numbers, "_", or "-"'
19
+ INVALID_DATABASE_NAME: Final = (
20
+ 'Database name must be 1-64 lowercase letters, numbers, or "_"'
21
+ )
22
+ INVALID_LOCK_KEY: Final = (
23
+ "Lock key must start with a letter or number and contain at most 128 "
24
+ 'letters, numbers, ".", "_", ":", or "-"'
25
+ )
26
+ INVALID_IDENTIFIER: Final = '{field} cannot contain "/" or be "." or ".."'
27
+
28
+ _DOT_SEGMENTS: Final = frozenset({".", ".."})
29
+ _BUCKET_NAME: Final = re.compile(r"[A-Za-z0-9_-]{1,64}")
30
+ _DATABASE_NAME: Final = re.compile(r"[a-z0-9_]{1,64}")
31
+ _LOCK_KEY: Final = re.compile(r"[A-Za-z0-9][A-Za-z0-9._:-]{0,127}")
32
+ _ENCODED_DOT: Final = re.compile(r"%2e", re.IGNORECASE)
33
+ _ENCODED_SLASH: Final = re.compile(r"%2f", re.IGNORECASE)
34
+
35
+
36
+ def bucket_relative_path(path: str) -> str:
37
+ """Drop one leading separator; Volcano treats "/a.txt" and "a.txt" alike.
38
+
39
+ Returns:
40
+ The path relative to its bucket.
41
+
42
+ """
43
+ return path.removeprefix("/")
44
+
45
+
46
+ def invalid_storage_path(path: str) -> bool:
47
+ """Report whether an object path has an empty, "." or ".." segment.
48
+
49
+ Returns:
50
+ Whether the path would leave its object route.
51
+
52
+ """
53
+ relative = bucket_relative_path(path)
54
+ return not relative or any(
55
+ not segment or segment in _DOT_SEGMENTS for segment in relative.split("/")
56
+ )
57
+
58
+
59
+ def bucket_name(value: str) -> str:
60
+ """Require the API's bucket name pattern across the whole value.
61
+
62
+ Returns:
63
+ The unchanged bucket name.
64
+
65
+ Raises:
66
+ ValueError: The name does not match the bucket name pattern.
67
+
68
+ """
69
+ if not _BUCKET_NAME.fullmatch(value):
70
+ raise ValueError(INVALID_BUCKET_NAME)
71
+ return value
72
+
73
+
74
+ def database_name(value: str) -> str:
75
+ """Require the API's database name pattern across the whole value.
76
+
77
+ Returns:
78
+ The unchanged database name.
79
+
80
+ Raises:
81
+ ValueError: The name does not match the database name pattern.
82
+
83
+ """
84
+ if not _DATABASE_NAME.fullmatch(value):
85
+ raise ValueError(INVALID_DATABASE_NAME)
86
+ return value
87
+
88
+
89
+ def lock_key(value: str) -> str:
90
+ """Require the API's lock key pattern across the whole value.
91
+
92
+ Returns:
93
+ The unchanged lock key.
94
+
95
+ Raises:
96
+ ValueError: The key does not match the lock key pattern.
97
+
98
+ """
99
+ if not _LOCK_KEY.fullmatch(value):
100
+ raise ValueError(INVALID_LOCK_KEY)
101
+ return value
102
+
103
+
104
+ def path_identifier(value: str, field: str) -> str:
105
+ """Refuse an identifier that would not stay one path segment.
106
+
107
+ Returns:
108
+ The unchanged identifier.
109
+
110
+ Raises:
111
+ ValueError: The identifier is ".", "..", or contains "/".
112
+
113
+ """
114
+ if value in _DOT_SEGMENTS or "/" in value:
115
+ raise ValueError(INVALID_IDENTIFIER.format(field=field))
116
+ return value
117
+
118
+
119
+ def invalid_request_segment(segment: str) -> bool:
120
+ """Report whether an encoded path segment resolves to an empty or dot segment.
121
+
122
+ Returns:
123
+ Whether the segment, decoded the way Volcano routes it, is empty,
124
+ "." or "..".
125
+
126
+ """
127
+ decoded = _ENCODED_DOT.sub(".", segment)
128
+ return any(
129
+ not part or part in _DOT_SEGMENTS for part in _ENCODED_SLASH.split(decoded)
130
+ )
131
+
132
+
133
+ def check_request_path(path: str) -> str:
134
+ """Refuse a relative request path before httpx resolves it.
135
+
136
+ Returns:
137
+ The unchanged path.
138
+
139
+ Raises:
140
+ ValueError: A segment is empty, "." or "..", directly or once decoded.
141
+
142
+ """
143
+ route = path.removeprefix("/")
144
+ if any(invalid_request_segment(segment) for segment in route.split("/")):
145
+ raise ValueError(REQUEST_PATH_SEGMENTS)
146
+ return path
147
+
148
+
149
+ def object_path(path: str) -> str:
150
+ """Check an object path and return it relative to its bucket.
151
+
152
+ Returns:
153
+ The path without its leading separator.
154
+
155
+ Raises:
156
+ ValueError: A segment is empty, "." or "..".
157
+
158
+ """
159
+ if invalid_storage_path(path):
160
+ raise ValueError(STORAGE_PATH_SEGMENTS)
161
+ return bucket_relative_path(path)
@@ -10,6 +10,8 @@ from typing import TYPE_CHECKING, Protocol, TypeVar, overload
10
10
  from centrifuge import CentrifugeError, Client
11
11
  from typing_extensions import override
12
12
 
13
+ from ._user_agent import user_agent_headers
14
+
13
15
  if TYPE_CHECKING:
14
16
  from typing import TypeGuard
15
17
 
@@ -202,7 +204,13 @@ def centrifuge_client(
202
204
  token: str,
203
205
  get_token: Callable[[], Awaitable[str]],
204
206
  ) -> CentrifugeConnection:
205
- return Client(address, events=events, token=token, get_token=get_token)
207
+ return Client(
208
+ address,
209
+ events=events,
210
+ token=token,
211
+ get_token=get_token,
212
+ headers=user_agent_headers(),
213
+ )
206
214
 
207
215
 
208
216
  class ProjectAwareSubscriptions(UserDict[str, _SubscriptionT]):
@@ -21,6 +21,12 @@ from urllib.parse import quote
21
21
 
22
22
  from typing_extensions import TypeIs
23
23
 
24
+ from ._path_segments import (
25
+ SEGMENT_RULE,
26
+ STORAGE_PATH_SEGMENTS,
27
+ bucket_relative_path,
28
+ invalid_storage_path,
29
+ )
24
30
  from .models import (
25
31
  JSONValue,
26
32
  StorageObject,
@@ -43,7 +49,7 @@ _INVALID_STORAGE_VISIBILITY = "is_public must be a boolean"
43
49
 
44
50
  _INVALID_STORAGE_ANON_KEY = "Anon key must contain a project ID"
45
51
 
46
- _INVALID_PUBLIC_URL_PATH = "Public URL paths cannot contain dot segments"
52
+ _STORAGE_PATHS_SEGMENTS = f"Storage paths {SEGMENT_RULE}"
47
53
 
48
54
  _JWT_PART_COUNT = 3
49
55
 
@@ -273,7 +279,10 @@ def storage_paths(paths: object) -> tuple[str, ...]:
273
279
  not isinstance(path, str) or not path for path in raw_paths
274
280
  ):
275
281
  raise ValueError(_INVALID_STORAGE_PATHS)
276
- return cast("tuple[str, ...]", raw_paths)
282
+ checked = cast("tuple[str, ...]", raw_paths)
283
+ if any(invalid_storage_path(path) for path in checked):
284
+ raise ValueError(_STORAGE_PATHS_SEGMENTS)
285
+ return checked
277
286
 
278
287
 
279
288
  def storage_path(path: object) -> str:
@@ -281,6 +290,8 @@ def storage_path(path: object) -> str:
281
290
  raise TypeError(_INVALID_STORAGE_PATH)
282
291
  if not path:
283
292
  raise ValueError(_INVALID_STORAGE_PATH)
293
+ if invalid_storage_path(path):
294
+ raise ValueError(STORAGE_PATH_SEGMENTS)
284
295
  return path
285
296
 
286
297
 
@@ -309,14 +320,11 @@ def project_id_from_anon_key(anon_key: str) -> str:
309
320
 
310
321
 
311
322
  def encoded_storage_path(path: str) -> str:
312
- segments = path.split("/")
313
- if any(segment in {".", ".."} for segment in segments):
314
- raise ValueError(_INVALID_PUBLIC_URL_PATH)
315
- return "/".join(quote(segment) for segment in segments)
323
+ return quote(bucket_relative_path(path))
316
324
 
317
325
 
318
326
  def encoded_storage_component(value: str) -> str:
319
- return quote(value).replace("/", "%2F")
327
+ return quote(value)
320
328
 
321
329
 
322
330
  def has_seekable_methods(source: BinaryReader) -> TypeIs[SeekableBinaryReader]:
@@ -2,10 +2,44 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import final
6
+
5
7
  import httpx
8
+ from typing_extensions import override
6
9
 
7
10
  from ._generated.client import AuthenticatedClient, Client
11
+ from ._path_segments import check_request_path
8
12
  from ._transport_types import URL_TRAILING_SLASHES
13
+ from ._user_agent import user_agent_headers
14
+
15
+
16
+ def _checked_route(url: httpx.URL | str) -> httpx.URL | str:
17
+ """Check a relative route before httpx joins it to the API URL.
18
+
19
+ httpx resolves dot segments while joining, after which a route that left
20
+ its operation looks like any other, so the check has to see the route
21
+ exactly as the generated operation built it. An absolute URL, such as a
22
+ resolved function endpoint, is not joined.
23
+
24
+ Returns:
25
+ The unchanged URL.
26
+
27
+ """
28
+ if isinstance(url, str) and url.startswith("/"):
29
+ _ = check_request_path(url)
30
+ return url
31
+
32
+
33
+ class _RouteCheckingClient(httpx.Client):
34
+ @override
35
+ def _merge_url(self, url: httpx.URL | str) -> httpx.URL:
36
+ return super()._merge_url(_checked_route(url))
37
+
38
+
39
+ class _RouteCheckingAsyncClient(httpx.AsyncClient):
40
+ @override
41
+ def _merge_url(self, url: httpx.URL | str) -> httpx.URL:
42
+ return super()._merge_url(_checked_route(url))
9
43
 
10
44
 
11
45
  class TransportBase:
@@ -22,19 +56,95 @@ class TransportBase:
22
56
  self._timeout: float = timeout
23
57
  self._httpx_transport: httpx.BaseTransport | None = httpx_transport
24
58
 
25
- def _client(self, authorization: str) -> AuthenticatedClient:
26
- httpx_args: dict[str, object] = {}
27
- if self._httpx_transport is not None:
28
- httpx_args["transport"] = self._httpx_transport
29
- return AuthenticatedClient(
59
+ def _client(
60
+ self, authorization: str, *, timeout: float | None = None
61
+ ) -> AuthenticatedClient:
62
+ client = _CheckedAuthenticatedClient(
30
63
  base_url=self._api_url,
31
64
  token=authorization,
32
- timeout=httpx.Timeout(self._timeout),
33
- httpx_args=httpx_args,
65
+ headers=user_agent_headers(),
66
+ timeout=self._limits(timeout),
34
67
  )
68
+ client.route_transport = self._httpx_transport
69
+ return client
35
70
 
36
- def _public_client(self) -> Client:
37
- return Client(
71
+ def _public_client(self, *, timeout: float | None = None) -> Client:
72
+ client = _CheckedClient(
38
73
  base_url=self._api_url,
39
- httpx_args={"transport": self._httpx_transport},
74
+ headers=user_agent_headers(),
75
+ timeout=self._limits(timeout),
40
76
  )
77
+ client.route_transport = self._httpx_transport
78
+ return client
79
+
80
+ def _limits(self, timeout: float | None) -> httpx.Timeout:
81
+ return httpx.Timeout(self._timeout if timeout is None else timeout)
82
+
83
+
84
+ # The generated clients build a plain httpx client for whichever side a call
85
+ # enters. These build the route-checking client instead, still only for the
86
+ # side that is used.
87
+ @final
88
+ class _CheckedClient(Client):
89
+ route_transport: httpx.BaseTransport | None = None
90
+
91
+ @override
92
+ def get_httpx_client(self) -> httpx.Client:
93
+ if self._client is None:
94
+ self._client = _RouteCheckingClient(
95
+ base_url=self._base_url,
96
+ headers=self._headers,
97
+ timeout=self._timeout,
98
+ transport=self.route_transport,
99
+ )
100
+ return self._client
101
+
102
+ @override
103
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
104
+ if self._async_client is None:
105
+ self._async_client = _RouteCheckingAsyncClient(
106
+ base_url=self._base_url,
107
+ headers=self._headers,
108
+ timeout=self._timeout,
109
+ transport=_async_side(self.route_transport),
110
+ )
111
+ return self._async_client
112
+
113
+
114
+ @final
115
+ class _CheckedAuthenticatedClient(AuthenticatedClient):
116
+ route_transport: httpx.BaseTransport | None = None
117
+
118
+ @override
119
+ def get_httpx_client(self) -> httpx.Client:
120
+ if self._client is None:
121
+ self._client = _RouteCheckingClient(
122
+ base_url=self._base_url,
123
+ headers=self._credentialed_headers(),
124
+ timeout=self._timeout,
125
+ transport=self.route_transport,
126
+ )
127
+ return self._client
128
+
129
+ @override
130
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
131
+ if self._async_client is None:
132
+ self._async_client = _RouteCheckingAsyncClient(
133
+ base_url=self._base_url,
134
+ headers=self._credentialed_headers(),
135
+ timeout=self._timeout,
136
+ transport=_async_side(self.route_transport),
137
+ )
138
+ return self._async_client
139
+
140
+ def _credentialed_headers(self) -> dict[str, str]:
141
+ return {**self._headers, self.auth_header_name: f"{self.prefix} {self.token}"}
142
+
143
+
144
+ def _async_side(
145
+ transport: httpx.BaseTransport | None,
146
+ ) -> httpx.AsyncBaseTransport | None:
147
+ # A mock can serve both directions; a plain synchronous transport has no
148
+ # asynchronous side to reuse.
149
+ side: object = transport
150
+ return side if isinstance(side, httpx.AsyncBaseTransport) else None
@@ -33,6 +33,7 @@ from ._generated.models.database_delete_request import DatabaseDeleteRequest
33
33
  from ._generated.models.database_insert_request import DatabaseInsertRequest
34
34
  from ._generated.models.database_select_request import DatabaseSelectRequest
35
35
  from ._generated.models.database_update_request import DatabaseUpdateRequest
36
+ from ._path_segments import database_name as checked_database
36
37
  from ._transport_base import TransportBase
37
38
  from ._transport_response import (
38
39
  generated_request,
@@ -59,7 +60,7 @@ class DatabaseTransport(TransportBase):
59
60
  response = generated_request(
60
61
  client,
61
62
  database_select_kwargs(
62
- database_name,
63
+ checked_database(database_name),
63
64
  body=DatabaseSelectRequest.from_dict(body),
64
65
  ),
65
66
  )
@@ -77,7 +78,7 @@ class DatabaseTransport(TransportBase):
77
78
  ) -> TransportResponse:
78
79
  async with self._client(authorization) as client:
79
80
  response = await query_database_select.asyncio_detailed(
80
- database_name,
81
+ checked_database(database_name),
81
82
  client=client,
82
83
  body=DatabaseSelectRequest.from_dict(body),
83
84
  )
@@ -94,7 +95,8 @@ class DatabaseTransport(TransportBase):
94
95
  response = generated_request(
95
96
  client,
96
97
  database_insert_kwargs(
97
- database_name, body=DatabaseInsertRequest.from_dict(body)
98
+ checked_database(database_name),
99
+ body=DatabaseInsertRequest.from_dict(body),
98
100
  ),
99
101
  )
100
102
  if response.status_code == HTTP_UNAUTHORIZED:
@@ -113,7 +115,8 @@ class DatabaseTransport(TransportBase):
113
115
  response = generated_request(
114
116
  client,
115
117
  database_update_kwargs(
116
- database_name, body=DatabaseUpdateRequest.from_dict(body)
118
+ checked_database(database_name),
119
+ body=DatabaseUpdateRequest.from_dict(body),
117
120
  ),
118
121
  )
119
122
  if response.status_code == HTTP_UNAUTHORIZED:
@@ -132,7 +135,8 @@ class DatabaseTransport(TransportBase):
132
135
  response = generated_request(
133
136
  client,
134
137
  database_delete_kwargs(
135
- database_name, body=DatabaseDeleteRequest.from_dict(body)
138
+ checked_database(database_name),
139
+ body=DatabaseDeleteRequest.from_dict(body),
136
140
  ),
137
141
  )
138
142
  if response.status_code == HTTP_UNAUTHORIZED:
@@ -17,6 +17,7 @@ from ._generated.api.locks.acquire_project_lock import (
17
17
  request_kwargs as lock_acquire_kwargs,
18
18
  )
19
19
  from ._generated.models.project_lock_lease_request import ProjectLockLeaseRequest
20
+ from ._path_segments import lock_key
20
21
  from ._transport_base import TransportBase
21
22
  from ._transport_response import (
22
23
  generated_request,
@@ -43,7 +44,7 @@ class LocksTransport(TransportBase):
43
44
  ) -> TransportResponse:
44
45
  with self._client(authorization) as client:
45
46
  request_kwargs = lock_acquire_kwargs(
46
- key,
47
+ lock_key(key),
47
48
  body=ProjectLockLeaseRequest(ttl_seconds=ttl),
48
49
  x_volcano_lock_token=token,
49
50
  x_volcano_request_id=request_id or str(uuid4()),
@@ -63,7 +64,7 @@ class LocksTransport(TransportBase):
63
64
  ) -> TransportResponse:
64
65
  with self._client(authorization) as client:
65
66
  response = get_project_lock.sync_detailed(
66
- key,
67
+ lock_key(key),
67
68
  client=client,
68
69
  x_volcano_request_id=request_id or str(uuid4()),
69
70
  )
@@ -78,7 +79,7 @@ class LocksTransport(TransportBase):
78
79
  ) -> TransportResponse:
79
80
  with self._client(authorization) as client:
80
81
  response = force_release_project_lock.sync_detailed(
81
- key,
82
+ lock_key(key),
82
83
  client=client,
83
84
  x_volcano_request_id=request_id or str(uuid4()),
84
85
  )
@@ -95,7 +96,7 @@ class LocksTransport(TransportBase):
95
96
  ) -> TransportResponse:
96
97
  with self._client(authorization) as client:
97
98
  response = renew_project_lock.sync_detailed(
98
- key,
99
+ lock_key(key),
99
100
  client=client,
100
101
  body=ProjectLockLeaseRequest(ttl_seconds=ttl),
101
102
  x_volcano_lock_token=token,
@@ -113,7 +114,7 @@ class LocksTransport(TransportBase):
113
114
  ) -> TransportResponse:
114
115
  with self._client(authorization) as client:
115
116
  response = release_project_lock.sync_detailed(
116
- key,
117
+ lock_key(key),
117
118
  client=client,
118
119
  x_volcano_lock_token=token,
119
120
  x_volcano_request_id=request_id or str(uuid4()),
@@ -17,6 +17,7 @@ from ._transport_types import (
17
17
  HTTP_RATE_LIMITED,
18
18
  HTTP_SERVER_ERROR_MAX,
19
19
  HTTP_SERVER_ERROR_MIN,
20
+ HTTP_SERVICE_UNAVAILABLE,
20
21
  RETRY_AFTER_HEADER,
21
22
  GeneratedTransportResponse,
22
23
  JSONResponse,
@@ -189,7 +190,7 @@ def response_payload(response: TransportResponse, expected_status: int) -> objec
189
190
  code_value = payload.get("code")
190
191
  code = str(code_value) if code_value is not None else None
191
192
  retry_after = None
192
- if status == HTTP_RATE_LIMITED:
193
+ if status in {HTTP_RATE_LIMITED, HTTP_SERVICE_UNAVAILABLE}:
193
194
  retry_after_value = header(response.headers, RETRY_AFTER_HEADER)
194
195
  try:
195
196
  retry_after = (
@@ -9,8 +9,6 @@ from io import BytesIO
9
9
  from typing import TYPE_CHECKING, cast
10
10
  from uuid import UUID
11
11
 
12
- import httpx
13
-
14
12
  from ._generated.api.sandboxes import (
15
13
  delete_sandbox,
16
14
  deploy_sandbox,
@@ -198,15 +196,15 @@ class SandboxHTTPTransport(TransportBase):
198
196
  The status, headers, and decoded response body.
199
197
 
200
198
  """
201
- base_client = (
202
- self._public_client()
203
- if authorization is None
204
- else self._client(authorization)
205
- )
206
199
  timeout = self._timeout
207
200
  if request.timeout is not None:
208
201
  timeout = max(timeout, request.timeout)
209
- with base_client.with_timeout(httpx.Timeout(timeout)) as client:
202
+ base_client = (
203
+ self._public_client(timeout=timeout)
204
+ if authorization is None
205
+ else self._client(authorization, timeout=timeout)
206
+ )
207
+ with base_client as client:
210
208
  if request.operation == "deploy_sandbox":
211
209
  return _deploy(client, request)
212
210
  response = generated_request(
@@ -24,6 +24,8 @@ from ._generated.models.upload_storage_object_files_body import (
24
24
  UploadStorageObjectFilesBody,
25
25
  )
26
26
  from ._generated.types import UNSET, File
27
+ from ._path_segments import bucket_name as checked_bucket
28
+ from ._path_segments import object_path
27
29
  from ._transport_base import TransportBase
28
30
  from ._transport_response import (
29
31
  parsed_response,
@@ -51,7 +53,7 @@ class StorageTransport(TransportBase):
51
53
  data: bytes,
52
54
  content_type: str = "application/octet-stream",
53
55
  ) -> TransportResponse:
54
- file_name = PurePosixPath(path).name or "file"
56
+ file_name = PurePosixPath(path).name
55
57
  body = UploadStorageObjectFilesBody(
56
58
  file=File(
57
59
  payload=BytesIO(data),
@@ -61,8 +63,8 @@ class StorageTransport(TransportBase):
61
63
  )
62
64
  with self._client(authorization) as client:
63
65
  response = upload_storage_object.sync_detailed(
64
- bucket_name,
65
- path,
66
+ checked_bucket(bucket_name),
67
+ object_path(path),
66
68
  client=client,
67
69
  body=body,
68
70
  )
@@ -76,15 +78,15 @@ class StorageTransport(TransportBase):
76
78
  request: StorageUploadSessionRequest,
77
79
  ) -> TransportResponse:
78
80
  body = CreateUploadSessionRequest(
79
- object_path=request.path,
81
+ object_path=object_path(request.path),
80
82
  content_type=request.content_type,
81
83
  total_size=request.total_size,
82
84
  part_size=request.part_size if request.part_size is not None else UNSET,
83
85
  )
84
86
  with self._client(authorization) as client:
85
87
  response = upload_storage_object.sync_detailed(
86
- bucket_name,
87
- request.path,
88
+ checked_bucket(bucket_name),
89
+ object_path(request.path),
88
90
  client=client,
89
91
  body=body,
90
92
  )
@@ -99,8 +101,8 @@ class StorageTransport(TransportBase):
99
101
  ) -> TransportResponse:
100
102
  with self._client(authorization) as client:
101
103
  response = upload_part.sync_detailed(
102
- bucket_name,
103
- request.path,
104
+ checked_bucket(bucket_name),
105
+ object_path(request.path),
104
106
  client=client,
105
107
  body=File(payload=BytesIO(request.data)),
106
108
  x_upload_session=request.session_id,
@@ -117,8 +119,8 @@ class StorageTransport(TransportBase):
117
119
  ) -> TransportResponse:
118
120
  with self._client(authorization) as client:
119
121
  response = upload_storage_object.sync_detailed(
120
- bucket_name,
121
- request.path,
122
+ checked_bucket(bucket_name),
123
+ object_path(request.path),
122
124
  client=client,
123
125
  x_upload_session=request.session_id,
124
126
  x_upload_complete="true",
@@ -134,8 +136,8 @@ class StorageTransport(TransportBase):
134
136
  ) -> TransportResponse:
135
137
  with self._client(authorization) as client:
136
138
  response = download_storage_object.sync_detailed(
137
- bucket_name,
138
- request.path,
139
+ checked_bucket(bucket_name),
140
+ object_path(request.path),
139
141
  client=client,
140
142
  x_upload_session=request.session_id,
141
143
  )
@@ -150,8 +152,8 @@ class StorageTransport(TransportBase):
150
152
  ) -> TransportResponse:
151
153
  with self._client(authorization) as client:
152
154
  response = delete_storage_object.sync_detailed(
153
- bucket_name,
154
- request.path,
155
+ checked_bucket(bucket_name),
156
+ object_path(request.path),
155
157
  client=client,
156
158
  x_upload_session=request.session_id,
157
159
  )
@@ -167,8 +169,8 @@ class StorageTransport(TransportBase):
167
169
  ) -> TransportResponse:
168
170
  with self._client(authorization) as client:
169
171
  response = download_storage_object.sync_detailed(
170
- bucket_name,
171
- path,
172
+ checked_bucket(bucket_name),
173
+ object_path(path),
172
174
  client=client,
173
175
  range_=byte_range if byte_range is not None else UNSET,
174
176
  )
@@ -185,7 +187,7 @@ class StorageTransport(TransportBase):
185
187
  ) -> TransportResponse:
186
188
  with self._client(authorization) as client:
187
189
  response = list_storage_objects.sync_detailed(
188
- bucket_name,
190
+ checked_bucket(bucket_name),
189
191
  client=client,
190
192
  prefix=prefix or UNSET,
191
193
  limit=limit if limit is not None else UNSET,
@@ -202,8 +204,8 @@ class StorageTransport(TransportBase):
202
204
  ) -> TransportResponse:
203
205
  with self._client(authorization) as client:
204
206
  response = delete_storage_object.sync_detailed(
205
- bucket_name,
206
- path,
207
+ checked_bucket(bucket_name),
208
+ object_path(path),
207
209
  client=client,
208
210
  )
209
211
  return parsed_response(response)
@@ -218,9 +220,11 @@ class StorageTransport(TransportBase):
218
220
  ) -> TransportResponse:
219
221
  with self._client(authorization) as client:
220
222
  response = move_storage_object.sync_detailed(
221
- bucket_name,
223
+ checked_bucket(bucket_name),
222
224
  client=client,
223
- body=StorageMoveRequest(from_=from_path, to=to_path),
225
+ body=StorageMoveRequest(
226
+ from_=object_path(from_path), to=object_path(to_path)
227
+ ),
224
228
  )
225
229
  return parsed_response(response)
226
230
 
@@ -234,9 +238,11 @@ class StorageTransport(TransportBase):
234
238
  ) -> TransportResponse:
235
239
  with self._client(authorization) as client:
236
240
  response = copy_storage_object.sync_detailed(
237
- bucket_name,
241
+ checked_bucket(bucket_name),
238
242
  client=client,
239
- body=StorageCopyRequest(from_=from_path, to=to_path),
243
+ body=StorageCopyRequest(
244
+ from_=object_path(from_path), to=object_path(to_path)
245
+ ),
240
246
  )
241
247
  return parsed_response(response)
242
248
 
@@ -250,8 +256,8 @@ class StorageTransport(TransportBase):
250
256
  ) -> TransportResponse:
251
257
  with self._client(authorization) as client:
252
258
  response = update_storage_object_visibility.sync_detailed(
253
- bucket_name,
254
- path,
259
+ checked_bucket(bucket_name),
260
+ object_path(path),
255
261
  client=client,
256
262
  body=StorageVisibilityRequest(is_public=is_public),
257
263
  )
@@ -65,6 +65,7 @@ HTTP_CONFLICT = 409
65
65
 
66
66
 
67
67
  HTTP_RATE_LIMITED = 429
68
+ HTTP_SERVICE_UNAVAILABLE = 503
68
69
 
69
70
 
70
71
  HTTP_OK = 200
@@ -0,0 +1,69 @@
1
+ """The User-Agent every request sends, so Volcano can count SDK use by version."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import platform
6
+ import sys
7
+ from importlib import metadata
8
+ from typing import Final
9
+
10
+ _DISTRIBUTION = "volcano-sdk-python"
11
+ _UNKNOWN = "unknown"
12
+ _PLATFORMS = {"win32": "windows"}
13
+
14
+
15
+ def sdk_version() -> str:
16
+ """Read the installed SDK version.
17
+
18
+ Returns:
19
+ The distribution's version, or ``unknown`` when it is not installed.
20
+
21
+ """
22
+ try:
23
+ version: str | None = metadata.version(_DISTRIBUTION)
24
+ except metadata.PackageNotFoundError:
25
+ return _UNKNOWN
26
+ return version or _UNKNOWN
27
+
28
+
29
+ def build_user_agent(
30
+ *,
31
+ version: str,
32
+ implementation: str,
33
+ python_version: str,
34
+ system: str,
35
+ machine: str,
36
+ ) -> str:
37
+ """Format the SDK, its version, and its runtime as a User-Agent value.
38
+
39
+ Returns:
40
+ ``volcano-sdk-python/<version> (<implementation>/<python>; <os>/<arch>)``.
41
+
42
+ """
43
+ os_name = _PLATFORMS.get(system, system)
44
+ arch = machine.lower() or _UNKNOWN
45
+ value = (
46
+ f"{_DISTRIBUTION}/{version} "
47
+ f"({implementation}/{python_version}; {os_name}/{arch})"
48
+ )
49
+ # HTTP clients encode header values as ASCII and raise on anything else.
50
+ return "".join(char if char.isascii() else "?" for char in value)
51
+
52
+
53
+ USER_AGENT: Final = build_user_agent(
54
+ version=sdk_version(),
55
+ implementation=sys.implementation.name,
56
+ python_version=platform.python_version(),
57
+ system=sys.platform,
58
+ machine=platform.machine(),
59
+ )
60
+
61
+
62
+ def user_agent_headers() -> dict[str, str]:
63
+ """Return a fresh header mapping, since HTTP clients may add to it.
64
+
65
+ Returns:
66
+ The ``User-Agent`` header.
67
+
68
+ """
69
+ return {"User-Agent": USER_AGENT}
@@ -377,12 +377,12 @@ class DurableContext:
377
377
 
378
378
  def _branch(
379
379
  self, branch: Callable[[DurableContext], T] | ParallelBranch[T]
380
- ) -> object:
380
+ ) -> Callable[[RuntimeContext], T] | object:
381
381
  """Adapt one branch to the engine.
382
382
 
383
- The branch's own result type is not carried through: what goes to the
384
- engine is an untyped callable either way, and `parallel` keeps the
385
- type on its own signature.
383
+ What goes to the engine is an untyped callable or named branch either
384
+ way. The return type still names the branch's result type so that type
385
+ checkers can solve the engine batch type for `parallel`.
386
386
 
387
387
  Returns:
388
388
  A named engine branch or a callable that wraps the engine context.
volcano_sdk/realtime.py CHANGED
@@ -8,6 +8,7 @@ import volcano_sdk._realtime_messages as _messages
8
8
  import volcano_sdk._realtime_transport as _native
9
9
 
10
10
  from ._client_context import ClientContextSource, facade_context
11
+ from ._path_segments import database_name
11
12
  from ._realtime_connection import RealtimeState
12
13
 
13
14
  if TYPE_CHECKING:
@@ -188,7 +189,7 @@ class Realtime:
188
189
 
189
190
  def set_database_name(self, name: str | None) -> None:
190
191
  """Bind lightweight Postgres changes to a project database."""
191
- self._state.set_database_name(name)
192
+ self._state.set_database_name(None if name is None else database_name(name))
192
193
 
193
194
  def on_connect(
194
195
  self, callback: Callable[[RealtimeConnectContext], object]
volcano_sdk/storage.py CHANGED
@@ -11,6 +11,7 @@ from typing import (
11
11
  )
12
12
 
13
13
  from ._client_context import ClientContextSource, facade_context
14
+ from ._path_segments import bucket_name, path_identifier
14
15
  from ._storage_values import (
15
16
  BinaryReader,
16
17
  SeekableBinaryReader,
@@ -277,6 +278,9 @@ class StorageBucket:
277
278
  _client: StorageContext | ClientContextSource
278
279
  _name: str
279
280
 
281
+ def _bucket_name(self) -> str:
282
+ return bucket_name(self._name)
283
+
280
284
  def upload(
281
285
  self,
282
286
  path: str,
@@ -294,6 +298,8 @@ class StorageBucket:
294
298
 
295
299
  """
296
300
  client = facade_context(self._client)
301
+ path = storage_path(path)
302
+ bucket = self._bucket_name()
297
303
  mime_type = upload_content_type(content_type)
298
304
  binding = client.capture_session_binding()
299
305
  _ = client.session_token()
@@ -302,7 +308,7 @@ class StorageBucket:
302
308
  lambda token: invoke(
303
309
  client.transport().upload_storage_object,
304
310
  authorization=token,
305
- bucket_name=self._name,
311
+ bucket_name=bucket,
306
312
  path=path,
307
313
  data=content,
308
314
  content_type=mime_type,
@@ -322,11 +328,13 @@ class StorageBucket:
322
328
 
323
329
  """
324
330
  client = facade_context(self._client)
331
+ path = storage_path(path)
332
+ bucket = self._bucket_name()
325
333
  response = client.auth().request(
326
334
  lambda token: invoke(
327
335
  client.transport().download_storage_object,
328
336
  authorization=token,
329
- bucket_name=self._name,
337
+ bucket_name=bucket,
330
338
  path=path,
331
339
  byte_range=byte_range,
332
340
  )
@@ -364,7 +372,7 @@ class StorageBucket:
364
372
  lambda token: invoke(
365
373
  transport.create_upload_session,
366
374
  authorization=token,
367
- bucket_name=self._name,
375
+ bucket_name=self._bucket_name(),
368
376
  request=StorageUploadSessionRequest(
369
377
  path=storage_path(path),
370
378
  content_type=content_type,
@@ -400,7 +408,7 @@ class StorageBucket:
400
408
  lambda token: invoke(
401
409
  transport.upload_part,
402
410
  authorization=token,
403
- bucket_name=self._name,
411
+ bucket_name=self._bucket_name(),
404
412
  request=StorageUploadPartRequest(
405
413
  path=storage_path(path),
406
414
  session_id=session_id,
@@ -434,7 +442,7 @@ class StorageBucket:
434
442
  lambda token: invoke(
435
443
  transport.complete_upload_session,
436
444
  authorization=token,
437
- bucket_name=self._name,
445
+ bucket_name=self._bucket_name(),
438
446
  request=StorageUploadSessionReference(
439
447
  path=storage_path(path),
440
448
  session_id=session_id,
@@ -467,7 +475,7 @@ class StorageBucket:
467
475
  lambda token: invoke(
468
476
  transport.get_upload_session,
469
477
  authorization=token,
470
- bucket_name=self._name,
478
+ bucket_name=self._bucket_name(),
471
479
  request=StorageUploadSessionReference(
472
480
  path=storage_path(path),
473
481
  session_id=session_id,
@@ -496,7 +504,7 @@ class StorageBucket:
496
504
  lambda token: invoke(
497
505
  transport.abort_upload_session,
498
506
  authorization=token,
499
- bucket_name=self._name,
507
+ bucket_name=self._bucket_name(),
500
508
  request=StorageUploadSessionReference(
501
509
  path=storage_path(path),
502
510
  session_id=session_id,
@@ -592,7 +600,7 @@ class StorageBucket:
592
600
  lambda token: invoke(
593
601
  transport.list_storage_objects,
594
602
  authorization=token,
595
- bucket_name=self._name,
603
+ bucket_name=self._bucket_name(),
596
604
  prefix=prefix,
597
605
  limit=limit,
598
606
  cursor=cursor,
@@ -625,8 +633,8 @@ class StorageBucket:
625
633
  lambda token: invoke(
626
634
  transport.delete_storage_object,
627
635
  authorization=token,
628
- bucket_name=self._name,
629
- path=path,
636
+ bucket_name=self._bucket_name(),
637
+ path=storage_path(path),
630
638
  ),
631
639
  binding=binding,
632
640
  )
@@ -651,7 +659,7 @@ class StorageBucket:
651
659
  lambda token: invoke(
652
660
  transport.move_storage_object,
653
661
  authorization=token,
654
- bucket_name=self._name,
662
+ bucket_name=self._bucket_name(),
655
663
  from_path=source,
656
664
  to_path=destination,
657
665
  )
@@ -677,7 +685,7 @@ class StorageBucket:
677
685
  lambda token: invoke(
678
686
  transport.copy_storage_object,
679
687
  authorization=token,
680
- bucket_name=self._name,
688
+ bucket_name=self._bucket_name(),
681
689
  from_path=source,
682
690
  to_path=destination,
683
691
  )
@@ -704,7 +712,7 @@ class StorageBucket:
704
712
  lambda token: invoke(
705
713
  transport.update_storage_object_visibility,
706
714
  authorization=token,
707
- bucket_name=self._name,
715
+ bucket_name=self._bucket_name(),
708
716
  path=object_path,
709
717
  is_public=visibility,
710
718
  )
@@ -720,11 +728,13 @@ class StorageBucket:
720
728
  """
721
729
  client = facade_context(self._client)
722
730
  object_path = storage_path(path)
723
- project_id = project_id_from_anon_key(client.anon_token())
731
+ project_id = path_identifier(
732
+ project_id_from_anon_key(client.anon_token()), "Project ID in anon key"
733
+ )
724
734
  return (
725
735
  f"{client.api_base_url()}/public/"
726
736
  f"{encoded_storage_component(project_id)}/"
727
- f"{encoded_storage_component(self._name)}/"
737
+ f"{encoded_storage_component(self._bucket_name())}/"
728
738
  f"{encoded_storage_path(object_path)}"
729
739
  )
730
740
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: volcano-sdk-python
3
- Version: 0.16.0
3
+ Version: 0.17.1
4
4
  Summary: Official Python SDK for Volcano
5
5
  Project-URL: Homepage, https://volcano.dev
6
6
  Project-URL: Repository, https://github.com/Kong/volcano-sdk-python
@@ -28,10 +28,10 @@ Description-Content-Type: text/markdown
28
28
  Use the Volcano Python SDK to access authentication, databases, storage,
29
29
  functions, locks, logs, and realtime events. Requires Python 3.11 or later.
30
30
 
31
- Start with the [Python quickstart](https://github.com/Kong/volcano-sdk-python/blob/main/docs/README.md).
32
- See the [functions guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/functions.md) for invocation identity and response handling.
31
+ Start with the [Python quickstart](https://docs.volcano.dev/sdk/python).
32
+ See the [functions guide](https://docs.volcano.dev/sdk/python/functions) for invocation identity and response handling.
33
33
 
34
- See [Authentication](https://github.com/Kong/volcano-sdk-python/blob/main/docs/authentication.md) for account, session, email, and OAuth workflows.
34
+ See [Authentication](https://docs.volcano.dev/sdk/python/authentication) for account, session, email, and OAuth workflows.
35
35
 
36
36
  ## Install
37
37
 
@@ -224,7 +224,7 @@ Acquisition accepts caller-owned UUID `token` and `request_id` values and retrie
224
224
  an ambiguous transport failure or HTTP 503 once with the same request and credential.
225
225
  Retain those IDs to recover an uncertain acquisition. Other lock methods accept
226
226
  `request_id`; block-scoped helpers forward initial IDs only to acquisition.
227
- See the [lock guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/locks.md)
227
+ See the [lock guide](https://docs.volcano.dev/sdk/python/locks)
228
228
  for examples and fencing requirements.
229
229
 
230
230
  `locks.get()` returns immutable lock availability, expiry, and fencing-token
@@ -307,7 +307,7 @@ Repeating the same decision returns the approval unchanged; a conflicting one, o
307
307
  deciding an approval that expired or whose execution ended, raises
308
308
  `ConflictError` with `code` set to `approval_decided`, `approval_expired`, or
309
309
  `approval_cancelled`. See the
310
- [functions guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/functions.md#decide-approvals-from-a-backend).
310
+ [functions guide](https://docs.volcano.dev/sdk/python/functions#decide-approvals-from-a-backend).
311
311
 
312
312
  `durable.messages` sends messages to a running execution, lists its messages,
313
313
  and follows what it publishes. It takes the credential `durable.start()` takes;
@@ -341,7 +341,7 @@ visible to the session, leaves the channel and is reported once to the event
341
341
  loop's exception handler. A send to an execution that has ended raises
342
342
  `ConflictError` with `code` set to `execution_not_running`. Pass `project_id` to
343
343
  use the owner's project route instead. See the
344
- [functions guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/functions.md#send-and-follow-messages).
344
+ [functions guide](https://docs.volcano.dev/sdk/python/functions#send-and-follow-messages).
345
345
 
346
346
  ## Write a durable function
347
347
 
@@ -478,14 +478,14 @@ sets `VOLCANO_PLATFORM_API_URL` on durable functions; without it the call raises
478
478
  `RuntimeError`. The function retries registering the approval for up to 30
479
479
  seconds. If Volcano refuses it, the call raises the durable runtime's
480
480
  `CallbackSubmitterError` with the SDK error's message. See the
481
- [functions guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/functions.md#wait-for-an-approval).
481
+ [functions guide](https://docs.volcano.dev/sdk/python/functions#wait-for-an-approval).
482
482
 
483
483
  `logs.search()` returns an immutable page of retained runtime or deployment log
484
484
  events. Pass `next_cursor` back as `cursor` to continue a search. `logs.activity()`
485
485
  returns immutable time buckets using the same resource selector and query syntax.
486
486
  Both methods require a platform user token or a project access token.
487
487
  A `read_only` project token is sufficient; end-user sessions cannot read project logs.
488
- See the [logs guide](https://github.com/Kong/volcano-sdk-python/blob/main/docs/logs.md).
488
+ See the [logs guide](https://docs.volcano.dev/sdk/python/logs).
489
489
 
490
490
  Database selects, inserts, updates, deletes, log reads, and authenticated storage
491
491
  requests (including upload sessions and parts) refresh the captured
@@ -870,7 +870,7 @@ Without a refresh token, `refresh_session()` raises `AuthenticationError` and
870
870
  `sign_out()` clears local state and revokes the server session when the access JWT
871
871
  contains a readable UUID `session_id`.
872
872
  Supplied credentials require both a refresh token and an access JWT with a readable UUID
873
- `session_id` to enable refresh. See the [token bootstrap example](https://github.com/Kong/volcano-sdk-python/blob/main/docs/README.md#use-a-supplied-access-token).
873
+ `session_id` to enable refresh. See the [token bootstrap example](https://docs.volcano.dev/sdk/python#use-a-supplied-access-token).
874
874
 
875
875
  Copy a complete native session into another client's memory:
876
876
 
@@ -2,16 +2,16 @@ volcano_sdk/__init__.py,sha256=M7qYgOwT8N2jYcu9kBvJOUwV6BHdXyGZ66Z4_D_5-3M,4444
2
2
  volcano_sdk/_auth_base.py,sha256=qAiPTs3jtdrWHSyAP9RWJEwvr4-s4Nkrtu7G7NNkqfk,1392
3
3
  volcano_sdk/_auth_context.py,sha256=9rqdvnMXFOh2qikdv9FmvFKfIHbYB7Yp0w8mkwRwGyY,2533
4
4
  volcano_sdk/_auth_email.py,sha256=V3yf_By68XwUgWrVv-0crXAtb18Sm2LvW6ZZo6RdwOc,6520
5
- volcano_sdk/_auth_oauth.py,sha256=rBX1Ud8H2FlcVd7hNjc8hdRb59fGppPWev95ZRIgUHE,12771
5
+ volcano_sdk/_auth_oauth.py,sha256=jcrJO7WzujQW4mx-ZodHpvok8ksLHikjLPfeTZYW9hM,12821
6
6
  volcano_sdk/_auth_requests.py,sha256=AmsWh8SX0Yo3BP4P6U2VI-Z3cZyZHL05BK5omm-TVwA,11008
7
- volcano_sdk/_auth_values.py,sha256=K4aGPZdrrhMh-BU_UYw4gM-WqudqAJo46I1cjWNkChE,15217
7
+ volcano_sdk/_auth_values.py,sha256=NHP7hXEOEngnQbGMYoDyCF__D6c03cj5mG1vosLULcI,15192
8
8
  volcano_sdk/_callbacks.py,sha256=rtojhO527qfcITwafzRsM4FbRGxce8tjIsJ8MhLCB50,1505
9
9
  volcano_sdk/_client_context.py,sha256=t5EbEH1WoD6Lu0fLS7aZKMeVA40tOzgbdJG3WwsCQCU,3198
10
10
  volcano_sdk/_client_session.py,sha256=RD-XDzy9e7Kv7wV1LiqmfiX5f51DIsSpaNGoAiSiE3Y,1893
11
11
  volcano_sdk/_database_response.py,sha256=GNpsqlvauZlToLNcslp04_74z-pKoE07Dd0yFOlE_i0,1206
12
12
  volcano_sdk/_durable_approval_registration.py,sha256=NbdZ_0mU-f1U1VG4ZeVOEMRKvFSy-XwXPLpjo6fzBts,5632
13
13
  volcano_sdk/_durable_approval_response.py,sha256=h6a3lLmgYYDQ9RdPaiXDyxrmtAbDO8H1sQNSo2C4p2M,9198
14
- volcano_sdk/_durable_arguments.py,sha256=ZwDssNbQrqRXQuBSI9rUSMdnvvPQ5mVZHczBHaqV18c,2205
14
+ volcano_sdk/_durable_arguments.py,sha256=2Gd-Kw2HDgJKZaNuLyTkVQxCeESkbLICdHgrkE-uqa0,2521
15
15
  volcano_sdk/_durable_callback.py,sha256=FGkG3sZFEWtrFVFYY5Rbl3Izt9kIKJr4j6wlcWoSXX0,3625
16
16
  volcano_sdk/_durable_callback_token.py,sha256=vuw1G3zNVkYiyDXob3klwxsNnPZ5HvUJ-vkZG2Q9Ghc,7326
17
17
  volcano_sdk/_durable_duration.py,sha256=0oRAR9wABTazIi1AwejHvNFCwIDnbP9z_fkDhlzy4ww,5098
@@ -22,7 +22,7 @@ volcano_sdk/_durable_message_stream.py,sha256=vwWoH7HoLZN0KyYHMBsCQi5OyDSbfk6dtq
22
22
  volcano_sdk/_durable_messages.py,sha256=pWHTxFk2nnZH8xWBLu2tTfXQklDN3AMcJ7Kz9PF2DLY,18175
23
23
  volcano_sdk/_durable_modules.py,sha256=6k2Rndr7wgbxlB6Uo3JIdYq65fAlQoBSbXzCbrs8HO4,6029
24
24
  volcano_sdk/_durable_options.py,sha256=RwZ3yrPQKgol44WHrSAu4s5qQcrgQER1z2E1zXtxER4,2913
25
- volcano_sdk/_durable_platform_request.py,sha256=_3Tag-pYaQiI5O8IxFVEIS9egzuyJPzRHyx5JMvvXiw,8275
25
+ volcano_sdk/_durable_platform_request.py,sha256=XokN3V8QBpxiaBwOGMc7NXHzuggydCyAkIfnnJf_jcY,8482
26
26
  volcano_sdk/_durable_protocols.py,sha256=u70iYJOUuuH5yN4slFZ5TOqMLGMJA5dg6RFMw-NpnHs,4320
27
27
  volcano_sdk/_durable_response.py,sha256=CO4cd58bCSMSLXT951nPyT6lcQNQsuwO2MQdksJT_1o,7382
28
28
  volcano_sdk/_durable_results.py,sha256=AyXDsEp50K6h9Nnh6MaSXP9VlrpLdudP2Ql19L0fTlM,6045
@@ -30,11 +30,12 @@ volcano_sdk/_function_requests.py,sha256=MIevztQr2caPwpM45rgaDbRfDyzsy0LcoHhOH1b
30
30
  volcano_sdk/_function_resolution.py,sha256=HgtqUMG2yTqS0l5PCP8opBuwcMIok6RadhtF-wpxsuU,6060
31
31
  volcano_sdk/_function_values.py,sha256=LmaMMutAiDCaGigqHaFV8x0NnQyJsay_BtcN8qLD0tA,6225
32
32
  volcano_sdk/_json_values.py,sha256=B1Wqj6YCX6PZEyxIr8eQVxVJJRrbYBGWWjpBEyG1LpA,802
33
- volcano_sdk/_lock_guard.py,sha256=ZnHMshczxEkHqbEg2-AARjzJjqUpONAm7yTpjGLplfM,6491
33
+ volcano_sdk/_lock_guard.py,sha256=izoN27FNtt3NEPzhGz10s-EksorQDtadJrA4zq6-NVU,6767
34
34
  volcano_sdk/_lock_renewer.py,sha256=1MoshNBlJU4_x0ELKw8bhNuOiyStD8O_rSGyhrczWqY,998
35
35
  volcano_sdk/_lock_values.py,sha256=LLZpabgjbshe1G_HqnEeCo_7JHQA0cgGHm710sP9a70,1902
36
36
  volcano_sdk/_lock_worker.py,sha256=IJ0TAFyKiLhS40j0LGLUcOnIrdaqCY3_ZVgETtXp0bc,3139
37
37
  volcano_sdk/_log_response.py,sha256=V97kht7HK5R_Avr8_8i0pzjWpYyOXufbLuJvQMSbgjE,3902
38
+ volcano_sdk/_path_segments.py,sha256=59AtNMm0veTnKHqptIR0LNyP9zjx4BP73fyYdrUSrh8,4664
38
39
  volcano_sdk/_realtime_callbacks.py,sha256=ZURrtIPxpIK2emSmhRc6tRTERnmirbcv_imWnHkmkYo,2642
39
40
  volcano_sdk/_realtime_channel.py,sha256=1s5L6FMKplSak7zrVOlLcEc4UwmMZ7EhUQTNQOKNs_M,25731
40
41
  volcano_sdk/_realtime_connection.py,sha256=vHC27WRT0uoO_RITDHkHrtGoqqGr24FlvulPKMJVccw,24921
@@ -42,43 +43,44 @@ volcano_sdk/_realtime_durable.py,sha256=subp_kJaIMS6ZIv5bR5JwBHcPb58FGds2IBfh07h
42
43
  volcano_sdk/_realtime_fetch_worker.py,sha256=pyICch33uZ3kkNI3J7EZk2Eu9DqINCULr2-RiWEsm4w,10580
43
44
  volcano_sdk/_realtime_messages.py,sha256=a5tOZIXPyHtqtlPg9OpkqHJFUmntjyXmF31cYO2Et7M,11175
44
45
  volcano_sdk/_realtime_presence.py,sha256=gh3LxgWdKMFBAxv_EZ0ROP9R2gaYFvhBtN7tVrKD_2w,7187
45
- volcano_sdk/_realtime_transport.py,sha256=11mO7660uYeISk518hisWel09KBSmaxPc30YiptAitk,8332
46
+ volcano_sdk/_realtime_transport.py,sha256=1oUWCyzvZXSXkqeqIeZ7Kn5Zpg6A4pL1S1XAicdPctA,8454
46
47
  volcano_sdk/_sandbox.py,sha256=8enKWQ5dgil2xY8ssd4yzSHQiXLGTOgoJJTDBg6g62U,7794
47
48
  volcano_sdk/_session.py,sha256=FiZD11mtOtXSL68WMQQOirxKLRmWk4NIh25zvJxRqek,3124
48
49
  volcano_sdk/_session_operations.py,sha256=dS4seAcD-HNYNs2zOXTk66qA9HliqhXyQwEz91nhY-4,6446
49
- volcano_sdk/_storage_values.py,sha256=z83LNNUu_wpbbv-aLyPtknG1R78j9TGBqDJPKaGJaT4,13366
50
+ volcano_sdk/_storage_values.py,sha256=05nEpoPqbPIjmAB5krrRrf-sOvuF9OzQjZOHZ662A3s,13517
50
51
  volcano_sdk/_transport.py,sha256=jG10VrvTDYWFOgKxBXp7ey5PJ_3cV9nZWbQt4HmhPKc,4002
51
52
  volcano_sdk/_transport_auth_account.py,sha256=RbbJ8oVKEo30Ku7BmVKuYcSstBTgTHym_E-nsO76v6s,11873
52
53
  volcano_sdk/_transport_auth_identity.py,sha256=hgElWxL6ES-b4dO9_XY61zgAkCXoCsjNU4or62GACjE,13427
53
- volcano_sdk/_transport_base.py,sha256=vcb-OIjfNTxvGDYpOzzevtlGYhzv0kQWWNYKz9dm2mk,1250
54
- volcano_sdk/_transport_database.py,sha256=63TKUF6ucuzO42yfZFiGdaCqmD4ojex2q2aZJPlSLl8,4990
54
+ volcano_sdk/_transport_base.py,sha256=hyovx9ULZxa1gwzE_sc1PVmZZSnorArUZmHeXUbXa7s,4976
55
+ volcano_sdk/_transport_database.py,sha256=6UM6O4hkJmnwuJfMrpeafb3cAl6ydBWk5C2P6F3FY3c,5205
55
56
  volcano_sdk/_transport_durable_approvals.py,sha256=11obGnRl9dpU7Rmu00bFrVVFUYnPhvTj_vx9A8e6xd8,4066
56
57
  volcano_sdk/_transport_durable_messages.py,sha256=4IfbxsbHxF1q9ns5EV6ZICTxwvVf3hU4uwr_ZtmjnX4,5556
57
58
  volcano_sdk/_transport_execution.py,sha256=Xasc0gqtjSDNcC6ZJE3Pwu52-UrLpKQ93_qeXqS1898,8122
58
- volcano_sdk/_transport_locks.py,sha256=yK2-YhR2wf2fnAJLrQCczFjjlaF1NL7Onv1JPvb243g,3709
59
- volcano_sdk/_transport_response.py,sha256=darZOtSOxgpQeWzSNPMt2pgDJepKlF23UBYkX69vUTA,7167
60
- volcano_sdk/_transport_sandbox.py,sha256=bQVA9y_yBTGnc4lMWt0_IXIR-hRuDP1PjzSm7aaCueM,9400
61
- volcano_sdk/_transport_storage.py,sha256=LNvDOtVfHiL63263Q4auKvNHRj2utepm6K0Y8fhX78Q,7958
62
- volcano_sdk/_transport_types.py,sha256=pFa603MrjXyvX8T6uJPION_hEPWwOQPgRMS7DzcC5M4,13436
59
+ volcano_sdk/_transport_locks.py,sha256=6p7ziN1xO-DNmVt6wmqkhDIbnBwcKRG5guUFeCzBYdo,3796
60
+ volcano_sdk/_transport_response.py,sha256=o6r4F0QbeotosdZ7iSgs7zLwuC7jJhEE1EHjPaPnXlI,7225
61
+ volcano_sdk/_transport_sandbox.py,sha256=SXtCmojJi8TUN0hAvcxuTm-pQFTt2mRD4x_CTkoDTrU,9381
62
+ volcano_sdk/_transport_storage.py,sha256=PjSTg39tYtmP8lGVh7G4h2cbkoCqqnS3K55QiyQ6dlU,8496
63
+ volcano_sdk/_transport_types.py,sha256=be5eVg4tNrhF-_3CLUxew--Xzp07g3ewYBgPjrDXmhI,13467
64
+ volcano_sdk/_user_agent.py,sha256=OFH1bVaQOS47rO0yGgBA2bEiNQH7nP8h6J9MhEY8Hsc,1740
63
65
  volcano_sdk/auth.py,sha256=uEkFgK2Yxc51HJVUH8FnKKiaFPtqzS1d4g3YNSqoaqo,14148
64
66
  volcano_sdk/client.py,sha256=swp4TfArtpIIEOkDGie8NgmjAL2nXyF7Pl_mkSG2fPU,15220
65
67
  volcano_sdk/connection_string.py,sha256=Mk2CJZnhvnktH1PQIygeM9aDdQIpAjlC5dSl3C9jnfU,2551
66
68
  volcano_sdk/database.py,sha256=pNwBW0K1661P6x4NeZFkx5KUG1_VoA1VVVg-jRxjOj8,13689
67
69
  volcano_sdk/durable.py,sha256=Ksrn-eGZVM_JFCGAeTvSul-G3SitfsrUrGqQ5mQ0qXg,19679
68
- volcano_sdk/durable_authoring.py,sha256=FBBAvz8YFEWBpXFGBAZHLCaD2kc55hgO-0IJc9l0oR0,26508
70
+ volcano_sdk/durable_authoring.py,sha256=Cp2770sG9rrgL4LTTlnSv7_78hGo1evUQQGXID0AJjc,26574
69
71
  volcano_sdk/errors.py,sha256=sOccwUnmgiSTs4A5GHkJR7QOAs_jlpKYtR4PTa69jp8,1907
70
72
  volcano_sdk/functions.py,sha256=TAwkAKgWHU-EYqMzB5lVBw29bsaE1_6Mb15wvvk_Kf0,9095
71
73
  volcano_sdk/locks.py,sha256=UXzEqdDmcdEHGvas5_qLwXKr3myO-BV8Ywoa_K_R-EA,10400
72
74
  volcano_sdk/logs.py,sha256=_vGg4TNtE9UZG53M7BgCxmr2zyUeQJ5ilwi1jRJ5hUk,4989
73
75
  volcano_sdk/models.py,sha256=o0cfbvBA3pbVdUIiLidKQhsB5_KB-ZwF48TKUT6QEkQ,18976
74
76
  volcano_sdk/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
75
- volcano_sdk/realtime.py,sha256=v-SYEZ-usccWfMO7m75uYAvTWW0QiemE0EJuXP20UF0,9893
77
+ volcano_sdk/realtime.py,sha256=16Wx4stygqfWFK1IFhRC3HTOETlCFA5bT9hnPknO-po,9976
76
78
  volcano_sdk/sandbox_deployment_models.py,sha256=xNnsp_H3EDTUVCULK6m--1JJ9ElXWP2GYy5DDoAOp5c,1270
77
79
  volcano_sdk/sandbox_deployments.py,sha256=pQLUtgpicF-1o8zNPFWlnOlJtBbspAcAVnszBxcMXsI,6843
78
80
  volcano_sdk/sandbox_models.py,sha256=u0uduGJFY68DyTWn75t5YeQ6EkgL_OoObsQp4SOOGBA,1998
79
81
  volcano_sdk/sandbox_session.py,sha256=u_vXvRKNzGemNRcVzyoY2ZTFaXGjHIj8U9DypMwIC2c,7046
80
82
  volcano_sdk/sandboxes.py,sha256=brzdiSpDh4O0iuetACYo9QY2ocFydhCbQVwhYg-XaEE,5150
81
- volcano_sdk/storage.py,sha256=up5v7skj-aeWafTyB9vwSlfreqWDONhZORV7Xd5k7ok,22501
83
+ volcano_sdk/storage.py,sha256=CKOGQGw5pfFFsngmu5GX1IXbTwLEjQTmw3nbDK3vDfM,22945
82
84
  volcano_sdk/_generated/__init__.py,sha256=EAb8gVU0b2MRgKKcXiVSWsnq4Zs5BFd8QbjyaFBmCRQ,156
83
85
  volcano_sdk/_generated/client.py,sha256=DHrMMBAjNo246WrkD6e8CTsC-xgljCIMj9VtSR2azYU,12309
84
86
  volcano_sdk/_generated/errors.py,sha256=trp-p5qn1_JLRxGZhdHtICaNPaCrcDCe4TgIihBravk,546
@@ -1102,7 +1104,7 @@ volcano_sdk/_generated/models/variable_status.py,sha256=THSsKBSiAYG4kAtBzGA4TZqx
1102
1104
  volcano_sdk/_generated/models/verified_domain.py,sha256=56LyikOVfJ7YNJnII_6v1OJ4tbgsbecbrqr4EkAyqLM,2032
1103
1105
  volcano_sdk/_generated/models/verified_domains_response.py,sha256=OcXUly-A_u6nJeHEDH4C6U9R0ok6zYdVIsICTYvbfXI,2239
1104
1106
  volcano_sdk/_generated/models/verify_domain_request.py,sha256=K7pVAZGeejlKGLVU-f7ugDpUlJInN09YBplcbw-MSmo,1654
1105
- volcano_sdk_python-0.16.0.dist-info/METADATA,sha256=LFQsXXvY50qTANm04cJ-UY5qtVngigbOPuqQZb5Rok8,51321
1106
- volcano_sdk_python-0.16.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
1107
- volcano_sdk_python-0.16.0.dist-info/licenses/LICENSE,sha256=AIHJy-5MFqM8fHfuGFTTb9a8rvJGypcVgN4aZ-7XTWw,11387
1108
- volcano_sdk_python-0.16.0.dist-info/RECORD,,
1107
+ volcano_sdk_python-0.17.1.dist-info/METADATA,sha256=F8xZeju6ELA2CgCAXwQGqHLtU1ZvtV36_cWn_Gmy3Ks,51082
1108
+ volcano_sdk_python-0.17.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
1109
+ volcano_sdk_python-0.17.1.dist-info/licenses/LICENSE,sha256=AIHJy-5MFqM8fHfuGFTTb9a8rvJGypcVgN4aZ-7XTWw,11387
1110
+ volcano_sdk_python-0.17.1.dist-info/RECORD,,