-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Complete SDK restructuring #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Dataverse SDK Examples | ||
|
|
||
| This directory contains comprehensive examples demonstrating how to use the Microsoft Dataverse SDK for Python. | ||
|
|
||
| ## 📁 Directory Structure | ||
|
|
||
| ### 🌱 Basic Examples (`basic/`) | ||
| Get started quickly with fundamental Dataverse operations: | ||
| - **`quickstart.py`** - Basic client setup, authentication, and simple CRUD operations | ||
| - Authentication setup with Azure Identity | ||
| - Creating, reading, updating, and deleting records | ||
| - Basic error handling | ||
|
|
||
| ### 🚀 Advanced Examples (`advanced/`) | ||
| Explore powerful features for complex scenarios: | ||
| - **`file_upload.py`** - File upload to Dataverse file columns with chunking | ||
| - **`pandas_integration.py`** - DataFrame-based operations for data analysis | ||
|
|
||
| ## 🚀 Getting Started | ||
|
|
||
| 1. **Install Dependencies**: | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| 2. **Set Up Authentication**: | ||
| Configure Azure Identity credentials (see individual examples for details) | ||
|
|
||
| 3. **Run Basic Example**: | ||
| ```bash | ||
| python examples/basic/quickstart.py | ||
| ``` | ||
|
|
||
| ## 📋 Prerequisites | ||
|
|
||
| - Python 3.8+ | ||
| - Azure Identity credentials configured | ||
| - Access to a Dataverse environment | ||
| - Required packages installed from `requirements.txt` | ||
|
|
||
| ## 🔒 Authentication | ||
|
|
||
| All examples use Azure Identity for authentication. Common patterns: | ||
| - `DefaultAzureCredential` for development | ||
| - `ClientSecretCredential` for production services | ||
| - `InteractiveBrowserCredential` for interactive scenarios | ||
|
|
||
| ## 📖 Documentation | ||
|
|
||
| For detailed API documentation, visit: [Dataverse SDK Documentation](link-to-docs) | ||
|
|
||
| ## 🤝 Contributing | ||
|
|
||
| When adding new examples: | ||
| 1. Follow the existing code style and structure | ||
| 2. Include comprehensive comments and docstrings | ||
| 3. Add error handling and validation | ||
| 4. Update this README with your example | ||
| 5. Test thoroughly before submitting | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Examples package for the Dataverse SDK.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Advanced examples showcasing complex Dataverse SDK features.""" |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Basic examples for getting started with the Dataverse SDK.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Core infrastructure components for the Dataverse SDK. | ||
|
|
||
| This module contains the foundational components including authentication, | ||
| configuration, HTTP client, and error handling. | ||
| """ | ||
|
|
||
| from .auth import AuthManager, TokenPair | ||
| from .config import DataverseConfig | ||
| from .errors import ( | ||
| DataverseError, | ||
| HttpError, | ||
| ValidationError, | ||
| MetadataError, | ||
| SQLParseError, | ||
| ) | ||
| from .http import HttpClient | ||
|
|
||
| __all__ = [ | ||
| "AuthManager", | ||
| "TokenPair", | ||
| "DataverseConfig", | ||
| "DataverseError", | ||
| "HttpError", | ||
| "ValidationError", | ||
| "MetadataError", | ||
| "SQLParseError", | ||
| "HttpClient", | ||
| ] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Data access layer for the Dataverse SDK. | ||
|
|
||
| This module contains OData protocol handling, CRUD operations, metadata management, | ||
| SQL query functionality, and file upload capabilities. | ||
| """ | ||
|
|
||
| from .odata import ODataClient | ||
| from .upload import ODataFileUpload | ||
|
|
||
| __all__ = ["ODataClient", "ODataFileUpload"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Optional extensions for the Dataverse SDK. | ||
|
|
||
| This module contains optional features like CLI interfaces, async clients, | ||
| and other extended functionality. | ||
| """ | ||
|
|
||
| # Will be populated with extensions as they are created | ||
| __all__ = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Data models and type definitions for the Dataverse SDK. | ||
|
|
||
| This module contains entity models, response models, enums, and other | ||
| type definitions used throughout the SDK. | ||
| """ | ||
|
|
||
| # Will be populated with models as they are created | ||
| __all__ = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Utilities and adapters for the Dataverse SDK. | ||
|
|
||
| This module contains helper functions, adapters (like Pandas integration), | ||
| logging utilities, and validation helpers. | ||
| """ | ||
|
|
||
| from .pandas_adapter import PandasODataClient | ||
|
|
||
| __all__ = ["PandasODataClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| import pandas as pd | ||
|
|
||
| from .odata import ODataClient | ||
| from ..data.odata import ODataClient | ||
|
|
||
|
|
||
| @dataclass | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Test package for the Dataverse SDK.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Shared pytest fixtures and configuration for Dataverse SDK tests. | ||
|
|
||
| This module provides common test fixtures, mock objects, and configuration | ||
| that can be used across all test modules. | ||
| """ | ||
|
|
||
| import pytest | ||
| from unittest.mock import Mock | ||
| from dataverse_sdk.core.config import DataverseConfig | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def dummy_auth(): | ||
| """Mock authentication object for testing.""" | ||
| class DummyAuth: | ||
| def acquire_token(self, scope): | ||
| class Token: | ||
| access_token = "test_token_12345" | ||
| return Token() | ||
| return DummyAuth() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def test_config(): | ||
| """Test configuration with safe defaults.""" | ||
| return DataverseConfig( | ||
| language_code=1033, | ||
| http_retries=0, | ||
| http_backoff=0.1, | ||
| http_timeout=5 | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_http_client(): | ||
| """Mock HTTP client for unit tests.""" | ||
| mock = Mock() | ||
| mock.request.return_value = Mock() | ||
| return mock | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_base_url(): | ||
| """Standard test base URL.""" | ||
| return "https://org.example.com" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_entity_data(): | ||
| """Sample entity data for testing.""" | ||
| return { | ||
| "name": "Test Account", | ||
| "telephone1": "555-0100", | ||
| "websiteurl": "https://example.com" | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_guid(): | ||
| """Sample GUID for testing.""" | ||
| return "11111111-2222-3333-4444-555555555555" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Sample test data and fixtures for Dataverse SDK tests. | ||
|
|
||
| This module contains reusable test data, mock responses, and fixtures | ||
| that can be used across different test modules. | ||
| """ | ||
|
|
||
| # Sample entity metadata response | ||
| SAMPLE_ENTITY_METADATA = { | ||
| "value": [ | ||
| { | ||
| "LogicalName": "account", | ||
| "EntitySetName": "accounts", | ||
| "PrimaryIdAttribute": "accountid", | ||
| "DisplayName": {"UserLocalizedLabel": {"Label": "Account"}} | ||
| }, | ||
| { | ||
| "LogicalName": "contact", | ||
| "EntitySetName": "contacts", | ||
| "PrimaryIdAttribute": "contactid", | ||
| "DisplayName": {"UserLocalizedLabel": {"Label": "Contact"}} | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| # Sample OData response for accounts | ||
| SAMPLE_ACCOUNTS_RESPONSE = { | ||
| "value": [ | ||
| { | ||
| "accountid": "11111111-2222-3333-4444-555555555555", | ||
| "name": "Contoso Ltd", | ||
| "telephone1": "555-0100", | ||
| "websiteurl": "https://contoso.com" | ||
| }, | ||
| { | ||
| "accountid": "22222222-3333-4444-5555-666666666666", | ||
| "name": "Fabrikam Inc", | ||
| "telephone1": "555-0200", | ||
| "websiteurl": "https://fabrikam.com" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| # Sample error responses | ||
| SAMPLE_ERROR_RESPONSES = { | ||
| "404": { | ||
| "error": { | ||
| "code": "0x80040217", | ||
| "message": "The requested resource was not found." | ||
| } | ||
| }, | ||
| "429": { | ||
| "error": { | ||
| "code": "0x80072321", | ||
| "message": "Too many requests. Please retry after some time." | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Sample SQL query results | ||
| SAMPLE_SQL_RESPONSE = { | ||
| "value": [ | ||
| {"name": "Account 1", "revenue": 1000000}, | ||
| {"name": "Account 2", "revenue": 2000000} | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Integration tests for the Dataverse SDK.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Unit tests for the Dataverse SDK.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """Unit tests for core infrastructure components.""" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.