Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 12f7012

Browse files
committed
initial commit
1 parent 07e62cc commit 12f7012

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/streamstore/_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ async def issue_access_token(
435435
timeout=self._config.rpc.timeout,
436436
metadata=self._config.rpc.metadata,
437437
)
438-
return response.token
438+
return response.access_token
439439

440440
@fallible
441441
async def list_access_tokens(
@@ -449,15 +449,17 @@ async def list_access_tokens(
449449
start_after: Filter to access tokens whose ID lexicographically starts after this value.
450450
limit: Number of results, up to a maximum of 1000.
451451
"""
452-
request = ListAccessTokensRequest(prefix, start_after, limit)
452+
request = ListAccessTokensRequest(
453+
prefix=prefix, start_after=start_after, limit=limit
454+
)
453455
response = await self._retrier(
454456
self._stub.ListAccessTokens,
455457
request,
456458
timeout=self._config.rpc.timeout,
457459
metadata=self._config.rpc.metadata,
458460
)
459461
return schemas.Page(
460-
items=[access_token_info_schema(info) for info in response.tokens],
462+
items=[access_token_info_schema(info) for info in response.access_tokens],
461463
has_more=response.has_more,
462464
)
463465

@@ -469,7 +471,7 @@ async def revoke_access_token(self, id: str) -> schemas.AccessTokenInfo:
469471
Args:
470472
id: Access token ID.
471473
"""
472-
request = RevokeAccessTokenRequest(id)
474+
request = RevokeAccessTokenRequest(id=id)
473475
response = await self._retrier(
474476
self._stub.RevokeAccessToken,
475477
request,

src/streamstore/_mappers.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,15 @@ def stream_config_message(
132132
delete_on_empty_min_age = config.delete_on_empty_min_age
133133
if storage_class is not None:
134134
paths.append(f"{mask_path_prefix}storage_class")
135-
stream_config.storage_class = msgs.StorageClass(storage_class.value)
135+
stream_config.storage_class = storage_class.value
136136
if retention_age is not None:
137137
paths.append(f"{mask_path_prefix}retention_policy")
138138
stream_config.age = retention_age
139139
if timestamping is not None:
140140
paths.append(f"{mask_path_prefix}timestamping")
141-
stream_config.timestamping = msgs.StreamConfig.Timestamping()
142141
if timestamping.mode is not None:
143142
paths.append(f"{mask_path_prefix}timestamping.mode")
144-
stream_config.timestamping.mode = msgs.TimestampingMode(
145-
timestamping.mode.value
146-
)
143+
stream_config.timestamping.mode = timestamping.mode.value
147144
if timestamping.uncapped is not None:
148145
paths.append(f"{mask_path_prefix}timestamping.uncapped")
149146
stream_config.timestamping.uncapped = timestamping.uncapped
@@ -176,7 +173,7 @@ def basin_config_message(
176173
default_stream_config = cast(
177174
msgs.StreamConfig, stream_config_message(config.default_stream_config)
178175
)
179-
basin_config.default_stream_config = default_stream_config
176+
basin_config.default_stream_config.CopyFrom(default_stream_config)
180177
if config.create_stream_on_append is not None:
181178
basin_config.create_stream_on_append = config.create_stream_on_append
182179
paths.append("create_stream_on_append")
@@ -266,7 +263,7 @@ def permissions(perm: Permission) -> msgs.ReadWritePermissions:
266263
case Permission.READ_WRITE:
267264
read = True
268265
write = True
269-
return msgs.ReadWritePermissions(read, write)
266+
return msgs.ReadWritePermissions(read=read, write=write)
270267

271268
def permitted_op_groups(
272269
op_group_perms: OperationGroupPermissions | None,
@@ -288,13 +285,15 @@ def permitted_op_groups(
288285
streams=resource_set(scope.streams),
289286
access_tokens=resource_set(scope.access_tokens),
290287
op_groups=permitted_op_groups(scope.op_group_perms),
291-
ops=(msgs.Operation(op.value) for op in scope.ops) if scope.ops else None,
288+
ops=(op.value for op in scope.ops),
292289
),
293290
)
294291

295292

296293
def access_token_info_schema(info: msgs.AccessTokenInfo) -> AccessTokenInfo:
297-
def resource_match_rule(resource_set: msgs.ResourceSet) -> ResourceMatchRule:
294+
def resource_match_rule(resource_set: msgs.ResourceSet) -> ResourceMatchRule | None:
295+
if not resource_set.HasField("matching"):
296+
return None
298297
match resource_set.WhichOneof("matching"):
299298
case "exact":
300299
return ResourceMatchRule(ResourceMatchOp.EXACT, resource_set.exact)

src/streamstore/schemas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class TimestampingMode(DocEnum):
258258
The arrival time is always in milliseconds since Unix epoch.
259259
"""
260260

261+
UNSPECIFIED = 0, "Defaults to ``CLIENT_PREFER``."
261262
CLIENT_PREFER = (
262263
1,
263264
"Prefer client-specified timestamp if present, otherwise use arrival time.",
@@ -414,7 +415,7 @@ class AccessTokenScope:
414415
#:
415416
#: Note:
416417
#: A union of allowed operations and groups is used as the effective set of allowed operations.
417-
ops: list[Operation] | None = None
418+
ops: list[Operation] = field(default_factory=list)
418419

419420

420421
@dataclass(slots=True)

0 commit comments

Comments
 (0)