Skip to content

[Playwright] Adding dataplane python sdk for playwright against latest API 2026-04-01-preview#46083

Open
Himanshu49 wants to merge 10 commits intoAzure:mainfrom
Himanshu49:users/hbisht/pww-sdk-preview
Open

[Playwright] Adding dataplane python sdk for playwright against latest API 2026-04-01-preview#46083
Himanshu49 wants to merge 10 commits intoAzure:mainfrom
Himanshu49:users/hbisht/pww-sdk-preview

Conversation

@Himanshu49
Copy link
Copy Markdown
Member

Description

Initial preview release of the Azure Developer Playwright client library for Python, generated from TypeSpec against data-plane API version 2026-04-01-preview.

Provides PlaywrightClient with 4 operation groups: AccessTokens, TestRuns, BrowserSessions, and Workspaces.

Customizations
Reporting subdomain routing - TestRunsOperations and BrowserSessionsOperations routed to *.reporting.api.playwright.microsoft.com via a config proxy. This is service behaviour.
Redirect handling - get_browsers disables auto-redirect to prevent auth failures on WebSocket 302 responses
Credential scope override - spec has incorrect scope; overridden to https://management.core.windows.net/.default

Tests are added for each of the operation introduced in the preview sdk version.

Spec PR - Azure/azure-rest-api-specs#41380

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@Himanshu49 Himanshu49 marked this pull request as ready for review April 2, 2026 15:07
Copilot AI review requested due to automatic review settings April 2, 2026 15:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the initial preview Python data-plane SDK for Azure Developer Playwright (API version 2026-04-01-preview), including the generated client surface, samples, and test scaffolding.

Changes:

  • Added the azure-developer-playwright package (client, models, operations, async variant) generated from TypeSpec.
  • Added customizations for reporting-subdomain routing, redirect handling for get_browsers, and credential scope override.
  • Added initial test suite and generated samples for the exposed operation groups.

Reviewed changes

Copilot reviewed 58 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/playwright/azure-developer-playwright/tsp-location.yaml Pins the TypeSpec source location/commit for SDK generation.
sdk/playwright/azure-developer-playwright/_metadata.json Declares the API version metadata used by tooling.
sdk/playwright/azure-developer-playwright/apiview-properties.json APIView cross-language mapping metadata for review alignment.
sdk/playwright/azure-developer-playwright/assets.json Tracks the asset/tag used for SDK automation.
sdk/playwright/azure-developer-playwright/CHANGELOG.md Initial preview release notes for 1.0.0b1.
sdk/playwright/azure-developer-playwright/README.md Package README with installation/authentication and basic usage.
sdk/playwright/azure-developer-playwright/pyproject.toml Package build and dependency configuration.
sdk/playwright/azure-developer-playwright/MANIFEST.in sdist packaging manifest (includes tests/samples and typing marker).
sdk/playwright/azure-developer-playwright/LICENSE MIT license file for the package.
sdk/playwright/azure-developer-playwright/dev_requirements.txt Development dependencies for local dev/test runs.
sdk/playwright/azure-developer-playwright/azure/init.py Namespace package setup for azure.*.
sdk/playwright/azure-developer-playwright/azure/developer/init.py Namespace package setup for azure.developer.*.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/init.py Public package entrypoint exporting PlaywrightClient and __version__.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_version.py Defines the package version constant.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_validation.py API-version validation decorator used by generated ops.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_configuration.py Sync client configuration (policies, scopes, endpoint, api-version).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_client.py Sync PlaywrightClient implementation wiring operation groups.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_patch.py Custom sync client override for credential scopes.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/py.typed PEP 561 typing marker inclusion.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_utils/init.py Generated utilities package marker.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_utils/model_base.py Generated model base (mapping-style models + serialization helpers).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/_utils/serialization.py Generated serializer/deserializer infrastructure.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/models/init.py Public models export surface.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/models/_models.py Generated model types (AccessToken, TestRun, Workspace, etc.).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/models/_enums.py Generated enum types (OS, RunStatus, etc.).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/models/_patch.py Customization hook for models (currently empty).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/operations/init.py Sync operations export surface (applies operation patches).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/operations/_operations.py Generated sync operation implementations.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/operations/_patch.py Custom sync operation overrides (reporting endpoint + redirect handling).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/init.py Async package entrypoint exporting async PlaywrightClient.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/_configuration.py Async client configuration (policies, scopes, endpoint, api-version).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/_client.py Async PlaywrightClient implementation wiring operation groups.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/_patch.py Custom async client override for credential scopes.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/operations/init.py Async operations export surface (applies operation patches).
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/operations/_operations.py Generated async operation implementations.
sdk/playwright/azure-developer-playwright/azure/developer/playwright/aio/operations/_patch.py Custom async operation overrides (reporting endpoint + redirect handling).
sdk/playwright/azure-developer-playwright/generated_samples/access_tokens_create_or_replace.py Generated sample for access token create/replace.
sdk/playwright/azure-developer-playwright/generated_samples/access_tokens_delete.py Generated sample for access token delete.
sdk/playwright/azure-developer-playwright/generated_samples/access_tokens_get.py Generated sample for access token get.
sdk/playwright/azure-developer-playwright/generated_samples/access_tokens_list.py Generated sample for access token list.
sdk/playwright/azure-developer-playwright/generated_samples/browser_sessions_get.py Generated sample for browser session get.
sdk/playwright/azure-developer-playwright/generated_samples/browser_sessions_list.py Generated sample for browser session list.
sdk/playwright/azure-developer-playwright/generated_samples/test_runs_create_or_update.py Generated sample for test run create/update.
sdk/playwright/azure-developer-playwright/generated_samples/test_runs_get.py Generated sample for test run get.
sdk/playwright/azure-developer-playwright/generated_samples/test_runs_list.py Generated sample for test run list.
sdk/playwright/azure-developer-playwright/generated_samples/workspaces_get.py Generated sample for workspace get.
sdk/playwright/azure-developer-playwright/generated_samples/workspaces_get_browsers.py Generated sample for workspace get browsers (redirect endpoint).
sdk/playwright/azure-developer-playwright/tests/conftest.py Test-proxy configuration + sanitizers for recordings/live runs.
sdk/playwright/azure-developer-playwright/tests/testpreparer.py Sync test base + PowerShell preparer.
sdk/playwright/azure-developer-playwright/tests/testpreparer_async.py Async test base.
sdk/playwright/azure-developer-playwright/tests/test_playwright_access_tokens_operations.py Sync tests for AccessTokens operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_access_tokens_operations_async.py Async tests for AccessTokens operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_test_runs_operations.py Sync tests for TestRuns operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_test_runs_operations_async.py Async tests for TestRuns operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_browser_sessions_operations.py Sync tests for BrowserSessions operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_browser_sessions_operations_async.py Async tests for BrowserSessions operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_workspaces_operations.py Sync tests for Workspaces operations.
sdk/playwright/azure-developer-playwright/tests/test_playwright_workspaces_operations_async.py Async tests for Workspaces operations.

Comment on lines +18 to +31
def _to_reporting_endpoint(endpoint: str) -> str:
"""Derive the reporting API endpoint from the base service endpoint.

The test-runs API is served from the reporting subdomain
(e.g. https://{region}.reporting.api.playwright.microsoft.com) while
all other operations use the base subdomain
(e.g. https://{region}.api.playwright.microsoft.com).

:param str endpoint: The base API endpoint URL.
:returns: The reporting API endpoint URL.
:rtype: str
"""
return endpoint.replace(".api.playwright.", ".reporting.api.playwright.")

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_to_reporting_endpoint() uses a plain string .replace(".api.playwright.", ".reporting.api.playwright."), which will produce an invalid host if the caller already passes a reporting endpoint (e.g., *.reporting.api.playwright.* becomes *.reporting.reporting.api.playwright.*). Consider making the transformation idempotent (e.g., detect .reporting.api.playwright. first, or parse the hostname and insert reporting. only when missing).

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +36
client = self.create_async_client(endpoint=playwright_endpoint)
response = await client.access_tokens.create_or_replace(
workspace_id=playwright_workspace_id,
access_token_id=token_id,
resource={
"name": f"tk-c-{suffix}",
"expiryAt": expiry,
},
)

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async client created here is never closed (PlaywrightClient manages an underlying aiohttp session). To avoid resource warnings/leaks and intermittent test flakiness, wrap usage in async with client: (or try/finally: await client.close()).

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +30
client = self.create_async_client(endpoint=playwright_endpoint)
response = await client.test_runs.create_or_update(
workspace_id=playwright_workspace_id,
run_id=run_id,
resource={
"displayName": "test-run",
},
)

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async client created here is never closed (PlaywrightClient manages an underlying aiohttp session). To avoid resource warnings/leaks and intermittent test flakiness, wrap usage in async with client: (or try/finally: await client.close()).

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +24
async def test_browser_sessions_list(self, playwright_endpoint, playwright_workspace_id):
client = self.create_async_client(endpoint=playwright_endpoint)
response = client.browser_sessions.list(
workspace_id=playwright_workspace_id,
)
result = [r async for r in response]
assert isinstance(result, list)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async client created here is never closed (PlaywrightClient manages an underlying aiohttp session). To avoid resource warnings/leaks and intermittent test flakiness, wrap usage in async with client: (or try/finally: await client.close()).

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +24
client = self.create_async_client(endpoint=playwright_endpoint)
response = await client.workspaces.get(
workspace_id=playwright_workspace_id,
)
assert response is not None
assert "id" in response
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async client created here is never closed (PlaywrightClient manages an underlying aiohttp session). To avoid resource warnings/leaks and intermittent test flakiness, wrap usage in async with client: (or try/finally: await client.close()).

Copilot uses AI. Check for mistakes.
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.

2 participants