|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## Extensions |
| 5 | + |
| 6 | +- [Create](#extensions_create) |
| 7 | +- [Delete](#extensions_delete) |
| 8 | +- [Get](#extensions_get) |
| 9 | +- [List](#extensions_list) |
| 10 | +- [Update](#extensions_update) |
| 11 | + |
| 12 | +## OperationStatus |
| 13 | + |
| 14 | +- [Get](#operationstatus_get) |
| 15 | +### Extensions_Create |
| 16 | + |
| 17 | +```java |
| 18 | +import com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.fluent.models.ExtensionInner; |
| 19 | +import com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.models.Plan; |
| 20 | +import com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.models.Scope; |
| 21 | +import com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.models.ScopeCluster; |
| 22 | +import java.util.HashMap; |
| 23 | +import java.util.Map; |
| 24 | + |
| 25 | +/** |
| 26 | + * Samples for Extensions Create. |
| 27 | + */ |
| 28 | +public final class ExtensionsCreateSamples { |
| 29 | + /* |
| 30 | + * x-ms-original-file: |
| 31 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 32 | + * 11-01/examples/CreateExtension.json |
| 33 | + */ |
| 34 | + /** |
| 35 | + * Sample code: Create Extension. |
| 36 | + * |
| 37 | + * @param manager Entry point to ExtensionsManager. |
| 38 | + */ |
| 39 | + public static void createExtension( |
| 40 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 41 | + manager.extensions() |
| 42 | + .create("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "ClusterMonitor", |
| 43 | + new ExtensionInner().withExtensionType("azuremonitor-containers") |
| 44 | + .withAutoUpgradeMinorVersion(true) |
| 45 | + .withReleaseTrain("Preview") |
| 46 | + .withScope(new Scope().withCluster(new ScopeCluster().withReleaseNamespace("kube-system"))) |
| 47 | + .withConfigurationSettings(mapOf("omsagent.env.clusterName", "clusterName1", "omsagent.secret.wsid", |
| 48 | + "fakeTokenPlaceholder")) |
| 49 | + .withConfigurationProtectedSettings(mapOf("omsagent.secret.key", "fakeTokenPlaceholder")), |
| 50 | + com.azure.core.util.Context.NONE); |
| 51 | + } |
| 52 | + |
| 53 | + /* |
| 54 | + * x-ms-original-file: |
| 55 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 56 | + * 11-01/examples/CreateExtensionWithPlan.json |
| 57 | + */ |
| 58 | + /** |
| 59 | + * Sample code: Create Extension with Plan. |
| 60 | + * |
| 61 | + * @param manager Entry point to ExtensionsManager. |
| 62 | + */ |
| 63 | + public static void createExtensionWithPlan( |
| 64 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 65 | + manager.extensions() |
| 66 | + .create("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "azureVote", |
| 67 | + new ExtensionInner() |
| 68 | + .withPlan(new Plan().withName("azure-vote-standard") |
| 69 | + .withPublisher("Microsoft") |
| 70 | + .withProduct("azure-vote-standard-offer-id")) |
| 71 | + .withExtensionType("azure-vote") |
| 72 | + .withAutoUpgradeMinorVersion(true) |
| 73 | + .withReleaseTrain("Preview"), |
| 74 | + com.azure.core.util.Context.NONE); |
| 75 | + } |
| 76 | + |
| 77 | + // Use "Map.of" if available |
| 78 | + @SuppressWarnings("unchecked") |
| 79 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 80 | + Map<String, T> map = new HashMap<>(); |
| 81 | + for (int i = 0; i < inputs.length; i += 2) { |
| 82 | + String key = (String) inputs[i]; |
| 83 | + T value = (T) inputs[i + 1]; |
| 84 | + map.put(key, value); |
| 85 | + } |
| 86 | + return map; |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +### Extensions_Delete |
| 92 | + |
| 93 | +```java |
| 94 | +/** |
| 95 | + * Samples for Extensions Delete. |
| 96 | + */ |
| 97 | +public final class ExtensionsDeleteSamples { |
| 98 | + /* |
| 99 | + * x-ms-original-file: |
| 100 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 101 | + * 11-01/examples/DeleteExtension.json |
| 102 | + */ |
| 103 | + /** |
| 104 | + * Sample code: Delete Extension. |
| 105 | + * |
| 106 | + * @param manager Entry point to ExtensionsManager. |
| 107 | + */ |
| 108 | + public static void deleteExtension( |
| 109 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 110 | + manager.extensions() |
| 111 | + .delete("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "ClusterMonitor", null, |
| 112 | + com.azure.core.util.Context.NONE); |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +### Extensions_Get |
| 118 | + |
| 119 | +```java |
| 120 | +/** |
| 121 | + * Samples for Extensions Get. |
| 122 | + */ |
| 123 | +public final class ExtensionsGetSamples { |
| 124 | + /* |
| 125 | + * x-ms-original-file: |
| 126 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 127 | + * 11-01/examples/GetExtensionWithPlan.json |
| 128 | + */ |
| 129 | + /** |
| 130 | + * Sample code: Get Extension with Plan. |
| 131 | + * |
| 132 | + * @param manager Entry point to ExtensionsManager. |
| 133 | + */ |
| 134 | + public static void getExtensionWithPlan( |
| 135 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 136 | + manager.extensions() |
| 137 | + .getWithResponse("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "azureVote", |
| 138 | + com.azure.core.util.Context.NONE); |
| 139 | + } |
| 140 | + |
| 141 | + /* |
| 142 | + * x-ms-original-file: |
| 143 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 144 | + * 11-01/examples/GetExtension.json |
| 145 | + */ |
| 146 | + /** |
| 147 | + * Sample code: Get Extension. |
| 148 | + * |
| 149 | + * @param manager Entry point to ExtensionsManager. |
| 150 | + */ |
| 151 | + public static void getExtension( |
| 152 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 153 | + manager.extensions() |
| 154 | + .getWithResponse("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "ClusterMonitor", |
| 155 | + com.azure.core.util.Context.NONE); |
| 156 | + } |
| 157 | +} |
| 158 | +``` |
| 159 | + |
| 160 | +### Extensions_List |
| 161 | + |
| 162 | +```java |
| 163 | +/** |
| 164 | + * Samples for Extensions List. |
| 165 | + */ |
| 166 | +public final class ExtensionsListSamples { |
| 167 | + /* |
| 168 | + * x-ms-original-file: |
| 169 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 170 | + * 11-01/examples/ListExtensions.json |
| 171 | + */ |
| 172 | + /** |
| 173 | + * Sample code: List Extensions. |
| 174 | + * |
| 175 | + * @param manager Entry point to ExtensionsManager. |
| 176 | + */ |
| 177 | + public static void listExtensions( |
| 178 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 179 | + manager.extensions() |
| 180 | + .list("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", com.azure.core.util.Context.NONE); |
| 181 | + } |
| 182 | +} |
| 183 | +``` |
| 184 | + |
| 185 | +### Extensions_Update |
| 186 | + |
| 187 | +```java |
| 188 | +import com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.models.PatchExtension; |
| 189 | +import java.util.HashMap; |
| 190 | +import java.util.Map; |
| 191 | + |
| 192 | +/** |
| 193 | + * Samples for Extensions Update. |
| 194 | + */ |
| 195 | +public final class ExtensionsUpdateSamples { |
| 196 | + /* |
| 197 | + * x-ms-original-file: |
| 198 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 199 | + * 11-01/examples/PatchExtension.json |
| 200 | + */ |
| 201 | + /** |
| 202 | + * Sample code: Update Extension. |
| 203 | + * |
| 204 | + * @param manager Entry point to ExtensionsManager. |
| 205 | + */ |
| 206 | + public static void updateExtension( |
| 207 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 208 | + manager.extensions() |
| 209 | + .update("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "ClusterMonitor", |
| 210 | + new PatchExtension().withAutoUpgradeMinorVersion(true) |
| 211 | + .withReleaseTrain("Preview") |
| 212 | + .withConfigurationSettings(mapOf("omsagent.env.clusterName", "clusterName1", "omsagent.secret.wsid", |
| 213 | + "fakeTokenPlaceholder")) |
| 214 | + .withConfigurationProtectedSettings(mapOf("omsagent.secret.key", "fakeTokenPlaceholder")), |
| 215 | + com.azure.core.util.Context.NONE); |
| 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 | + |
| 232 | +### OperationStatus_Get |
| 233 | + |
| 234 | +```java |
| 235 | +/** |
| 236 | + * Samples for OperationStatus Get. |
| 237 | + */ |
| 238 | +public final class OperationStatusGetSamples { |
| 239 | + /* |
| 240 | + * x-ms-original-file: |
| 241 | + * specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/stable/2024- |
| 242 | + * 11-01/examples/GetExtensionAsyncOperationStatus.json |
| 243 | + */ |
| 244 | + /** |
| 245 | + * Sample code: ExtensionAsyncOperationStatus Get. |
| 246 | + * |
| 247 | + * @param manager Entry point to ExtensionsManager. |
| 248 | + */ |
| 249 | + public static void extensionAsyncOperationStatusGet( |
| 250 | + com.azure.resourcemanager.kubernetesconfigurationmicrosoftkubernetesconfigurationextensions.ExtensionsManager manager) { |
| 251 | + manager.operationStatus() |
| 252 | + .getWithResponse("rg1", "Microsoft.Kubernetes", "connectedClusters", "clusterName1", "ClusterMonitor", |
| 253 | + "99999999-9999-9999-9999-999999999999", com.azure.core.util.Context.NONE); |
| 254 | + } |
| 255 | +} |
| 256 | +``` |
| 257 | + |
0 commit comments