|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## PlaywrightWorkspaces |
| 5 | + |
| 6 | +- [CheckNameAvailability](#playwrightworkspaces_checknameavailability) |
| 7 | +- [CreateOrUpdate](#playwrightworkspaces_createorupdate) |
| 8 | +- [Delete](#playwrightworkspaces_delete) |
| 9 | +- [GetByResourceGroup](#playwrightworkspaces_getbyresourcegroup) |
| 10 | +- [List](#playwrightworkspaces_list) |
| 11 | +- [ListByResourceGroup](#playwrightworkspaces_listbyresourcegroup) |
| 12 | +- [Update](#playwrightworkspaces_update) |
| 13 | +### PlaywrightWorkspaces_CheckNameAvailability |
| 14 | + |
| 15 | +```java |
| 16 | +import com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.models.EnablementStatus; |
| 17 | +import com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.models.PlaywrightWorkspace; |
| 18 | +import java.util.HashMap; |
| 19 | +import java.util.Map; |
| 20 | + |
| 21 | +/** |
| 22 | + * Samples for PlaywrightWorkspaces Update. |
| 23 | + */ |
| 24 | +public final class PlaywrightWorkspacesUpdateSamples { |
| 25 | + /* |
| 26 | + * x-ms-original-file: |
| 27 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 28 | + * examples/PlaywrightWorkspaces_Update.json |
| 29 | + */ |
| 30 | + /** |
| 31 | + * Sample code: PlaywrightWorkspaces_Update. |
| 32 | + * |
| 33 | + * @param manager Entry point to PlaywrightServiceManager. |
| 34 | + */ |
| 35 | + public static void playwrightWorkspacesUpdate( |
| 36 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 37 | + PlaywrightWorkspace resource = manager.playwrightWorkspaces() |
| 38 | + .getByResourceGroupWithResponse("dummyrg", "myWorkspace", com.azure.core.util.Context.NONE) |
| 39 | + .getValue(); |
| 40 | + resource.update() |
| 41 | + .withTags(mapOf("Division", "LT", "Team", "Dev Exp")) |
| 42 | + .withRegionalAffinity(EnablementStatus.DISABLED) |
| 43 | + .apply(); |
| 44 | + } |
| 45 | + |
| 46 | + // Use "Map.of" if available |
| 47 | + @SuppressWarnings("unchecked") |
| 48 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 49 | + Map<String, T> map = new HashMap<>(); |
| 50 | + for (int i = 0; i < inputs.length; i += 2) { |
| 51 | + String key = (String) inputs[i]; |
| 52 | + T value = (T) inputs[i + 1]; |
| 53 | + map.put(key, value); |
| 54 | + } |
| 55 | + return map; |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +### PlaywrightWorkspaces_CreateOrUpdate |
| 61 | + |
| 62 | +```java |
| 63 | +import com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.models.CheckNameAvailabilityRequest; |
| 64 | + |
| 65 | +/** |
| 66 | + * Samples for PlaywrightWorkspaces CheckNameAvailability. |
| 67 | + */ |
| 68 | +public final class PlaywrightWorkspacesCheckNameAvailabilitySamples { |
| 69 | + /* |
| 70 | + * x-ms-original-file: |
| 71 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 72 | + * examples/PlaywrightWorkspaces_CheckNameAvailability.json |
| 73 | + */ |
| 74 | + /** |
| 75 | + * Sample code: PlaywrightWorkspaces_CheckNameAvailability. |
| 76 | + * |
| 77 | + * @param manager Entry point to PlaywrightServiceManager. |
| 78 | + */ |
| 79 | + public static void playwrightWorkspacesCheckNameAvailability( |
| 80 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 81 | + manager.playwrightWorkspaces() |
| 82 | + .checkNameAvailabilityWithResponse(new CheckNameAvailabilityRequest().withName("dummyName") |
| 83 | + .withType("Microsoft.LoadTestService/PlaywrightWorkspaces"), com.azure.core.util.Context.NONE); |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +### PlaywrightWorkspaces_Delete |
| 89 | + |
| 90 | +```java |
| 91 | +/** |
| 92 | + * Samples for PlaywrightWorkspaces GetByResourceGroup. |
| 93 | + */ |
| 94 | +public final class PlaywrightWorkspacesGetByResourceGroupSamples { |
| 95 | + /* |
| 96 | + * x-ms-original-file: |
| 97 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 98 | + * examples/PlaywrightWorkspaces_Get.json |
| 99 | + */ |
| 100 | + /** |
| 101 | + * Sample code: PlaywrightWorkspaces_Get. |
| 102 | + * |
| 103 | + * @param manager Entry point to PlaywrightServiceManager. |
| 104 | + */ |
| 105 | + public static void playwrightWorkspacesGet( |
| 106 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 107 | + manager.playwrightWorkspaces() |
| 108 | + .getByResourceGroupWithResponse("dummyrg", "myWorkspace", com.azure.core.util.Context.NONE); |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +### PlaywrightWorkspaces_GetByResourceGroup |
| 114 | + |
| 115 | +```java |
| 116 | +/** |
| 117 | + * Samples for PlaywrightWorkspaces Delete. |
| 118 | + */ |
| 119 | +public final class PlaywrightWorkspacesDeleteSamples { |
| 120 | + /* |
| 121 | + * x-ms-original-file: |
| 122 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 123 | + * examples/PlaywrightWorkspaces_Delete.json |
| 124 | + */ |
| 125 | + /** |
| 126 | + * Sample code: PlaywrightWorkspaces_Delete. |
| 127 | + * |
| 128 | + * @param manager Entry point to PlaywrightServiceManager. |
| 129 | + */ |
| 130 | + public static void playwrightWorkspacesDelete( |
| 131 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 132 | + manager.playwrightWorkspaces().delete("dummyrg", "myWorkspace", com.azure.core.util.Context.NONE); |
| 133 | + } |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### PlaywrightWorkspaces_List |
| 138 | + |
| 139 | +```java |
| 140 | +/** |
| 141 | + * Samples for PlaywrightWorkspaces List. |
| 142 | + */ |
| 143 | +public final class PlaywrightWorkspacesListSamples { |
| 144 | + /* |
| 145 | + * x-ms-original-file: |
| 146 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 147 | + * examples/PlaywrightWorkspaces_ListBySubscription.json |
| 148 | + */ |
| 149 | + /** |
| 150 | + * Sample code: PlaywrightWorkspaces_ListBySubscription. |
| 151 | + * |
| 152 | + * @param manager Entry point to PlaywrightServiceManager. |
| 153 | + */ |
| 154 | + public static void playwrightWorkspacesListBySubscription( |
| 155 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 156 | + manager.playwrightWorkspaces().list(com.azure.core.util.Context.NONE); |
| 157 | + } |
| 158 | +} |
| 159 | +``` |
| 160 | + |
| 161 | +### PlaywrightWorkspaces_ListByResourceGroup |
| 162 | + |
| 163 | +```java |
| 164 | +/** |
| 165 | + * Samples for PlaywrightWorkspaces ListByResourceGroup. |
| 166 | + */ |
| 167 | +public final class PlaywrightWorkspacesListByResourceGroupSamples { |
| 168 | + /* |
| 169 | + * x-ms-original-file: |
| 170 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 171 | + * examples/PlaywrightWorkspaces_ListByResourceGroup.json |
| 172 | + */ |
| 173 | + /** |
| 174 | + * Sample code: PlaywrightWorkspaces_ListByResourceGroup. |
| 175 | + * |
| 176 | + * @param manager Entry point to PlaywrightServiceManager. |
| 177 | + */ |
| 178 | + public static void playwrightWorkspacesListByResourceGroup( |
| 179 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 180 | + manager.playwrightWorkspaces().listByResourceGroup("dummyrg", com.azure.core.util.Context.NONE); |
| 181 | + } |
| 182 | +} |
| 183 | +``` |
| 184 | + |
| 185 | +### PlaywrightWorkspaces_Update |
| 186 | + |
| 187 | +```java |
| 188 | +import com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.models.EnablementStatus; |
| 189 | +import java.util.HashMap; |
| 190 | +import java.util.Map; |
| 191 | + |
| 192 | +/** |
| 193 | + * Samples for PlaywrightWorkspaces CreateOrUpdate. |
| 194 | + */ |
| 195 | +public final class PlaywrightWorkspacesCreateOrUpdateSamples { |
| 196 | + /* |
| 197 | + * x-ms-original-file: |
| 198 | + * specification/loadtestservice/resource-manager/Microsoft.LoadTestService/playwright/preview/2025-07-01-preview/ |
| 199 | + * examples/PlaywrightWorkspaces_CreateOrUpdate.json |
| 200 | + */ |
| 201 | + /** |
| 202 | + * Sample code: PlaywrightWorkspaces_CreateOrUpdate. |
| 203 | + * |
| 204 | + * @param manager Entry point to PlaywrightServiceManager. |
| 205 | + */ |
| 206 | + public static void playwrightWorkspacesCreateOrUpdate( |
| 207 | + com.azure.resourcemanager.loadtestservicemicrosoftloadtestserviceplaywright.PlaywrightServiceManager manager) { |
| 208 | + manager.playwrightWorkspaces() |
| 209 | + .define("myWorkspace") |
| 210 | + .withRegion("westus3") |
| 211 | + .withExistingResourceGroup("dummyrg") |
| 212 | + .withTags(mapOf("Team", "Dev Exp")) |
| 213 | + .withRegionalAffinity(EnablementStatus.ENABLED) |
| 214 | + .withLocalAuth(EnablementStatus.ENABLED) |
| 215 | + .create(); |
| 216 | + } |
| 217 | + |
| 218 | + // Use "Map.of" if available |
| 219 | + @SuppressWarnings("unchecked") |
| 220 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 221 | + Map<String, T> map = new HashMap<>(); |
| 222 | + for (int i = 0; i < inputs.length; i += 2) { |
| 223 | + String key = (String) inputs[i]; |
| 224 | + T value = (T) inputs[i + 1]; |
| 225 | + map.put(key, value); |
| 226 | + } |
| 227 | + return map; |
| 228 | + } |
| 229 | +} |
| 230 | +``` |
| 231 | + |
0 commit comments