agntcy-dir 0.3.0__tar.gz
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.
- agntcy_dir-0.3.0/.gitignore +14 -0
- agntcy_dir-0.3.0/PKG-INFO +154 -0
- agntcy_dir-0.3.0/README.md +144 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/client/__init__.py +5 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/client/client.py +896 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/client/config.py +45 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/client/test_client.py +361 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/README.md +12 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/__init__.py +11 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/core_v1.py +5 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/routing_v1.py +11 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/search_v1.py +7 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/sign_v1.py +5 -0
- agntcy_dir-0.3.0/agntcy/dir_sdk/models/store_v1.py +7 -0
- agntcy_dir-0.3.0/pyproject.toml +42 -0
- agntcy_dir-0.3.0/uv.lock +494 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agntcy-dir
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Directory SDK
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: agntcy-dir-grpc-python==1.75.0.1.20250917121230+a7e88d4f0f48
|
|
7
|
+
Requires-Dist: spiffe-tls>=0.2.1
|
|
8
|
+
Requires-Dist: spiffe>=0.2.2
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Directory Python SDK
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Dir Python SDK provides a simple way to interact with the Directory API.
|
|
16
|
+
It allows developers to integrate and use Directory functionality from their Python applications with ease.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
The Directory Python SDK provides comprehensive access to all Directory APIs with a simple, intuitive interface:
|
|
21
|
+
|
|
22
|
+
### **Store API**
|
|
23
|
+
- **Record Management**: Push records to the store and pull them by reference
|
|
24
|
+
- **Metadata Operations**: Look up record metadata without downloading full content
|
|
25
|
+
- **Data Lifecycle**: Delete records permanently from the store
|
|
26
|
+
- **Referrer Support**: Push and pull artifacts for existing records
|
|
27
|
+
- **Sync Management**: Manage storage synchronization policies between Directory servers
|
|
28
|
+
|
|
29
|
+
### **Search API**
|
|
30
|
+
- **Flexible Search**: Search stored records using text, semantic, and structured queries
|
|
31
|
+
- **Advanced Filtering**: Filter results by metadata, content type, and other criteria
|
|
32
|
+
|
|
33
|
+
### **Routing API**
|
|
34
|
+
- **Network Publishing**: Publish records to make them discoverable across the network
|
|
35
|
+
- **Content Discovery**: List and query published records across the network
|
|
36
|
+
- **Network Management**: Unpublish records to remove them from network discovery
|
|
37
|
+
|
|
38
|
+
### **Signing and Verification**
|
|
39
|
+
- **Local Signing**: Sign records locally using private keys or OIDC-based authentication.
|
|
40
|
+
Requires [dirctl](https://github.com/agntcy/dir/releases) binary to perform signing.
|
|
41
|
+
- **Remote Verification**: Verify record signatures using the Directory gRPC API
|
|
42
|
+
|
|
43
|
+
### **Developer Experience**
|
|
44
|
+
- **Type Safety**: Full type hints for better IDE support and fewer runtime errors
|
|
45
|
+
- **Async Support**: Non-blocking operations with streaming responses for large datasets
|
|
46
|
+
- **Error Handling**: Comprehensive gRPC error handling with detailed error messages
|
|
47
|
+
- **Configuration**: Flexible configuration via environment variables or direct instantiation
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
Install the SDK using [uv](https://github.com/astral-sh/uv)
|
|
52
|
+
|
|
53
|
+
1. Initialize the project:
|
|
54
|
+
```bash
|
|
55
|
+
uv init
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
2. Add the SDK to your project:
|
|
59
|
+
```bash
|
|
60
|
+
uv add agntcy-dir --index https://buf.build/gen/python
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
The SDK can be configured via environment variables or direct instantiation:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# Environment variables
|
|
69
|
+
export DIRECTORY_CLIENT_SERVER_ADDRESS="localhost:8888"
|
|
70
|
+
export DIRCTL_PATH="/path/to/dirctl"
|
|
71
|
+
|
|
72
|
+
# Or configure directly
|
|
73
|
+
from agntcy.dir_sdk.client import Config, Client
|
|
74
|
+
|
|
75
|
+
config = Config(
|
|
76
|
+
server_address="localhost:8888",
|
|
77
|
+
dirctl_path="/usr/local/bin/dirctl",
|
|
78
|
+
spiffe_socket_path="/tmp/agent.sock" # Optional, used for SPIRE-based mTLS
|
|
79
|
+
)
|
|
80
|
+
client = Client(config)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Error Handling
|
|
84
|
+
|
|
85
|
+
The SDK primarily raises `grpc.RpcError` exceptions for gRPC communication issues and `RuntimeError` for configuration problems:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import grpc
|
|
89
|
+
from agntcy.dir_sdk.client import Client
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
client = Client()
|
|
93
|
+
records = client.list(list_request)
|
|
94
|
+
except grpc.RpcError as e:
|
|
95
|
+
# Handle gRPC errors
|
|
96
|
+
if e.code() == grpc.StatusCode.NOT_FOUND:
|
|
97
|
+
print("Resource not found")
|
|
98
|
+
elif e.code() == grpc.StatusCode.UNAVAILABLE:
|
|
99
|
+
print("Server unavailable")
|
|
100
|
+
else:
|
|
101
|
+
print(f"gRPC error: {e.details()}")
|
|
102
|
+
except RuntimeError as e:
|
|
103
|
+
# Handle configuration or subprocess errors
|
|
104
|
+
print(f"Runtime error: {e}")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Common gRPC status codes:
|
|
108
|
+
- `NOT_FOUND`: Resource doesn't exist
|
|
109
|
+
- `ALREADY_EXISTS`: Resource already exists
|
|
110
|
+
- `UNAVAILABLE`: Server is down or unreachable
|
|
111
|
+
- `PERMISSION_DENIED`: Authentication/authorization failure
|
|
112
|
+
- `INVALID_ARGUMENT`: Invalid request parameters
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Getting Started
|
|
116
|
+
|
|
117
|
+
### Prerequisites
|
|
118
|
+
|
|
119
|
+
- Python 3.10 or higher
|
|
120
|
+
- [uv](https://github.com/astral-sh/uv) - Package manager
|
|
121
|
+
- [dirctl](https://github.com/agntcy/dir/releases) - Directory CLI binary
|
|
122
|
+
- Directory server instance (see setup below)
|
|
123
|
+
|
|
124
|
+
### 1. Server Setup
|
|
125
|
+
|
|
126
|
+
**Option A: Local Development Server**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Clone the repository and start the server using Taskfile
|
|
130
|
+
task server:start
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Option B: Custom Server**
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Set your Directory server address
|
|
137
|
+
export DIRECTORY_CLIENT_SERVER_ADDRESS="your-server:8888"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. SDK Installation
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Add the Directory SDK
|
|
144
|
+
uv add agntcy-dir --index https://buf.build/gen/python
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Usage Examples
|
|
148
|
+
|
|
149
|
+
See the [Example Python Project](../examples/example-py/) for a complete working example that demonstrates all SDK features.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
uv sync
|
|
153
|
+
uv run example.py
|
|
154
|
+
```
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Directory Python SDK
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Dir Python SDK provides a simple way to interact with the Directory API.
|
|
6
|
+
It allows developers to integrate and use Directory functionality from their Python applications with ease.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
The Directory Python SDK provides comprehensive access to all Directory APIs with a simple, intuitive interface:
|
|
11
|
+
|
|
12
|
+
### **Store API**
|
|
13
|
+
- **Record Management**: Push records to the store and pull them by reference
|
|
14
|
+
- **Metadata Operations**: Look up record metadata without downloading full content
|
|
15
|
+
- **Data Lifecycle**: Delete records permanently from the store
|
|
16
|
+
- **Referrer Support**: Push and pull artifacts for existing records
|
|
17
|
+
- **Sync Management**: Manage storage synchronization policies between Directory servers
|
|
18
|
+
|
|
19
|
+
### **Search API**
|
|
20
|
+
- **Flexible Search**: Search stored records using text, semantic, and structured queries
|
|
21
|
+
- **Advanced Filtering**: Filter results by metadata, content type, and other criteria
|
|
22
|
+
|
|
23
|
+
### **Routing API**
|
|
24
|
+
- **Network Publishing**: Publish records to make them discoverable across the network
|
|
25
|
+
- **Content Discovery**: List and query published records across the network
|
|
26
|
+
- **Network Management**: Unpublish records to remove them from network discovery
|
|
27
|
+
|
|
28
|
+
### **Signing and Verification**
|
|
29
|
+
- **Local Signing**: Sign records locally using private keys or OIDC-based authentication.
|
|
30
|
+
Requires [dirctl](https://github.com/agntcy/dir/releases) binary to perform signing.
|
|
31
|
+
- **Remote Verification**: Verify record signatures using the Directory gRPC API
|
|
32
|
+
|
|
33
|
+
### **Developer Experience**
|
|
34
|
+
- **Type Safety**: Full type hints for better IDE support and fewer runtime errors
|
|
35
|
+
- **Async Support**: Non-blocking operations with streaming responses for large datasets
|
|
36
|
+
- **Error Handling**: Comprehensive gRPC error handling with detailed error messages
|
|
37
|
+
- **Configuration**: Flexible configuration via environment variables or direct instantiation
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
Install the SDK using [uv](https://github.com/astral-sh/uv)
|
|
42
|
+
|
|
43
|
+
1. Initialize the project:
|
|
44
|
+
```bash
|
|
45
|
+
uv init
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. Add the SDK to your project:
|
|
49
|
+
```bash
|
|
50
|
+
uv add agntcy-dir --index https://buf.build/gen/python
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
The SDK can be configured via environment variables or direct instantiation:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
# Environment variables
|
|
59
|
+
export DIRECTORY_CLIENT_SERVER_ADDRESS="localhost:8888"
|
|
60
|
+
export DIRCTL_PATH="/path/to/dirctl"
|
|
61
|
+
|
|
62
|
+
# Or configure directly
|
|
63
|
+
from agntcy.dir_sdk.client import Config, Client
|
|
64
|
+
|
|
65
|
+
config = Config(
|
|
66
|
+
server_address="localhost:8888",
|
|
67
|
+
dirctl_path="/usr/local/bin/dirctl",
|
|
68
|
+
spiffe_socket_path="/tmp/agent.sock" # Optional, used for SPIRE-based mTLS
|
|
69
|
+
)
|
|
70
|
+
client = Client(config)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Error Handling
|
|
74
|
+
|
|
75
|
+
The SDK primarily raises `grpc.RpcError` exceptions for gRPC communication issues and `RuntimeError` for configuration problems:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import grpc
|
|
79
|
+
from agntcy.dir_sdk.client import Client
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
client = Client()
|
|
83
|
+
records = client.list(list_request)
|
|
84
|
+
except grpc.RpcError as e:
|
|
85
|
+
# Handle gRPC errors
|
|
86
|
+
if e.code() == grpc.StatusCode.NOT_FOUND:
|
|
87
|
+
print("Resource not found")
|
|
88
|
+
elif e.code() == grpc.StatusCode.UNAVAILABLE:
|
|
89
|
+
print("Server unavailable")
|
|
90
|
+
else:
|
|
91
|
+
print(f"gRPC error: {e.details()}")
|
|
92
|
+
except RuntimeError as e:
|
|
93
|
+
# Handle configuration or subprocess errors
|
|
94
|
+
print(f"Runtime error: {e}")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Common gRPC status codes:
|
|
98
|
+
- `NOT_FOUND`: Resource doesn't exist
|
|
99
|
+
- `ALREADY_EXISTS`: Resource already exists
|
|
100
|
+
- `UNAVAILABLE`: Server is down or unreachable
|
|
101
|
+
- `PERMISSION_DENIED`: Authentication/authorization failure
|
|
102
|
+
- `INVALID_ARGUMENT`: Invalid request parameters
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Getting Started
|
|
106
|
+
|
|
107
|
+
### Prerequisites
|
|
108
|
+
|
|
109
|
+
- Python 3.10 or higher
|
|
110
|
+
- [uv](https://github.com/astral-sh/uv) - Package manager
|
|
111
|
+
- [dirctl](https://github.com/agntcy/dir/releases) - Directory CLI binary
|
|
112
|
+
- Directory server instance (see setup below)
|
|
113
|
+
|
|
114
|
+
### 1. Server Setup
|
|
115
|
+
|
|
116
|
+
**Option A: Local Development Server**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Clone the repository and start the server using Taskfile
|
|
120
|
+
task server:start
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Option B: Custom Server**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Set your Directory server address
|
|
127
|
+
export DIRECTORY_CLIENT_SERVER_ADDRESS="your-server:8888"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 2. SDK Installation
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Add the Directory SDK
|
|
134
|
+
uv add agntcy-dir --index https://buf.build/gen/python
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Usage Examples
|
|
138
|
+
|
|
139
|
+
See the [Example Python Project](../examples/example-py/) for a complete working example that demonstrates all SDK features.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
uv sync
|
|
143
|
+
uv run example.py
|
|
144
|
+
```
|