Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ConfidentialLedgerClient(GeneratedClient):
file does not exist yet, the Confidential Ledger's TLS certificate will be fetched and saved
to this file.
:paramtype ledger_certificate_path: Union[bytes, str, os.PathLike]
:keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: API version for Confidential Ledger operations. Default value is "2024-12-09-preview".
This aligns with the latest preview specification. Overriding may lead to unsupported behavior.
:paramtype api_version: str
"""

Expand All @@ -79,6 +79,10 @@ def __init__(
ledger_certificate_path: Union[bytes, str, os.PathLike],
**kwargs: Any,
) -> None:
# Align default to latest preview used by generated configuration
api_version = kwargs.pop("api_version", "2024-12-09-preview")
kwargs["api_version"] = api_version

# Remove some kwargs first so that there aren't unexpected kwargs passed to
# get_ledger_identity.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class ConfidentialLedgerClient(GeneratedClient):
file does not exist yet, the Confidential Ledger's TLS certificate will be fetched and saved
to this file.
:paramtype ledger_certificate_path: Union[bytes, str, os.PathLike]
:keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: API version for Confidential Ledger operations. Default value is "2024-12-09-preview".
This aligns with the latest preview specification. Overriding may lead to unsupported behavior.
:paramtype api_version: str
"""

Expand All @@ -65,6 +65,10 @@ def __init__(
ledger_certificate_path: Union[bytes, str, os.PathLike],
**kwargs: Any,
) -> None:
# Align default to latest preview used by generated configuration
api_version = kwargs.pop("api_version", "2024-12-09-preview")
kwargs["api_version"] = api_version

# Remove some kwargs first so that there aren't unexpected kwargs passed to
# get_ledger_identity.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# pylint: disable=line-too-long,useless-suppression
"""Tests for API version defaults in Confidential Ledger clients."""
import os
import re


class TestDefaultApiVersion:
"""Test that the default API version is correctly set in source code."""

def test_data_plane_patch_has_correct_default(self):
"""Verify data-plane _patch.py has 2024-12-09-preview as default."""
patch_file = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"azure", "confidentialledger", "_patch.py"
)

with open(patch_file, 'r', encoding='utf-8') as f:
content = f.read()

# Check docstring mentions the correct version
assert '"2024-12-09-preview"' in content, \
"Docstring should mention 2024-12-09-preview"

# Check code sets the correct default
assert 'api_version = kwargs.pop("api_version", "2024-12-09-preview")' in content, \
"Code should default to 2024-12-09-preview"

def test_data_plane_async_patch_has_correct_default(self):
"""Verify async data-plane aio/_patch.py has 2024-12-09-preview as default."""
patch_file = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"azure", "confidentialledger", "aio", "_patch.py"
)

with open(patch_file, 'r', encoding='utf-8') as f:
content = f.read()

# Check docstring mentions the correct version
assert '"2024-12-09-preview"' in content, \
"Docstring should mention 2024-12-09-preview"

# Check code sets the correct default
assert 'api_version = kwargs.pop("api_version", "2024-12-09-preview")' in content, \
"Code should default to 2024-12-09-preview"

def test_mgmt_client_docstring_mentions_version(self):
"""Verify management client docstring mentions current default version."""
mgmt_file = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
"azure-mgmt-confidentialledger", "azure", "mgmt", "confidentialledger",
"_confidential_ledger.py"
)

with open(mgmt_file, 'r', encoding='utf-8') as f:
content = f.read()

# Check docstring mentions the correct version
assert "2024-09-19-preview" in content, \
"Docstring should mention 2024-09-19-preview as default"

# Check it mentions the newer version
assert "2025-06-10-preview" in content, \
"Docstring should mention 2025-06-10-preview as available"

def test_mgmt_client_async_docstring_mentions_version(self):
"""Verify async management client docstring mentions current default version."""
mgmt_file = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
"azure-mgmt-confidentialledger", "azure", "mgmt", "confidentialledger",
"aio", "_confidential_ledger.py"
)

with open(mgmt_file, 'r', encoding='utf-8') as f:
content = f.read()

# Check docstring mentions the correct version
assert "2024-09-19-preview" in content, \
"Docstring should mention 2024-09-19-preview as default"

# Check it mentions the newer version
assert "2025-06-10-preview" in content, \
"Docstring should mention 2025-06-10-preview as available"

def test_generated_config_uses_latest_preview(self):
"""Verify generated configuration file uses the latest preview version."""
config_file = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"azure", "confidentialledger", "_configuration.py"
)

with open(config_file, 'r', encoding='utf-8') as f:
content = f.read()

# Check that generated config uses 2024-12-09-preview
assert '"2024-12-09-preview"' in content, \
"Generated configuration should use 2024-12-09-preview"
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@


class ConfidentialLedger(ConfidentialLedgerOperationsMixin):
"""Microsoft Azure Confidential Compute Ledger Control Plane REST API version 2020-12-01-preview.
"""Microsoft Azure Confidential Compute Ledger Control Plane.

Default REST API version: 2024-09-19-preview.
A newer preview (2025-06-10-preview) is available in published TypeSpec; specify api_version to opt-in.

:ivar operations: Operations operations
:vartype operations: azure.mgmt.confidentialledger.operations.Operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@


class ConfidentialLedger(ConfidentialLedgerOperationsMixin):
"""Microsoft Azure Confidential Compute Ledger Control Plane REST API version 2020-12-01-preview.
"""Microsoft Azure Confidential Compute Ledger Control Plane.

Default REST API version: 2024-09-19-preview.
Newer preview (2025-06-10-preview) available; set api_version explicitly to use it.

:ivar operations: Operations operations
:vartype operations: azure.mgmt.confidentialledger.aio.operations.Operations
Expand Down
Loading