Skip to content

Commit f1ca317

Browse files
author
Max Wang
committed
add class underscore
1 parent 5433056 commit f1ca317

10 files changed

Lines changed: 35 additions & 35 deletions

File tree

examples/basic/installation_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def validate_imports():
8484

8585
print(f" ✅ Core config: DataverseConfig")
8686

87-
from PowerPlatform.Dataverse.data._odata import ODataClient
87+
from PowerPlatform.Dataverse.data._odata import _ODataClient
8888

89-
print(f" ✅ Data layer: ODataClient")
89+
print(f" ✅ Data layer: _ODataClient")
9090

9191
# Test Azure Identity import
9292
from azure.identity import InteractiveBrowserCredential

src/PowerPlatform/Dataverse/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
from azure.core.credentials import TokenCredential
99

10-
from .core._auth import AuthManager
10+
from .core._auth import _AuthManager
1111
from .core.config import DataverseConfig
12-
from .data._odata import ODataClient
12+
from .data._odata import _ODataClient
1313

1414

1515
class DataverseClient:
@@ -18,7 +18,7 @@ class DataverseClient:
1818
1919
This client provides a simple, stable interface for interacting with Dataverse environments
2020
through the Web API. It handles authentication via Azure Identity and delegates HTTP operations
21-
to an internal :class:`~PowerPlatform.Dataverse.data._odata.ODataClient`.
21+
to an internal :class:`~PowerPlatform.Dataverse.data._odata._ODataClient`.
2222
2323
Key capabilities:
2424
- OData CRUD operations: create, read, update, delete records
@@ -74,25 +74,25 @@ def __init__(
7474
credential: TokenCredential,
7575
config: Optional[DataverseConfig] = None,
7676
) -> None:
77-
self.auth = AuthManager(credential)
77+
self.auth = _AuthManager(credential)
7878
self._base_url = (base_url or "").rstrip("/")
7979
if not self._base_url:
8080
raise ValueError("base_url is required.")
8181
self._config = config or DataverseConfig.from_env()
82-
self._odata: Optional[ODataClient] = None
82+
self._odata: Optional[_ODataClient] = None
8383

84-
def _get_odata(self) -> ODataClient:
84+
def _get_odata(self) -> _ODataClient:
8585
"""
8686
Get or create the internal OData client instance.
8787
8888
This method implements lazy initialization of the low-level OData client,
8989
deferring construction until the first API call.
9090
9191
:return: The lazily-initialized low-level client used to perform HTTP requests.
92-
:rtype: ~PowerPlatform.Dataverse.data._odata.ODataClient
92+
:rtype: ~PowerPlatform.Dataverse.data._odata._ODataClient
9393
"""
9494
if self._odata is None:
95-
self._odata = ODataClient(
95+
self._odata = _ODataClient(
9696
self.auth,
9797
self._base_url,
9898
self._config,

src/PowerPlatform/Dataverse/core/_auth.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"""
55
Authentication helpers for Dataverse.
66
7-
This module provides :class:`~PowerPlatform.Dataverse.core._auth.AuthManager`, a thin wrapper over any Azure Identity
8-
``TokenCredential`` for acquiring OAuth2 access tokens, and :class:`~PowerPlatform.Dataverse.core._auth.TokenPair` for
7+
This module provides :class:`~PowerPlatform.Dataverse.core._auth._AuthManager`, a thin wrapper over any Azure Identity
8+
``TokenCredential`` for acquiring OAuth2 access tokens, and :class:`~PowerPlatform.Dataverse.core._auth._TokenPair` for
99
storing the acquired token alongside its scope.
1010
"""
1111

@@ -17,7 +17,7 @@
1717

1818

1919
@dataclass
20-
class TokenPair:
20+
class _TokenPair:
2121
"""
2222
Container for an OAuth2 access token and its associated resource scope.
2323
@@ -31,7 +31,7 @@ class TokenPair:
3131
access_token: str
3232

3333

34-
class AuthManager:
34+
class _AuthManager:
3535
"""
3636
Azure Identity-based authentication manager for Dataverse.
3737
@@ -45,15 +45,15 @@ def __init__(self, credential: TokenCredential) -> None:
4545
raise TypeError("credential must implement azure.core.credentials.TokenCredential.")
4646
self.credential: TokenCredential = credential
4747

48-
def _acquire_token(self, scope: str) -> TokenPair:
48+
def _acquire_token(self, scope: str) -> _TokenPair:
4949
"""
5050
Acquire an access token for the specified OAuth2 scope.
5151
5252
:param scope: OAuth2 scope string, typically ``"https://<org>.crm.dynamics.com/.default"``.
5353
:type scope: :class:`str`
5454
:return: Token pair containing the scope and access token.
55-
:rtype: ~PowerPlatform.Dataverse.core._auth.TokenPair
55+
:rtype: ~PowerPlatform.Dataverse.core._auth._TokenPair
5656
:raises ~azure.core.exceptions.ClientAuthenticationError: If token acquisition fails.
5757
"""
5858
token = self.credential.get_token(scope)
59-
return TokenPair(resource=scope, access_token=token.token)
59+
return _TokenPair(resource=scope, access_token=token.token)

src/PowerPlatform/Dataverse/core/_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
HTTP client with automatic retry logic and timeout handling.
66
7-
This module provides :class:`~PowerPlatform.Dataverse.core._http.HttpClient`, a wrapper
7+
This module provides :class:`~PowerPlatform.Dataverse.core._http._HttpClient`, a wrapper
88
around the requests library that adds configurable retry behavior for transient
99
network errors and intelligent timeout management based on HTTP method types.
1010
"""
@@ -17,7 +17,7 @@
1717
import requests
1818

1919

20-
class HttpClient:
20+
class _HttpClient:
2121
"""
2222
HTTP client with configurable retry logic and timeout handling.
2323

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from datetime import datetime, timezone
1515
import importlib.resources as ir
1616

17-
from ..core._http import HttpClient
18-
from ._upload import ODataFileUpload
17+
from ..core._http import _HttpClient
18+
from ._upload import _ODataFileUpload
1919
from ..core.errors import *
2020
from ..core._error_codes import (
2121
_http_subcode,
@@ -37,7 +37,7 @@
3737
_GUID_RE = re.compile(r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
3838

3939

40-
class ODataClient(ODataFileUpload):
40+
class _ODataClient(_ODataFileUpload):
4141
"""Dataverse Web API client: CRUD, SQL-over-API, and table metadata helpers."""
4242

4343
@staticmethod
@@ -82,7 +82,7 @@ def __init__(
8282
Sets up authentication, base URL, configuration, and internal caches.
8383
8484
:param auth: Authentication manager providing ``_acquire_token(scope)`` that returns an object with ``access_token``.
85-
:type auth: ~PowerPlatform.Dataverse.core._auth.AuthManager
85+
:type auth: ~PowerPlatform.Dataverse.core._auth._AuthManager
8686
:param base_url: Organization base URL (e.g. ``"https://<org>.crm.dynamics.com"``).
8787
:type base_url: ``str``
8888
:param config: Optional Dataverse configuration (HTTP retry, backoff, timeout, language code). If omitted ``DataverseConfig.from_env()`` is used.
@@ -100,7 +100,7 @@ def __init__(
100100
"PowerPlatform.Dataverse.core.config", fromlist=["DataverseConfig"]
101101
).DataverseConfig.from_env()
102102
)
103-
self._http = HttpClient(
103+
self._http = _HttpClient(
104104
retries=self.config.http_retries,
105105
backoff=self.config.http_backoff,
106106
timeout=self.config.http_timeout,

src/PowerPlatform/Dataverse/data/_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Optional
99

1010

11-
class ODataFileUpload:
11+
class _ODataFileUpload:
1212
"""File upload capabilities (small + chunk) with auto selection."""
1313

1414
def _upload_file(

tests/unit/core/test_http_errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from PowerPlatform.Dataverse.core.errors import HttpError
66
from PowerPlatform.Dataverse.core._error_codes import HTTP_404, HTTP_429, HTTP_500
7-
from PowerPlatform.Dataverse.data._odata import ODataClient
7+
from PowerPlatform.Dataverse.data._odata import _ODataClient
88

99

1010
class DummyAuth:
@@ -49,7 +49,7 @@ def json_fail():
4949
return r
5050

5151

52-
class MockClient(ODataClient):
52+
class MockClient(_ODataClient):
5353
def __init__(self, responses):
5454
super().__init__(DummyAuth(), "https://org.example", None)
5555
self._http = DummyHTTP(responses)

tests/unit/data/test_enum_optionset_payload.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from enum import Enum, IntEnum
66

7-
from PowerPlatform.Dataverse.data._odata import ODataClient
7+
from PowerPlatform.Dataverse.data._odata import _ODataClient
88

99

1010
class DummyAuth:
@@ -16,18 +16,18 @@ class T:
1616

1717

1818
class DummyConfig:
19-
"""Minimal config stub providing attributes ODataClient.__init__ expects."""
19+
"""Minimal config stub providing attributes _ODataClient.__init__ expects."""
2020

2121
def __init__(self, language_code=1033):
2222
self.language_code = language_code
23-
# HTTP settings referenced during ODataClient construction
23+
# HTTP settings referenced during _ODataClient construction
2424
self.http_retries = 0
2525
self.http_backoff = 0
2626
self.http_timeout = 5
2727

2828

2929
def _make_client(lang=1033):
30-
return ODataClient(DummyAuth(), "https://org.example", DummyConfig(language_code=lang))
30+
return _ODataClient(DummyAuth(), "https://org.example", DummyConfig(language_code=lang))
3131

3232

3333
def _labels_for(option):

tests/unit/data/test_logical_crud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import types
55
import pytest
6-
from PowerPlatform.Dataverse.data._odata import ODataClient
6+
from PowerPlatform.Dataverse.data._odata import _ODataClient
77
from PowerPlatform.Dataverse.core.errors import MetadataError
88

99

@@ -43,7 +43,7 @@ def json_func():
4343
return resp
4444

4545

46-
class MockableClient(ODataClient):
46+
class MockableClient(_ODataClient):
4747
def __init__(self, responses):
4848
super().__init__(DummyAuth(), "https://org.example", None)
4949
self._http = DummyHTTPClient(responses)

tests/unit/data/test_sql_parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
import pytest
5-
from PowerPlatform.Dataverse.data._odata import ODataClient
5+
from PowerPlatform.Dataverse.data._odata import _ODataClient
66

77

88
class DummyAuth:
@@ -14,7 +14,7 @@ class T:
1414

1515

1616
def _client():
17-
return ODataClient(DummyAuth(), "https://org.example", None)
17+
return _ODataClient(DummyAuth(), "https://org.example", None)
1818

1919

2020
def test_basic_from():

0 commit comments

Comments
 (0)