|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## LoadTests |
| 5 | + |
| 6 | +- [CreateOrUpdate](#loadtests_createorupdate) |
| 7 | +- [Delete](#loadtests_delete) |
| 8 | +- [GetByResourceGroup](#loadtests_getbyresourcegroup) |
| 9 | +- [List](#loadtests_list) |
| 10 | +- [ListByResourceGroup](#loadtests_listbyresourcegroup) |
| 11 | +- [Update](#loadtests_update) |
| 12 | + |
| 13 | +## Operations |
| 14 | + |
| 15 | +- [List](#operations_list) |
| 16 | +### LoadTests_CreateOrUpdate |
| 17 | + |
| 18 | +```java |
| 19 | +import java.util.HashMap; |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +/** Samples for LoadTests CreateOrUpdate. */ |
| 23 | +public final class LoadTestsCreateOrUpdateSamples { |
| 24 | + /* |
| 25 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_CreateOrUpdate.json |
| 26 | + */ |
| 27 | + /** |
| 28 | + * Sample code: LoadTests_CreateOrUpdate. |
| 29 | + * |
| 30 | + * @param manager Entry point to LoadTestManager. |
| 31 | + */ |
| 32 | + public static void loadTestsCreateOrUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 33 | + manager |
| 34 | + .loadTests() |
| 35 | + .define("myLoadTest") |
| 36 | + .withRegion("westus") |
| 37 | + .withExistingResourceGroup("dummyrg") |
| 38 | + .withTags(mapOf("Team", "Dev Exp")) |
| 39 | + .withDescription("This is new load test resource") |
| 40 | + .create(); |
| 41 | + } |
| 42 | + |
| 43 | + @SuppressWarnings("unchecked") |
| 44 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 45 | + Map<String, T> map = new HashMap<>(); |
| 46 | + for (int i = 0; i < inputs.length; i += 2) { |
| 47 | + String key = (String) inputs[i]; |
| 48 | + T value = (T) inputs[i + 1]; |
| 49 | + map.put(key, value); |
| 50 | + } |
| 51 | + return map; |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +### LoadTests_Delete |
| 57 | + |
| 58 | +```java |
| 59 | +import com.azure.core.util.Context; |
| 60 | + |
| 61 | +/** Samples for LoadTests Delete. */ |
| 62 | +public final class LoadTestsDeleteSamples { |
| 63 | + /* |
| 64 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Delete.json |
| 65 | + */ |
| 66 | + /** |
| 67 | + * Sample code: LoadTests_Delete. |
| 68 | + * |
| 69 | + * @param manager Entry point to LoadTestManager. |
| 70 | + */ |
| 71 | + public static void loadTestsDelete(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 72 | + manager.loadTests().delete("dummyrg", "myLoadTest", Context.NONE); |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### LoadTests_GetByResourceGroup |
| 78 | + |
| 79 | +```java |
| 80 | +import com.azure.core.util.Context; |
| 81 | + |
| 82 | +/** Samples for LoadTests GetByResourceGroup. */ |
| 83 | +public final class LoadTestsGetByResourceGroupSamples { |
| 84 | + /* |
| 85 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Get.json |
| 86 | + */ |
| 87 | + /** |
| 88 | + * Sample code: LoadTests_Get. |
| 89 | + * |
| 90 | + * @param manager Entry point to LoadTestManager. |
| 91 | + */ |
| 92 | + public static void loadTestsGet(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 93 | + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE); |
| 94 | + } |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +### LoadTests_List |
| 99 | + |
| 100 | +```java |
| 101 | +import com.azure.core.util.Context; |
| 102 | + |
| 103 | +/** Samples for LoadTests List. */ |
| 104 | +public final class LoadTestsListSamples { |
| 105 | + /* |
| 106 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListBySubscription.json |
| 107 | + */ |
| 108 | + /** |
| 109 | + * Sample code: LoadTests_ListBySubscription. |
| 110 | + * |
| 111 | + * @param manager Entry point to LoadTestManager. |
| 112 | + */ |
| 113 | + public static void loadTestsListBySubscription(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 114 | + manager.loadTests().list(Context.NONE); |
| 115 | + } |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### LoadTests_ListByResourceGroup |
| 120 | + |
| 121 | +```java |
| 122 | +import com.azure.core.util.Context; |
| 123 | + |
| 124 | +/** Samples for LoadTests ListByResourceGroup. */ |
| 125 | +public final class LoadTestsListByResourceGroupSamples { |
| 126 | + /* |
| 127 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListByResourceGroup.json |
| 128 | + */ |
| 129 | + /** |
| 130 | + * Sample code: LoadTests_ListByResourceGroup. |
| 131 | + * |
| 132 | + * @param manager Entry point to LoadTestManager. |
| 133 | + */ |
| 134 | + public static void loadTestsListByResourceGroup(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 135 | + manager.loadTests().listByResourceGroup("dummyrg", Context.NONE); |
| 136 | + } |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +### LoadTests_Update |
| 141 | + |
| 142 | +```java |
| 143 | +import com.azure.core.management.serializer.SerializerFactory; |
| 144 | +import com.azure.core.util.Context; |
| 145 | +import com.azure.core.util.serializer.SerializerEncoding; |
| 146 | +import com.azure.resourcemanager.loadtestservice.models.LoadTestResource; |
| 147 | +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBodyProperties; |
| 148 | +import java.io.IOException; |
| 149 | + |
| 150 | +/** Samples for LoadTests Update. */ |
| 151 | +public final class LoadTestsUpdateSamples { |
| 152 | + /* |
| 153 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Update.json |
| 154 | + */ |
| 155 | + /** |
| 156 | + * Sample code: LoadTests_Update. |
| 157 | + * |
| 158 | + * @param manager Entry point to LoadTestManager. |
| 159 | + */ |
| 160 | + public static void loadTestsUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) |
| 161 | + throws IOException { |
| 162 | + LoadTestResource resource = |
| 163 | + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE).getValue(); |
| 164 | + resource |
| 165 | + .update() |
| 166 | + .withTags( |
| 167 | + SerializerFactory |
| 168 | + .createDefaultManagementSerializerAdapter() |
| 169 | + .deserialize("{\"Division\":\"LT\",\"Team\":\"Dev Exp\"}", Object.class, SerializerEncoding.JSON)) |
| 170 | + .withProperties( |
| 171 | + new LoadTestResourcePatchRequestBodyProperties().withDescription("This is new load test resource")) |
| 172 | + .apply(); |
| 173 | + } |
| 174 | +} |
| 175 | +``` |
| 176 | + |
| 177 | +### Operations_List |
| 178 | + |
| 179 | +```java |
| 180 | +import com.azure.core.util.Context; |
| 181 | + |
| 182 | +/** Samples for Operations List. */ |
| 183 | +public final class OperationsListSamples { |
| 184 | + /* |
| 185 | + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/Operations_List.json |
| 186 | + */ |
| 187 | + /** |
| 188 | + * Sample code: Operations_List. |
| 189 | + * |
| 190 | + * @param manager Entry point to LoadTestManager. |
| 191 | + */ |
| 192 | + public static void operationsList(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { |
| 193 | + manager.operations().list(Context.NONE); |
| 194 | + } |
| 195 | +} |
| 196 | +``` |
| 197 | + |
0 commit comments