Name | abs-nosql-integration-core JSON |
Version |
0.1.15
JSON |
| download |
home_page | None |
Summary | Core utilities for building OAuth-based integrations in FastAPI applications with use of NoSql db |
upload_time | 2025-07-21 17:33:34 |
maintainer | None |
docs_url | None |
author | AutoBridgeSystems |
requires_python | <4.0,>=3.13 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# NoSQL Integration Core
A comprehensive library for building OAuth-based integration services with NoSQL databases in FastAPI applications.
## Overview
NoSQL Integration Core extends the base Integration Core library to provide specialized support for NoSQL databases like MongoDB. It simplifies the process of managing OAuth tokens, API credentials, and integration state while leveraging the flexibility and scalability of NoSQL databases.
## Installation
```bash
# Using pip
pip install abs-nosql-integration-core
# Using Poetry
poetry add abs-nosql-integration-core
```
## Features
- Complete OAuth 2.0 flow management
- Secure token storage with encryption
- Automatic token refresh handling
- NoSQL database integration with Beanie ODM
- Asynchronous API with FastAPI compatibility
- Built-in MongoDB integration
## Architecture
The package follows a modular architecture:
- **Repository Layer**: Handles persistence with NoSQL databases
- **Service Layer**: Implements OAuth flows and business logic
- **Models**: Defines document models for NoSQL storage
- **Schemas**: Defines data models and validation
## Usage
### Basic Setup
```python
from abs_nosql_integration_core.service import IntegrationBaseService
from abs_nosql_integration_core.repository import IntegrationRepository
from abs_integration_core.utils.encryption import Encryption
# Create an integration service
class MyIntegrationService(IntegrationBaseService):
def __init__(
self,
provider_name: str,
integration_repository: IntegrationRepository,
encryption: Encryption
):
super().__init__(provider_name, integration_repository, encryption)
# Additional provider-specific configuration
```
### Dependency Injection Setup
```python
from dependency_injector import containers, providers
from abs_nosql_integration_core.repository import IntegrationRepository
from abs_integration_core.utils.encryption import Encryption
class Container(containers.DeclarativeContainer):
# MongoDB initialization
mongodb_client = providers.Singleton(
MongoClient,
connection_string=settings.MONGODB_CONNECTION_STRING
)
# Encryption service
encryption = providers.Singleton(
Encryption,
secret_key=settings.ENCRYPTION_KEY
)
# Repository layer
integration_repository = providers.Singleton(IntegrationRepository)
# Service layer
my_integration_service = providers.Singleton(
MyIntegrationService,
provider_name="my_provider",
integration_repository=integration_repository,
encryption=encryption
)
```
### FastAPI Integration
```python
from fastapi import Depends, FastAPI, APIRouter
from dependency_injector.wiring import inject, Provide
router = APIRouter()
@router.get("/connect")
async def connect(
service: IntegrationBaseService = Depends(get_integration_service),
):
auth_url = service.get_auth_url()
return {"auth_url": auth_url}
@router.get("/callback")
async def callback(
code: str,
service: IntegrationBaseService = Depends(get_integration_service),
):
token_data = await service.handle_oauth_callback(code)
return {"status": "connected"}
```
## Document Schema
The integration document model includes:
```python
class IntegrationDocument(BaseDraftDocument):
provider_name: str # Name of the integration provider
access_token: str # OAuth access token (encrypted)
refresh_token: str # OAuth refresh token (encrypted)
expires_at: datetime # Token expiration date
```
## Repository Methods
The `IntegrationRepository` class provides:
- `create_integration`: Create a new integration record
- `refresh_token`: Update access and refresh tokens
- `get_query_by_provider`: Find an integration by provider name
- `get_integration`: Get a single integration by provider
- `get_all_integrations`: Get all integrations
- `delete_integration`: Remove an integration
## Service Methods
The `IntegrationBaseService` class provides:
- `get_auth_url`: Generate OAuth authorization URL
- `handle_oauth_callback`: Process OAuth callback and store tokens
- `refresh_token`: Refresh expired access tokens
- `get_integration`: Get current integration details
- `delete_integration`: Remove integration and related tokens
## Exception Handling
The library uses a standard exception hierarchy:
- `NotFoundError`: Integration not found
- `BadRequestError`: Invalid request parameters
- `DuplicatedError`: Integration already exists
- `UnauthorizedError`: Authentication issues
## MongoDB Configuration
The package supports MongoDB through Beanie ODM:
```python
from beanie import init_beanie
from motor.motor_asyncio import AsyncIOMotorClient
from abs_nosql_integration_core.model import IntegrationDocument
async def init_mongodb():
# Create Motor client
client = AsyncIOMotorClient(MONGODB_URL)
# Initialize Beanie with document models
await init_beanie(
database=client.db_name,
document_models=[IntegrationDocument]
)
```
## Best Practices
- Always encrypt sensitive tokens using the provided encryption utilities
- Use dependency injection for better testability
- Implement proper error handling for OAuth edge cases
- Consider rate limiting for API calls
- Implement proper logging for debugging
- Use async context managers for database operations
## Contributing
Contributions are welcome! Please feel free to submit pull requests.
## License
This project is licensed under the MIT License.
Raw data
{
"_id": null,
"home_page": null,
"name": "abs-nosql-integration-core",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.13",
"maintainer_email": null,
"keywords": null,
"author": "AutoBridgeSystems",
"author_email": "info@autobridgesystems.com",
"download_url": "https://files.pythonhosted.org/packages/7c/50/b4736f9b2f5f1856be35630ef1f17d4fa55b21cb9af05e85b335c6f7cb2d/abs_nosql_integration_core-0.1.15.tar.gz",
"platform": null,
"description": "# NoSQL Integration Core\n\nA comprehensive library for building OAuth-based integration services with NoSQL databases in FastAPI applications.\n\n## Overview\n\nNoSQL Integration Core extends the base Integration Core library to provide specialized support for NoSQL databases like MongoDB. It simplifies the process of managing OAuth tokens, API credentials, and integration state while leveraging the flexibility and scalability of NoSQL databases.\n\n## Installation\n\n```bash\n# Using pip\npip install abs-nosql-integration-core\n\n# Using Poetry\npoetry add abs-nosql-integration-core\n```\n\n## Features\n\n- Complete OAuth 2.0 flow management\n- Secure token storage with encryption\n- Automatic token refresh handling\n- NoSQL database integration with Beanie ODM\n- Asynchronous API with FastAPI compatibility\n- Built-in MongoDB integration\n\n## Architecture\n\nThe package follows a modular architecture:\n\n- **Repository Layer**: Handles persistence with NoSQL databases\n- **Service Layer**: Implements OAuth flows and business logic\n- **Models**: Defines document models for NoSQL storage\n- **Schemas**: Defines data models and validation\n\n## Usage\n\n### Basic Setup\n\n```python\nfrom abs_nosql_integration_core.service import IntegrationBaseService\nfrom abs_nosql_integration_core.repository import IntegrationRepository\nfrom abs_integration_core.utils.encryption import Encryption\n\n# Create an integration service\nclass MyIntegrationService(IntegrationBaseService):\n def __init__(\n self,\n provider_name: str,\n integration_repository: IntegrationRepository,\n encryption: Encryption\n ):\n super().__init__(provider_name, integration_repository, encryption)\n # Additional provider-specific configuration\n```\n\n### Dependency Injection Setup\n\n```python\nfrom dependency_injector import containers, providers\nfrom abs_nosql_integration_core.repository import IntegrationRepository\nfrom abs_integration_core.utils.encryption import Encryption\n\nclass Container(containers.DeclarativeContainer):\n # MongoDB initialization\n mongodb_client = providers.Singleton(\n MongoClient, \n connection_string=settings.MONGODB_CONNECTION_STRING\n )\n \n # Encryption service\n encryption = providers.Singleton(\n Encryption,\n secret_key=settings.ENCRYPTION_KEY\n )\n \n # Repository layer\n integration_repository = providers.Singleton(IntegrationRepository)\n \n # Service layer\n my_integration_service = providers.Singleton(\n MyIntegrationService,\n provider_name=\"my_provider\",\n integration_repository=integration_repository,\n encryption=encryption\n )\n```\n\n### FastAPI Integration\n\n```python\nfrom fastapi import Depends, FastAPI, APIRouter\nfrom dependency_injector.wiring import inject, Provide\n\nrouter = APIRouter()\n\n@router.get(\"/connect\")\nasync def connect(\n service: IntegrationBaseService = Depends(get_integration_service),\n):\n auth_url = service.get_auth_url()\n return {\"auth_url\": auth_url}\n\n@router.get(\"/callback\")\nasync def callback(\n code: str,\n service: IntegrationBaseService = Depends(get_integration_service),\n):\n token_data = await service.handle_oauth_callback(code)\n return {\"status\": \"connected\"}\n```\n\n## Document Schema\n\nThe integration document model includes:\n\n```python\nclass IntegrationDocument(BaseDraftDocument):\n provider_name: str # Name of the integration provider\n access_token: str # OAuth access token (encrypted)\n refresh_token: str # OAuth refresh token (encrypted)\n expires_at: datetime # Token expiration date\n```\n\n## Repository Methods\n\nThe `IntegrationRepository` class provides:\n\n- `create_integration`: Create a new integration record\n- `refresh_token`: Update access and refresh tokens\n- `get_query_by_provider`: Find an integration by provider name\n- `get_integration`: Get a single integration by provider\n- `get_all_integrations`: Get all integrations\n- `delete_integration`: Remove an integration\n\n## Service Methods\n\nThe `IntegrationBaseService` class provides:\n\n- `get_auth_url`: Generate OAuth authorization URL\n- `handle_oauth_callback`: Process OAuth callback and store tokens\n- `refresh_token`: Refresh expired access tokens\n- `get_integration`: Get current integration details\n- `delete_integration`: Remove integration and related tokens\n\n## Exception Handling\n\nThe library uses a standard exception hierarchy:\n\n- `NotFoundError`: Integration not found\n- `BadRequestError`: Invalid request parameters\n- `DuplicatedError`: Integration already exists\n- `UnauthorizedError`: Authentication issues\n\n## MongoDB Configuration\n\nThe package supports MongoDB through Beanie ODM:\n\n```python\nfrom beanie import init_beanie\nfrom motor.motor_asyncio import AsyncIOMotorClient\nfrom abs_nosql_integration_core.model import IntegrationDocument\n\nasync def init_mongodb():\n # Create Motor client\n client = AsyncIOMotorClient(MONGODB_URL)\n \n # Initialize Beanie with document models\n await init_beanie(\n database=client.db_name,\n document_models=[IntegrationDocument]\n )\n```\n\n## Best Practices\n\n- Always encrypt sensitive tokens using the provided encryption utilities\n- Use dependency injection for better testability\n- Implement proper error handling for OAuth edge cases\n- Consider rate limiting for API calls\n- Implement proper logging for debugging\n- Use async context managers for database operations\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests.\n\n## License\n\nThis project is licensed under the MIT License.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Core utilities for building OAuth-based integrations in FastAPI applications with use of NoSql db",
"version": "0.1.15",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fd1133b32840321c2f48c8ab9da18e88c267a5fca12b1ff410271e07e1623320",
"md5": "372870a356055467c88ee243b57a63f9",
"sha256": "9d6fb0038b36c27ff9448fdf73e98ffcd58e6fab97f8f92c1ff4d187fb0514fc"
},
"downloads": -1,
"filename": "abs_nosql_integration_core-0.1.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "372870a356055467c88ee243b57a63f9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.13",
"size": 15557,
"upload_time": "2025-07-21T17:33:32",
"upload_time_iso_8601": "2025-07-21T17:33:32.420646Z",
"url": "https://files.pythonhosted.org/packages/fd/11/33b32840321c2f48c8ab9da18e88c267a5fca12b1ff410271e07e1623320/abs_nosql_integration_core-0.1.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c50b4736f9b2f5f1856be35630ef1f17d4fa55b21cb9af05e85b335c6f7cb2d",
"md5": "160548b631636134841b073f07ccd383",
"sha256": "7dec68dd07f618b42970164c970c81751a865098e2453887f86f33759b0e58b1"
},
"downloads": -1,
"filename": "abs_nosql_integration_core-0.1.15.tar.gz",
"has_sig": false,
"md5_digest": "160548b631636134841b073f07ccd383",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.13",
"size": 9518,
"upload_time": "2025-07-21T17:33:34",
"upload_time_iso_8601": "2025-07-21T17:33:34.063149Z",
"url": "https://files.pythonhosted.org/packages/7c/50/b4736f9b2f5f1856be35630ef1f17d4fa55b21cb9af05e85b335c6f7cb2d/abs_nosql_integration_core-0.1.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 17:33:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "abs-nosql-integration-core"
}