Skip to content

Commit 0433add

Browse files
authored
PlaywrightTesting -Bringing common model in shared namespace (Azure#32019)
* Created PlaywrightTesting.Shared namespace * tsp format fixed
1 parent 9be3ccf commit 0433add

File tree

5 files changed

+223
-190
lines changed

5 files changed

+223
-190
lines changed

cSpell.json

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
"typescript"
5151
],
5252
"overrides": [
53+
{
54+
"filename": "**/specification/playwrighttesting/**/*",
55+
"words": [
56+
"microsoftplaywrighttesting",
57+
"playwrighttesting",
58+
]
59+
},
5360
{
5461
"filename": "**/specification/azurearcdata/resource-manager/Microsoft.AzureArcData/**/*.json",
5562
"words": [

specification/playwrighttesting/PlaywrightTesting.AuthManager/main.tsp

+3-97
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import "@typespec/http";
55
import "@typespec/rest";
66
import "@typespec/versioning";
77
import "@azure-tools/typespec-azure-core";
8+
import "../PlaywrightTesting.Shared";
89

910
using TypeSpec.Http;
1011
using TypeSpec.Rest;
1112
using TypeSpec.Versioning;
1213
using Azure.Core;
1314
using Azure.Core.Traits;
15+
using Microsoft.PlaywrightTesting.Shared;
1416

1517
@server(
1618
"{endpoint}",
@@ -54,97 +56,12 @@ namespace Microsoft.PlaywrightTesting.AuthManager;
5456
enum Versions {
5557
@doc("Version 2024-12-01")
5658
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
59+
@useDependency(Microsoft.PlaywrightTesting.Shared.Versions.v1_0)
5760
`2024-12-01`,
5861
}
5962

6063
// Models ////////////////////
6164

62-
@doc("An account is a parent resource for most of the other service resources. It's directly mapped to an Azure resource.")
63-
@resource("accounts")
64-
model Account {
65-
@key("accountId")
66-
@doc("The account id.")
67-
@maxLength(64)
68-
@pattern("[A-Za-z0-9]+(_[A-Za-z0-9]+)*(-[A-Za-z0-9]+)+")
69-
@visibility("read")
70-
id: string;
71-
72-
@doc("The fully-qualified Azure resource id for the account.")
73-
@visibility("read")
74-
resourceId: string;
75-
76-
@doc("The account name.")
77-
@visibility("read")
78-
name: string;
79-
80-
@doc("The state of account - Active | Inactive")
81-
@visibility("read")
82-
state: AccountState;
83-
84-
@doc("The Azure subscription id for the account.")
85-
@visibility("read")
86-
subscriptionId: uuid;
87-
88-
@doc("The Azure subscription state - Registered | Unregistered | Warned | Suspended | Deleted")
89-
@visibility("read")
90-
subscriptionState: SubscriptionState;
91-
92-
@doc("The Azure tenant id of the account.")
93-
@visibility("read")
94-
tenantId: uuid;
95-
96-
@doc("The account resource location in Azure, for eg. eastus, southeastasia.")
97-
@visibility("read")
98-
location: string;
99-
100-
@doc("This property sets the connection region for Playwright client workers to cloud-hosted browsers. If enabled, workers connect to browsers in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which the workspace was initially created.")
101-
@visibility("read")
102-
regionalAffinity?: EnablementStatus = EnablementStatus.Enabled;
103-
104-
@doc("When enabled, Playwright client workers can connect to cloud-hosted browsers. This can increase the number of parallel workers for a test run, significantly minimizing test completion durations.")
105-
@visibility("read")
106-
scalableExecution?: EnablementStatus = EnablementStatus.Enabled;
107-
108-
@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.")
109-
@visibility("read")
110-
reporting?: EnablementStatus = EnablementStatus.Enabled;
111-
112-
@doc("When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations.")
113-
@visibility("read")
114-
localAuth?: EnablementStatus = EnablementStatus.Disabled;
115-
}
116-
117-
@doc("The account state.")
118-
union AccountState {
119-
string,
120-
121-
@doc("The account is Active.")
122-
"Active",
123-
124-
@doc("The account is Inactive.")
125-
"Inactive",
126-
}
127-
128-
@doc("The Azure subscription state.")
129-
union SubscriptionState {
130-
string,
131-
132-
@doc("The subscription state is Registered.")
133-
"Registered",
134-
135-
@doc("The subscription state is Warned.")
136-
"Warned",
137-
138-
@doc("The subscription state is Suspended.")
139-
"Suspended",
140-
141-
@doc("The subscription state is Deleted.")
142-
"Deleted",
143-
144-
@doc("The subscription state is Unregistered.")
145-
"Unregistered",
146-
}
147-
14865
@doc("Model of an access-token linked to an account.")
14966
@resource("access-tokens")
15067
@parentResource(Account)
@@ -191,17 +108,6 @@ union AccessTokenState {
191108
Expired: "Expired",
192109
}
193110

194-
@doc("The enablement status of a feature.")
195-
union EnablementStatus {
196-
string,
197-
198-
@doc("The feature is Enabled.")
199-
Enabled: "Enabled",
200-
201-
@doc("The feature is Disabled.")
202-
Disabled: "Disabled",
203-
}
204-
205111
@doc("The os to configure for remote test runs.")
206112
union OS {
207113
string,

specification/playwrighttesting/PlaywrightTesting.AuthManager/tspconfig.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ linter:
66
parameters:
77
"service-dir":
88
default: "sdk/playwrighttesting"
9+
"dependencies":
10+
"additionalDirectories":
11+
- "specification/playwrighttesting/PlaywrightTesting.Shared/"
12+
default: ""
913
options:
1014
"@azure-tools/typespec-autorest":
1115
azure-resource-provider-folder: "data-plane"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// cheat-sheet - https://microsoft.github.io/typespec/standard-library/http/cheat-sheet
2+
// tsp compile main.tsp --emit @azure-tools/typespec-autorest
3+
4+
import "@typespec/versioning";
5+
import "@azure-tools/typespec-azure-core";
6+
7+
using TypeSpec.Versioning;
8+
using TypeSpec.Rest;
9+
using Azure.Core;
10+
11+
@versioned(Microsoft.PlaywrightTesting.Shared.Versions)
12+
namespace Microsoft.PlaywrightTesting.Shared;
13+
14+
@doc("The PlaywrightTesting Accounts Model Version.")
15+
enum Versions {
16+
@doc("Version 1.0")
17+
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
18+
v1_0,
19+
}
20+
21+
@doc("An account is a parent resource for most of the other service resources. It's directly mapped to an Azure resource.")
22+
@resource("accounts")
23+
model Account {
24+
@key("accountId")
25+
@doc("The account id.")
26+
@maxLength(64)
27+
@pattern("[A-Za-z0-9]+(_[A-Za-z0-9]+)*(-[A-Za-z0-9]+)+")
28+
@visibility("read")
29+
id: string;
30+
31+
@doc("The fully-qualified Azure resource id for the account.")
32+
@visibility("read")
33+
resourceId: string;
34+
35+
@doc("The account name.")
36+
@visibility("read")
37+
name: string;
38+
39+
@doc("The state of account - Active | Inactive")
40+
@visibility("read")
41+
state: AccountState;
42+
43+
@doc("The Azure subscription id for the account.")
44+
@visibility("read")
45+
subscriptionId: uuid;
46+
47+
@doc("The Azure subscription state - Registered | Unregistered | Warned | Suspended | Deleted")
48+
@visibility("read")
49+
subscriptionState: SubscriptionState;
50+
51+
@doc("The Azure tenant id of the account.")
52+
@visibility("read")
53+
tenantId: uuid;
54+
55+
@doc("The account resource location in Azure, for eg. eastus, southeastasia.")
56+
@visibility("read")
57+
location: string;
58+
59+
@doc("This property sets the connection region for Playwright client workers to cloud-hosted browsers. If enabled, workers connect to browsers in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which the workspace was initially created.")
60+
@visibility("read")
61+
regionalAffinity?: EnablementStatus = EnablementStatus.Enabled;
62+
63+
@doc("When enabled, Playwright client workers can connect to cloud-hosted browsers. This can increase the number of parallel workers for a test run, significantly minimizing test completion durations.")
64+
@visibility("read")
65+
scalableExecution?: EnablementStatus = EnablementStatus.Enabled;
66+
67+
@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.")
68+
@visibility("read")
69+
reporting?: EnablementStatus = EnablementStatus.Enabled;
70+
71+
@doc("When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations.")
72+
@visibility("read")
73+
localAuth?: EnablementStatus = EnablementStatus.Disabled;
74+
}
75+
76+
@doc("The account state.")
77+
union AccountState {
78+
string,
79+
80+
@doc("The account is Active.")
81+
"Active",
82+
83+
@doc("The account is Inactive.")
84+
"Inactive",
85+
}
86+
87+
@doc("The Azure subscription state.")
88+
union SubscriptionState {
89+
string,
90+
91+
@doc("The subscription state is Registered.")
92+
"Registered",
93+
94+
@doc("The subscription state is Warned.")
95+
"Warned",
96+
97+
@doc("The subscription state is Suspended.")
98+
"Suspended",
99+
100+
@doc("The subscription state is Deleted.")
101+
"Deleted",
102+
103+
@doc("The subscription state is Unregistered.")
104+
"Unregistered",
105+
}
106+
107+
@doc("The enablement status of a feature.")
108+
union EnablementStatus {
109+
string,
110+
111+
@doc("The feature is Enabled.")
112+
Enabled: "Enabled",
113+
114+
@doc("The feature is Disabled.")
115+
Disabled: "Disabled",
116+
}

0 commit comments

Comments
 (0)