Skip to content

Conversation

@TordAreStromsnes
Copy link
Contributor

This pull request introduces comprehensive documentation and codebase improvements for the DSIS Python client SDK. The main focus is on adding the initial use case of the sdk, which is building queries for the API and executing the request to the api, retrieving the data and casting the result.

Codebase documentation and public API enhancements:

  • Replaced the placeholder main() in src/dsis_client/__init__.py with a comprehensive module docstring, listed all public API symbols in __all__, and provided a usage example.
  • created dsisconfig and dsisclient for an easy setup for connection to the api
  • added querybuilder to setup the entire url
  • added executequery and cast_result to retrieve data and get right schema on it

Documentation additions and improvements:

  • Added a high-level overview and documentation map to docs/index.md, outlining the SDK's purpose, security highlights, and navigation for new users.
  • Introduced a Getting Started guide with prerequisites, environment variable setup, configuration, troubleshooting, and security best practices in docs/guides/getting-started.md.
  • Added a QueryBuilder guide with detailed usage patterns, method chaining, error handling, and best practices in docs/guides/query-builder.md.
  • Provided an advanced serialization guide in docs/guides/advanced-serialization.md, demonstrating multiple ways to deserialize API responses using dsis-model-sdk.
  • Created an API summary in docs/api/index.md with class/method overviews, usage examples, error handling tips, and notes on extending functionality.
  • Updated the documentation navigation in mkdocs.yml to include the new guides and API summary.

TordAreStromsnes and others added 22 commits October 15, 2025 12:18
- Updated index.md with a comprehensive overview and documentation map.
- Added getting-started.md for installation and usage instructions.
- Introduced api/index.md for API summary and class details.
- Implemented DSIS API client and authentication modules with dual-token handling.
- Configured environment settings and endpoints for DSIS API.
…omprehensive documentation

- Create custom exception hierarchy (DSISException, DSISAuthenticationError, DSISAPIError, DSISConfigurationError)
- Add configuration validation in DSISConfig.__post_init__()
- Add logging support throughout auth.py and client.py
- Improve docstrings with detailed descriptions and examples
- Add type hints for better IDE support
- Export exceptions from main package
- Update README with comprehensive documentation including:
  - Features overview
  - Quick start guide with basic and advanced examples
  - Configuration parameters table
  - Error handling guide
  - Logging setup instructions
  - Complete API method documentation
- Refactor DSISConfig to use single 'model_name' field instead of separate native/common model names
- Add factory methods: for_native_model() and for_common_model() for easy config creation
- Update client.get() and get_odata() to always use configured model_name and model_version
- Remove get_configured_data() method as it's now redundant
- Simplify API: users no longer need to pass model names to get/get_odata methods
- Update README with simplified usage examples
- Add comprehensive test coverage for endpoint construction
- Create QueryBuilder class for building OData queries with dsis_schemas validation
- Support fluent interface: .data_table().select().filter().expand().build()
- Validate data_table against available models in dsis_schemas
- Support both common and native model domains
- Add comprehensive test suite with 49 tests covering all functionality
- Update README with QueryBuilder documentation and examples
- Add model validation to DSISClient.get() and get_odata() methods
- Export QueryBuilder from main package
…turn DsisQuery

- QueryBuilder now accepts optional district_id and field parameters in constructor
- build() method now returns DsisQuery object instead of string
- DsisQuery encapsulates query string and path parameters for clean separation of concerns
- Added executeQuery() method to DSISClient for executing DsisQuery objects
- Updated example.py to demonstrate single builder instance reuse
- Added comprehensive tests for new path parameter functionality
- Updated README with new API documentation and examples
- Add model() method to set data_table from dsis_model_sdk model class
- Add select_from_model() method for field validation against model schema
- Add get_model() static method to retrieve model class by name
- Add get_model_fields() static method to get model field information
- Add 11 comprehensive tests for new model helper functionality
- Update README with examples and documentation for new methods
- All 66 tests passing
- Add model_class parameter to DsisQuery constructor
- Add set_model() method to set model class for casting
- Add cast_result() method to cast single result item to model
- Add cast_results() method to cast multiple result items to models
- Update QueryBuilder to track and pass model_class to DsisQuery
- Update QueryBuilder.model() to store model class for automatic casting
- Add 8 comprehensive tests for result casting functionality
- Update README with casting examples and documentation
- All 74 tests passing
- Rename model_class to schema_class in DsisQuery
- Rename data_table property to schema (removed deprecated data_table)
- Rename set_model() to set_schema() (removed deprecated set_model)
- Update client.py to use query.schema instead of query.data_table
- Update all tests to use schema terminology
- Update README documentation with new terminology
- All 74 tests passing

This change improves clarity by avoiding confusion between:
- DSISConfig.model (API model name like 'common' or 'native')
- QueryBuilder.model() (dsis_model_sdk model class)
- DsisQuery.schema (the data schema/table name like 'Well', 'Fault')
- Create .env.example as a template for credentials
- Users can copy this to .env and fill in their credentials
- .env is already in .gitignore to prevent committing secrets
Major refactoring to simplify the API and improve separation of concerns:

1. Removed domain parameter from QueryBuilder
   - Domain validation moved to API level
   - Simpler constructor: only district_id and field required

2. Removed static helper methods from QueryBuilder
   - Removed list_available_models(), get_model(), get_model_fields()
   - Users should import models directly from dsis_model_sdk

3. Moved casting functionality from QueryBuilder to DSISClient
   - Added cast parameter to executeQuery(query, cast=False)
   - Added cast_results(results, schema_class) method
   - Better separation: QueryBuilder builds, DSISClient executes and processes

4. Removed select_from_model() method
   - Redundant with .select() method
   - Removed unnecessary field validation

5. Renamed query_builder.py to dsis_query_builder.py
   - Clearer naming to indicate DSIS-specific functionality

6. Deleted dsis_query.py
   - Functionality merged into QueryBuilder

7. Added working example.py with casting demonstration
   - Shows both auto-cast and manual cast options
   - Uses Basin model with required fields
   - Demonstrates all QueryBuilder features

Test results: 55 tests passing (down from 68 - removed redundant tests)

Benefits:
- Simpler, cleaner API
- Better separation of concerns
- Fewer parameters and methods
- More intuitive usage
- Less code to maintain
- Remove references to domain parameter (removed from QueryBuilder)
- Remove references to static helper methods (list_available_models, get_model, get_model_fields)
- Remove references to select_from_model() method (removed)
- Remove references to DsisQuery class (merged into QueryBuilder)
- Remove references to .build() method (QueryBuilder IS the query object)
- Update QueryBuilder constructor signature (district_id and field are required)
- Update .schema() method documentation (replaces .model() and .data_table())
- Update casting documentation (moved to DSISClient with cast=True and cast_results())
- Update executeQuery() documentation (added cast parameter)
- Add examples showing required fields must be selected for casting
- Simplify API documentation to match current implementation
- Added ModelOperationsMixin to provide model validation, discovery, and serialization operations.
- Implemented methods for checking model validity, retrieving model classes and fields, deserializing API responses, and casting results to model instances.

refactor: Restructure configuration management for DSIS API client

- Deleted old config.py and split configuration into multiple modules for better organization.
- Introduced environment management and factory methods for creating DSISConfig instances.
- Added validation for configuration values and improved error handling.

feat: Implement query builder for DSIS OData API

- Created QueryBuilder class to facilitate building OData queries with a fluent interface.
- Added methods for setting schema, selecting fields, expanding relations, and filtering results.
- Implemented utilities for building and formatting OData query strings.

chore: Add model utilities for schema validation and serialization

- Introduced schema_helper and serialization modules for model validation and response deserialization.
- Implemented functions for checking model validity, retrieving model fields, and casting API response items to model instances.
…ne testing, so that we test for behavior in our implementation and not the implementation itself.
…tency and code cleanup

- Removed ModelOperationsMixin and its associated methods.
- Updated DSISClient to eliminate data_table parameter, replacing it with schema.
- Renamed validation and retrieval functions from model to schema terminology in schema_helper.py.
- Deleted unused deserialize_response function from serialization.py.
- Consolidated cast_results functionality to avoid duplication.
- Enhanced documentation and examples to reflect changes in schema terminology.
- Added new advanced serialization and query builder guides to documentation.
@TordAreStromsnes TordAreStromsnes merged commit 7342725 into main Nov 4, 2025
5 checks passed
@TordAreStromsnes TordAreStromsnes deleted the feature/dsis-sdk branch November 4, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants