Python client library for NDP EP API
Project description
ndp-ep
A Python client library for interacting with the NDP EP API. This library provides a simple and intuitive interface for managing datasets, organizations, resources, and services through the API.
Features
- Complete API Coverage: Support for all API endpoints including Kafka topics, S3 resources, URL resources, organizations, and services
- Authentication: Token-based and username/password authentication
- Search Functionality: Advanced search capabilities across datasets and resources
- Error Handling: Comprehensive error handling with meaningful error messages
- Type Hints: Full type hint support for better IDE integration
- Testing: Extensive test coverage (>70%) with unit and integration tests
Installation
pip install ndp-ep
Quick Start
from ndp_ep import APIClient
# Initialize client with token
client = APIClient(
base_url="https://your-api-endpoint.com",
token="your-access-token"
)
# Or with username/password
client = APIClient(
base_url="https://your-api-endpoint.com",
username="your-username",
password="your-password"
)
# List organizations
organizations = client.list_organizations()
print(organizations)
# Search datasets
results = client.search_datasets(
terms=["climate", "temperature"],
server="global"
)
# Register a new organization
org_data = {
"name": "my_organization",
"title": "My Organization",
"description": "A sample organization"
}
response = client.register_organization(org_data)
# Register a service
service_data = {
"service_name": "user_auth_api",
"service_title": "User Authentication API",
"owner_org": "services",
"service_url": "https://api.example.com/auth",
"service_type": "API",
"notes": "RESTful API for user authentication"
}
response = client.register_service(service_data)
API Coverage
Authentication
- Token-based authentication
- Username/password authentication
Organizations
list_organizations()- List all organizationsregister_organization()- Create new organizationdelete_organization()- Delete organization
Datasets and Resources
search_datasets()- Search datasets with advanced filtersadvanced_search()- Advanced search with POST methodregister_url()- Register URL resourcesregister_s3_link()- Register S3 resourcesregister_kafka_topic()- Register Kafka topicsregister_general_dataset()- Register general datasetsupdate_url_resource()- Update URL resourcesupdate_s3_resource()- Update S3 resourcesupdate_kafka_topic()- Update Kafka topicsupdate_general_dataset()- Update general datasets (PUT)patch_general_dataset()- Partially update general datasets (PATCH)delete_resource_by_id()- Delete resource by IDdelete_resource_by_name()- Delete resource by name
Services
register_service()- Register new services
System Information
get_kafka_details()- Get Kafka connection detailsget_system_status()- Check system statusget_system_metrics()- Get system metricsget_jupyter_details()- Get Jupyter connection details
Development
Setting up development environment
# Clone the repository
git clone https://github.com/sci-ndp/ndp-ep-py.git
cd ndp-ep-py
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e .
pip install -r requirements-dev.txt
Running tests
# Run all tests
pytest
# Run with coverage
pytest --cov=ndp_ep --cov-report=html
# Run specific test categories
pytest -m unit # Unit tests only
pytest -m integration # Integration tests only
Code formatting and linting
# Format code
black ndp_ep tests
# Lint code
flake8 ndp_ep
# Type checking
mypy ndp_ep
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass and coverage is maintained
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
v0.1.0
- Initial release
- Complete API coverage for all endpoints
- Authentication support (token and username/password)
- Search functionality
- Resource management (URL, S3, Kafka)
- Organization management
- Comprehensive testing suite
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ndp_ep-0.1.0.tar.gz
(19.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ndp_ep-0.1.0-py3-none-any.whl
(22.2 kB
view details)
File details
Details for the file ndp_ep-0.1.0.tar.gz.
File metadata
- Download URL: ndp_ep-0.1.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d2817c85b4064eccfe2b49471a9474da832b9ccdb7166de05a031f348cafda6
|
|
| MD5 |
0bdf0f6bf69cadbb2bab41fdde6ac3af
|
|
| BLAKE2b-256 |
400a5babe5faf3c3b6c15dcc1a3c89296b831acc7b61a224650289dea26cd281
|
File details
Details for the file ndp_ep-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ndp_ep-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5464c3a210c9f3a88d2404fa3cb35170b2ee59cc06a3ec14e75b8907b7fc2be6
|
|
| MD5 |
be9de9cfc7228a1ae374b4b920cb35a2
|
|
| BLAKE2b-256 |
32e493320d10fe2e5e630f900a1f3ae089f22bdc8895063ac0d809990962681b
|