|
3 | 3 | The Glean Python SDK provides convenient access to the Glean REST API from any Python 3.8+ application. It includes type hints for all request parameters and response fields, and supports both synchronous and asynchronous usage via [httpx](https://www.python-httpx.org/). |
4 | 4 | <!-- No Summary [summary] --> |
5 | 5 |
|
| 6 | +## Unified SDK Architecture |
| 7 | + |
| 8 | +This SDK combines both the Client and Indexing API namespaces into a single unified package: |
| 9 | + |
| 10 | +- **Client API**: Used for search, retrieval, and end-user interactions with Glean content |
| 11 | +- **Indexing API**: Used for indexing content, permissions, and other administrative operations |
| 12 | + |
| 13 | +Each namespace has its own authentication requirements and access patterns. While they serve different purposes, having them in a single SDK provides a consistent developer experience across all Glean API interactions. |
| 14 | + |
| 15 | +```python |
| 16 | +# Example of accessing Client namespace |
| 17 | +from glean import Glean, models |
| 18 | +import os |
| 19 | + |
| 20 | +with Glean(bearer_auth="client-token") as glean: |
| 21 | + search_response = glean.client.search.query( |
| 22 | + search_request=models.SearchRequest(query="search term") |
| 23 | + ) |
| 24 | + print(search_response) |
| 25 | + |
| 26 | +# Example of accessing Indexing namespace |
| 27 | +from glean import Glean, models |
| 28 | +import os |
| 29 | + |
| 30 | +with Glean(bearer_auth="indexing-token") as glean: |
| 31 | + document_response = glean.indexing.documents.index( |
| 32 | + document=models.Document( |
| 33 | + id="doc-123", |
| 34 | + title="Sample Document", |
| 35 | + container_id="container-456", |
| 36 | + datasource="confluence" |
| 37 | + ) |
| 38 | + ) |
| 39 | +``` |
| 40 | + |
| 41 | +Remember that each namespace requires its own authentication token type as described in the [Authentication Methods](#authentication-methods) section. |
| 42 | + |
6 | 43 | <!-- Start Table of Contents [toc] --> |
7 | 44 | ## Table of Contents |
8 | 45 | <!-- $toc-max-depth=2 --> |
@@ -204,6 +241,35 @@ with Glean( |
204 | 241 | ``` |
205 | 242 | <!-- End Authentication [security] --> |
206 | 243 |
|
| 244 | +### Authentication Methods |
| 245 | + |
| 246 | +Glean supports different authentication methods depending on which API namespace you're using: |
| 247 | + |
| 248 | +#### Client Namespace |
| 249 | + |
| 250 | +The Client namespace supports two authentication methods: |
| 251 | + |
| 252 | +1. **Manually Provisioned API Tokens** |
| 253 | + - Can be created by an Admin or a user with the API Token Creator role |
| 254 | + - Used for server-to-server integrations |
| 255 | + |
| 256 | +2. **OAuth** |
| 257 | + - Requires OAuth setup to be completed by an Admin |
| 258 | + - Used for user-based authentication flows |
| 259 | + |
| 260 | +#### Indexing Namespace |
| 261 | + |
| 262 | +The Indexing namespace supports only one authentication method: |
| 263 | + |
| 264 | +1. **Manually Provisioned API Tokens** |
| 265 | + - Can be created by an Admin or a user with the API Token Creator role |
| 266 | + - Used for secure document indexing operations |
| 267 | + |
| 268 | +> [!IMPORTANT] |
| 269 | +> Client tokens **will not work** for Indexing operations, and Indexing tokens **will not work** for Client operations. You must use the appropriate token type for the namespace you're accessing. |
| 270 | +
|
| 271 | +For more information on obtaining the appropriate token type, please contact your Glean administrator. |
| 272 | + |
207 | 273 | <!-- Start Available Resources and Operations [operations] --> |
208 | 274 | ## Available Resources and Operations |
209 | 275 |
|
|
0 commit comments