Skip to content

Commit 9529416

Browse files
tpellissier-msfttpellissierCopilot
authored
Make docs RST format and add more details for public facing methods (#29)
* Make docs RST format and add more details for public facing methods * remove rtype / returns for None * Update src/dataverse_sdk/client.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Tim Pellissier <tpellissier@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 587baf4 commit 9529416

File tree

6 files changed

+623
-224
lines changed

6 files changed

+623
-224
lines changed

src/dataverse_sdk/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
"""
2+
Microsoft Dataverse SDK for Python.
3+
4+
This package provides a high-level Python client for interacting with Microsoft Dataverse
5+
environments through the Web API. It supports CRUD operations, SQL queries, table metadata
6+
management, and file uploads with Azure Identity authentication.
7+
8+
Key Features:
9+
- OData CRUD operations (create, read, update, delete)
10+
- SQL query support via Web API
11+
- Table metadata operations (create, inspect, delete custom tables)
12+
- File column upload capabilities
13+
- Pandas integration for DataFrame-based operations
14+
- Azure Identity credential support
15+
16+
.. note::
17+
This SDK requires Azure Identity credentials for authentication. See the
18+
`Azure Identity documentation <https://learn.microsoft.com/python/api/overview/azure/identity-readme>`_
19+
for supported credential types.
20+
21+
Example:
22+
Basic client initialization and usage::
23+
24+
from azure.identity import DefaultAzureCredential
25+
from dataverse_sdk import DataverseClient
26+
27+
credential = DefaultAzureCredential()
28+
client = DataverseClient(
29+
"https://org.crm.dynamics.com",
30+
credential
31+
)
32+
33+
# Create a record
34+
account_id = client.create("account", {"name": "Contoso"})[0]
35+
36+
# Query records
37+
accounts = client.get("account", filter="name eq 'Contoso'")
38+
for batch in accounts:
39+
for record in batch:
40+
print(record["name"])
41+
"""
42+
143
from .__version__ import __version__
244
from .client import DataverseClient
345

src/dataverse_sdk/auth.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@
77

88
@dataclass
99
class TokenPair:
10+
"""
11+
Container for an OAuth2 access token and its associated resource scope.
12+
13+
:param resource: The OAuth2 scope/resource for which the token was acquired.
14+
:type resource: str
15+
:param access_token: The access token string.
16+
:type access_token: str
17+
"""
1018
resource: str
1119
access_token: str
1220

1321

1422
class AuthManager:
15-
"""Azure Identity-based authentication helper for Dataverse."""
23+
"""
24+
Azure Identity-based authentication manager for Dataverse.
25+
26+
:param credential: Azure Identity credential implementation.
27+
:type credential: ~azure.core.credentials.TokenCredential
28+
:raises TypeError: If ``credential`` does not implement :class:`~azure.core.credentials.TokenCredential`.
29+
"""
1630

1731
def __init__(self, credential: TokenCredential) -> None:
1832
if not isinstance(credential, TokenCredential):
@@ -22,6 +36,14 @@ def __init__(self, credential: TokenCredential) -> None:
2236
self.credential: TokenCredential = credential
2337

2438
def acquire_token(self, scope: str) -> TokenPair:
25-
"""Acquire an access token for the given scope using Azure Identity."""
39+
"""
40+
Acquire an access token for the specified OAuth2 scope.
41+
42+
:param scope: OAuth2 scope string, typically ``"https://<org>.crm.dynamics.com/.default"``.
43+
:type scope: str
44+
:return: Token pair containing the scope and access token.
45+
:rtype: ~dataverse_sdk.auth.TokenPair
46+
:raises ~azure.core.exceptions.ClientAuthenticationError: If token acquisition fails.
47+
"""
2648
token = self.credential.get_token(scope)
2749
return TokenPair(resource=scope, access_token=token.token)

0 commit comments

Comments
 (0)