Skip to content

Commit 5470683

Browse files
authored
feat(py-client): Specify public API and add example to README.md (#163)
1 parent b740449 commit 5470683

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

clients/python/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
11
# Objectstore Client
22

3+
The client is used to interface with the objectstore backend. It handles
4+
responsibilities like transparent compression, and making sure that uploads and
5+
downloads are done as efficiently as possible.
6+
37
## Usage
48

5-
TODO
9+
```python
10+
import datetime
11+
12+
from objectstore_client import ClientBuilder, NoOpMetricsBackend, TimeToLive
13+
14+
client_builder = ClientBuilder(
15+
"http://localhost:8888",
16+
"my_usecase",
17+
metrics_backend=NoOpMetricsBackend(), # optionally, provide your own MetricsBackend implementation
18+
)
19+
client = client_builder.for_project(42, 424242)
20+
21+
object_id = client.put(
22+
b"Hello, world!",
23+
metadata={"key": "value"},
24+
expiration_policy=TimeToLive(datetime.timedelta(days=1)),
25+
)
26+
27+
result = client.get(object_id)
28+
29+
content = result.payload.read()
30+
assert content == b"Hello, world!"
31+
assert result.metadata.custom["key"] == "value"
32+
33+
client.delete(object_id)
34+
```
635

736
## Development
837

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from objectstore_client.client import Client, ClientBuilder, ClientError, GetResult
2+
from objectstore_client.metadata import (
3+
Compression,
4+
ExpirationPolicy,
5+
Metadata,
6+
TimeToIdle,
7+
TimeToLive,
8+
)
9+
from objectstore_client.metrics import MetricsBackend, NoOpMetricsBackend
10+
11+
__all__ = [
12+
"Client",
13+
"ClientBuilder",
14+
"ClientError",
15+
"GetResult",
16+
"Compression",
17+
"ExpirationPolicy",
18+
"Metadata",
19+
"TimeToIdle",
20+
"TimeToLive",
21+
"MetricsBackend",
22+
"NoOpMetricsBackend",
23+
]

0 commit comments

Comments
 (0)