Skip to content

Commit 799af8f

Browse files
committed
add README
1 parent b8d12cf commit 799af8f

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Octelium Python SDK
2+
3+
This is the official Python SDK for Octelium. The SDK provides authenticated access to Octelium gRPC and HTTP APIs using async Python APIs built on top of `grpclib`, `aiohttp`, and `betterproto`.
4+
5+
## Installation
6+
7+
```bash
8+
pip install octelium-sdk
9+
```
10+
11+
Or install the generated protobuf APIs separately:
12+
13+
```bash
14+
pip install octelium-apis
15+
```
16+
17+
# Basic Example
18+
19+
```python
20+
import asyncio
21+
22+
from octelium.sdk import (
23+
AuthConfig,
24+
AuthTokenConfig,
25+
OcteliumClient,
26+
OcteliumClientConfig,
27+
)
28+
29+
from octelium.api.main.core.v1 import ListNamespaceOptions
30+
31+
async def main() -> None:
32+
client = await OcteliumClient.create(
33+
OcteliumClientConfig(
34+
domain="<DOMAIN>",
35+
auth=AuthConfig(
36+
type="auth_token",
37+
auth_token=AuthTokenConfig(
38+
token="<AUTH_TOKEN>"
39+
),
40+
),
41+
)
42+
)
43+
44+
try:
45+
resp = await client.core_v1.list_namespace(
46+
ListNamespaceOptions()
47+
)
48+
49+
for namespace in resp.items:
50+
print(namespace)
51+
52+
finally:
53+
await client.close()
54+
55+
56+
asyncio.run(main())
57+
```
58+
59+
60+
## OAuth2 Client Credentials
61+
62+
```python
63+
from octelium.sdk import (
64+
AuthConfig,
65+
OAuth2ClientCredentialsConfig,
66+
OcteliumClient,
67+
OcteliumClientConfig,
68+
)
69+
70+
client = await OcteliumClient.create(
71+
OcteliumClientConfig(
72+
domain="example.com",
73+
auth=AuthConfig(
74+
type="oauth2_client_credentials",
75+
oauth2_client_credentials=OAuth2ClientCredentialsConfig(
76+
client_id="client-id",
77+
client_secret="client-secret",
78+
scopes=["core"],
79+
),
80+
),
81+
)
82+
)
83+
```
84+
85+
## Authenticated HTTP Requests
86+
87+
```python
88+
async with client.http_client() as http:
89+
resp = await http.get(
90+
"https://my-api.<DOMAIN>/v1/users"
91+
)
92+
93+
data = await resp.json()
94+
print(data)
95+
```
96+
97+
## Lazy Authentication
98+
99+
Authentication is lazy by default. The SDK only authenticates when the first authenticated request is performed.
100+
101+
To authenticate immediately during client creation:
102+
103+
```python
104+
client = await OcteliumClient.create(
105+
OcteliumClientConfig(
106+
authenticate_on_creation=True,
107+
)
108+
)
109+
```
110+
111+
## License
112+
113+
Apache License 2.0.

0 commit comments

Comments
 (0)