Skip to content
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

Release playwrighttesting microsoft.playwright testing.auth manager 2024 12 01 #31855

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a26928d
Copy files from preview/2023-10-01-preview
mjmadhu Dec 12, 2024
36c6afd
Update version to stable/2024-12-01
mjmadhu Dec 12, 2024
52a1a37
Added tag for 2024-12-01 in readme file
mjmadhu Dec 12, 2024
9cc3283
Added stable api-version for data-plane auth manager apis
mjmadhu Dec 12, 2024
1db7b13
Rectified a typo
mjmadhu Dec 12, 2024
2cb194c
Typespec Validation error resolved
mjmadhu Dec 12, 2024
0bdfe05
Typespec Validation error resolved
mjmadhu Dec 12, 2024
c8216f4
TSP Validation fix trial
mjmadhu Dec 12, 2024
6ff1186
TSP Validation fix trial
mjmadhu Dec 12, 2024
13348ff
Removed redundant imports
mjmadhu Dec 13, 2024
c3f61c7
Fixed readme errors
mjmadhu Dec 13, 2024
b291261
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 15, 2024
0bb3649
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 17, 2024
74b8e47
Added trailing newline char in tspconfig.yaml
mjmadhu Dec 17, 2024
91818d6
Typespec validation errors fix
mjmadhu Dec 17, 2024
528ca41
Committing changes by npx tsv
mjmadhu Dec 17, 2024
3f602d2
Update formatting
mjmadhu Dec 17, 2024
2cc2e53
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 17, 2024
c21633b
Added suppression and bit more documentation in comments
mjmadhu Dec 17, 2024
381b8a0
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 18, 2024
6f33e52
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 18, 2024
7ce268b
Suppression improvement
mjmadhu Dec 18, 2024
5d76723
Merge branch 'main' into dev-playwrighttesting-Microsoft.PlaywrightTe…
mjmadhu Dec 19, 2024
15d8881
Removed validate access token api as suggested in review feedback
mjmadhu Dec 19, 2024
96a2f69
Added suppressions for swagger lintdiff issues
mjmadhu Dec 19, 2024
c280115
Added suppressions for swagger lintdiff issues
mjmadhu Dec 19, 2024
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
@@ -1,9 +1,9 @@
{
"title": "AccessTokens_CreateAccessToken",
"operationId": "AccessTokens_CreateAccessToken",
"title": "AccessTokens_CreateOrReplace",
"operationId": "AccessTokens_CreateOrReplace",
"parameters": {
"api-version": "2023-10-01-preview",
"accountId": "sampleAccountId",
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000",
"accessTokenId": "00000000-0000-0000-0000-000000000000",
"resource": {
"id": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"title": "AccessTokens_Delete",
"operationId": "AccessTokens_Delete",
"parameters": {
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000",
"accessTokenId": "00000000-0000-0000-0000-000000000000"
},
"responses": {
"204": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"title": "AccessTokens_GetAccessToken",
"operationId": "AccessTokens_GetAccessToken",
"title": "AccessTokens_Get",
"operationId": "AccessTokens_Get",
"parameters": {
"api-version": "2023-10-01-preview",
"accountId": "sampleAccountId",
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000",
"accessTokenId": "00000000-0000-0000-0000-000000000000"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"title": "AccessTokens_ListAccessTokens",
"operationId": "AccessTokens_ListAccessTokens",
"title": "AccessTokens_List",
"operationId": "AccessTokens_List",
"parameters": {
"api-version": "2023-10-01-preview",
"accountId": "sampleAccountId"
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000"
},
"responses": {
"200": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"title": "Accounts_GetAccount",
"operationId": "Accounts_GetAccount",
"title": "Accounts_Get",
"operationId": "Accounts_Get",
"parameters": {
"api-version": "2023-10-01-preview",
"accountId": "sampleAccountId"
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000"
},
"responses": {
"200": {
"body": {
"id": "sampleAccountId",
"id": "sampleAccountId_00000000-0000-0000-0000-000000000000",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount",
"name": "myPlaywrightAccount",
"state": "Active",
Expand All @@ -18,7 +18,8 @@
"location": "westus",
"regionalAffinity": "Enabled",
"scalableExecution": "Enabled",
"reporting": "Disabled"
"reporting": "Disabled",
"localAuth": "Enabled"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Accounts_GetBrowsers",
"operationId": "Accounts_GetBrowsers",
"parameters": {
"api-version": "2024-12-01",
"accountId": "sampleAccountId_00000000-0000-0000-0000-000000000000",
"os": "linux"
},
"responses": {
"302": {
"headers": {
"location": "wss://{region}.api.playwright.microsoft.com/redirectURL?api-version=2024-12-01&os=linux"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,41 @@ import "@typespec/http";
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-autorest";

using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;
using Azure.Core.Traits;
using Autorest;

@server(
"https://api.playwright-int.io",
"Azure Playwright Service API Endpoint"
"{endpoint}",
"Microsoft Azure Playwright Service API Endpoint",
{
@doc("""
Supported Azure Playwright Service API Endpoints (protocol and hostname, for example:
https://{region}.api.playwright.microsoft.com).
""")
endpoint: string,
}
)
@useAuth(
[
OAuth2Auth<[
{
type: OAuth2FlowType.implicit,
description: "We can use OAuth2 Implicit flow to get the auth token for calling the APIs.",
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize",
scopes: ["https://preview.playwright-int.io/.default"],
scopes: ["https://playwright.microsoft.com/.default"],
}
]>,
OAuth2Auth<[
{
type: OAuth2FlowType.authorizationCode,
description: "We can use OAuth2 Authorization Code flow to get the auth token for calling the APIs.",
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize",
tokenUrl: "https://login.microsoftonline.com/common/v2.0/oauth2/token",
scopes: ["https://playwright.microsoft.com/.default"],
}
]>
]
Expand All @@ -37,22 +52,24 @@ namespace Microsoft.PlaywrightTesting.AuthManager;

@doc("The PlaywrightTesting Auth Manager service version.")
enum Versions {
@doc("Version 2023-10-01-preview")
@doc("Version 2024-12-01")
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
`2023-10-01-preview`,
`2024-12-01`,
}

// Models ////////////////////

@doc("An account is a parent resource for most of the other service resources. It's directly mapped to an ARM resource and helps to create a link between control-plane and data-plane resources.")
@doc("An account is a parent resource for most of the other service resources. It's directly mapped to an Azure resource.")
@resource("accounts")
model Account {
@key("accountId")
@doc("The account id.")
@maxLength(64)
@pattern("[A-Za-z0-9]+(_[A-Za-z0-9]+)*(-[A-Za-z0-9]+)+")
@visibility("read")
id: string;

@doc("The ARM fully-qualified resource id for the account.")
@doc("The fully-qualified Azure resource id for the account.")
@visibility("read")
resourceId: string;

Expand All @@ -64,19 +81,19 @@ model Account {
@visibility("read")
state: AccountState;

@doc("The ARM-based subscription id for the account.")
@doc("The Azure subscription id for the account.")
@visibility("read")
subscriptionId: uuid;

@doc("The ARM-based subscription state - Registered | Unregistered | Warned | Suspended | Deleted")
@doc("The Azure subscription state - Registered | Unregistered | Warned | Suspended | Deleted")
@visibility("read")
subscriptionState: SubscriptionState;

@doc("The Azure tenant id of the account.")
@visibility("read")
tenantId: uuid;

@doc("The account resource ARM location, for eg. eastus, southeastasia.")
@doc("The account resource location in Azure, for eg. eastus, southeastasia.")
@visibility("read")
location: string;

Expand All @@ -90,7 +107,11 @@ model Account {

@doc("When enabled, this feature allows the workspace to upload and display test results, including artifacts like traces and screenshots, in the Playwright portal. This enables faster and more efficient troubleshooting.")
@visibility("read")
reporting?: EnablementStatus = EnablementStatus.Disabled;
reporting?: EnablementStatus = EnablementStatus.Enabled;

@doc("When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations.")
@visibility("read")
localAuth?: EnablementStatus = EnablementStatus.Disabled;
Comment on lines 108 to +114
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Dec 23, 2024

Choose a reason for hiding this comment

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

Why there is a service-side default value (e.g. EnablementStatus.Disabled) to this already read-only property?
A server-side default value is used when user does not define the property in request (e.g. a PUT), and server choose the value. How does this work together with a property user cannot set?

And since the e.g. localAuth? is an optional property, what does it mean, when the response does not contain localAuth. Is it "disabled" or "enabled"?

}

@doc("The account state.")
Expand All @@ -104,7 +125,7 @@ union AccountState {
"Inactive",
}

@doc("The ARM-based subscription state.")
@doc("The Azure subscription state.")
union SubscriptionState {
string,

Expand All @@ -130,6 +151,8 @@ union SubscriptionState {
model AccessToken {
@key("accessTokenId")
@doc("The access-token id.")
@maxLength(64)
@pattern("[A-Za-z0-9]+(-[A-Za-z0-9]+)+")
@visibility("read")
id: uuid;

Expand All @@ -146,26 +169,26 @@ model AccessToken {

@doc("The access-token createdAt utcDateTime.")
@visibility("read")
createdAt?: utcDateTime;
createdAt: utcDateTime;

@doc("The access-token expiryAt utcDateTime.")
@visibility("read", "create")
expiryAt: utcDateTime;

@doc("The access-token state - Active | Expired.")
@visibility("read")
state?: AccessTokenState;
state: AccessTokenState;
}

@doc("The access-token state.")
union AccessTokenState {
string,

@doc("The access-token is Active.")
"Active",
Active: "Active",

@doc("The access-token is Expired.")
"Expired",
Expired: "Expired",
}

@doc("The enablement status of a feature.")
Expand All @@ -179,6 +202,17 @@ union EnablementStatus {
Disabled: "Disabled",
}

@doc("The os to configure for remote test runs.")
union OS {
string,

@doc("Linux OS.")
Linux: "linux",

@doc("Windows OS.")
Windows: "windows",
Comment on lines +209 to +213
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Dec 23, 2024

Choose a reason for hiding this comment

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

Not a blocker, but we'd expect the casing of enum values be consistent. Here is it lowercase/camelCase e.g. linux, and the enum value above is PascalCase e.g. Active. Any reason for this inconsistency?

}

// Operations ////////////////////

alias ServiceTraits = NoRepeatableRequests &
Expand All @@ -189,23 +223,54 @@ alias Operations = Azure.Core.ResourceOperations<ServiceTraits>;

interface AccessTokens {
// AccessToken Operations
@doc("Creates an access-token for the account with given access-token id. Authorization required is Bearer JWT Access token provided by EntraID.")
createOrReplace is Operations.ResourceCreateOrReplace<AccessToken>;

#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Existing name"
@doc("Creates an access-token with given access-token id in guid format.")
createAccessToken is Operations.ResourceCreateOrReplace<AccessToken>;
@doc("Gets an access-token for the account with given access-token id. Authorization required is Bearer JWT Access token provided by EntraID.")
get is Operations.ResourceRead<AccessToken>;

@doc("Get an access-token for given access-token id in guid format.")
getAccessToken is Operations.ResourceRead<AccessToken>;
@doc("Deletes an access-token for the account with given access-token id. Authorization required is Bearer JWT Access token provided by EntraID.")
delete is Operations.ResourceDelete<AccessToken>;

@doc("Revoke an access-token with given access-token id in guid format.")
deleteAccessToken is Operations.ResourceDelete<AccessToken>;

@doc("List access-tokens for a given accountId.")
listAccessTokens is Operations.ResourceList<AccessToken>;
@doc("Lists access-tokens for the given account id. It can use OData query params like $select, $filter, $orderby, $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. Authorization required is Bearer JWT Access token provided by EntraID.")
list is Operations.ResourceList<AccessToken>;
}

alias GetBrowsersParams = {
@query
@doc("The run id provided by client for corresponding remote test run.")
runId?: string;

@query
@doc("The os provided by client for remote test runs.")
os?: OS = OS.Linux;

@path
@doc("The account id.")
accountId: string;
Comment on lines +248 to +250

Choose a reason for hiding this comment

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

I am not sure how much it effects the Swagger or API. But I'd expect the most important parameter (I assume it be accountId) at the top.

};

alias GetBrowsersResponse = {
@statusCode
_: 302;

@header
@doc("The redirect target URL to run test on remote browsers.")
location: url;
};

interface Accounts {
// Accounts Operations
@doc("Get details of the ARM resource mapped to an account for the given accountId.")
getAccount is Operations.ResourceRead<Account>;

@doc("Get details of the Azure resource mapped to an account for the given account id. Authorization required is Bearer JWT Access token provided by EntraID.")
get is Operations.ResourceRead<Account>;

#suppress "@azure-tools/typespec-azure-core/no-rpc-path-params" "Operations defined using RpcOperation should not have path parameters. Consider using ResourceAction or ResourceCollectionAction instead."
@doc("Gets remote browsers corresponding to given account id and redirects the client for running Playwright tests. Authorization required is Bearer JWT Access token provided by EntraID or Microsoft Playwright Testing Service.")
@route("/accounts/{accountId}/browsers")
getBrowsers is RpcOperation<
GetBrowsersParams,
GetBrowsersResponse,
ServiceTraits
>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
emit:
- "@azure-tools/typespec-autorest"
linter:
extends:
- "@azure-tools/typespec-azure-rulesets/data-plane"
parameters:
"service-dir":
default: "sdk/playwrighttesting"
options:
"@azure-tools/typespec-autorest":
azure-resource-provider-folder: "data-plane"
emitter-output-dir: "{project-root}/.."
output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/playwrighttesting.json"
omit-unreachable-types: true
"@azure-tools/typespec-python":
package-dir: "azure-developer-microsoftplaywrighttesting"
package-name: "{package-dir}"
# emitter-output-dir: "{python-sdk-folder}/sdk/{service-directory-name}/{package-name}"
package-mode: azure-dataplane
flavor: azure
"@azure-tools/typespec-ts":
package-dir: "microsoft-playwright-testing-rest"
title: Microsoft Playwright Testing
description: Microsoft Playwright Testing Client
generateMetadata: true
generateTest: false
packageDetails:
name: "@azure-rest/microsoft-playwright-testing"
description: "This package contains Microsoft Playwright Testing client library."
version: 1.0.0
flavor: azure
"@azure-tools/typespec-csharp":
package-dir: "Azure.Developer.MicrosoftPlaywrightTesting"
clear-output-folder: true
model-namespace: false
namespace: "{package-dir}"
flavor: azure
"@azure-tools/typespec-java":
package-dir: "azure-developer-microsoftplaywrighttesting"
namespace: com.azure.developer.microsoftplaywrighttesting
partial-update: true
generate-tests: false
service-name: Microsoft Playwright Testing
flavor: azure
Loading
Loading