|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## Appliances |
| 5 | + |
| 6 | +- [CreateOrUpdate](#appliances_createorupdate) |
| 7 | +- [Delete](#appliances_delete) |
| 8 | +- [GetByResourceGroup](#appliances_getbyresourcegroup) |
| 9 | +- [List](#appliances_list) |
| 10 | +- [ListByResourceGroup](#appliances_listbyresourcegroup) |
| 11 | +- [ListClusterUserCredential](#appliances_listclusterusercredential) |
| 12 | +- [ListOperations](#appliances_listoperations) |
| 13 | +- [Update](#appliances_update) |
| 14 | +### Appliances_CreateOrUpdate |
| 15 | + |
| 16 | +```java |
| 17 | +import com.azure.resourcemanager.resourceconnector.models.AppliancePropertiesInfrastructureConfig; |
| 18 | +import com.azure.resourcemanager.resourceconnector.models.Distro; |
| 19 | +import com.azure.resourcemanager.resourceconnector.models.Provider; |
| 20 | + |
| 21 | +/** Samples for Appliances CreateOrUpdate. */ |
| 22 | +public final class AppliancesCreateOrUpdateSamples { |
| 23 | + /* |
| 24 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesCreate_Update.json |
| 25 | + */ |
| 26 | + /** |
| 27 | + * Sample code: Create/Update Appliance. |
| 28 | + * |
| 29 | + * @param manager Entry point to AppliancesManager. |
| 30 | + */ |
| 31 | + public static void createUpdateAppliance(com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 32 | + manager |
| 33 | + .appliances() |
| 34 | + .define("appliance01") |
| 35 | + .withRegion("West US") |
| 36 | + .withExistingResourceGroup("testresourcegroup") |
| 37 | + .withDistro(Distro.AKSEDGE) |
| 38 | + .withInfrastructureConfig(new AppliancePropertiesInfrastructureConfig().withProvider(Provider.VMWARE)) |
| 39 | + .create(); |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +### Appliances_Delete |
| 45 | + |
| 46 | +```java |
| 47 | +import com.azure.core.util.Context; |
| 48 | + |
| 49 | +/** Samples for Appliances Delete. */ |
| 50 | +public final class AppliancesDeleteSamples { |
| 51 | + /* |
| 52 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesDelete.json |
| 53 | + */ |
| 54 | + /** |
| 55 | + * Sample code: Delete Appliance. |
| 56 | + * |
| 57 | + * @param manager Entry point to AppliancesManager. |
| 58 | + */ |
| 59 | + public static void deleteAppliance(com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 60 | + manager.appliances().delete("testresourcegroup", "appliance01", Context.NONE); |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +### Appliances_GetByResourceGroup |
| 66 | + |
| 67 | +```java |
| 68 | +import com.azure.core.util.Context; |
| 69 | + |
| 70 | +/** Samples for Appliances GetByResourceGroup. */ |
| 71 | +public final class AppliancesGetByResourceGroupSamples { |
| 72 | + /* |
| 73 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesGet.json |
| 74 | + */ |
| 75 | + /** |
| 76 | + * Sample code: Get Appliance. |
| 77 | + * |
| 78 | + * @param manager Entry point to AppliancesManager. |
| 79 | + */ |
| 80 | + public static void getAppliance(com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 81 | + manager.appliances().getByResourceGroupWithResponse("testresourcegroup", "appliance01", Context.NONE); |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +### Appliances_List |
| 87 | + |
| 88 | +```java |
| 89 | +import com.azure.core.util.Context; |
| 90 | + |
| 91 | +/** Samples for Appliances List. */ |
| 92 | +public final class AppliancesListSamples { |
| 93 | + /* |
| 94 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesListBySubscription.json |
| 95 | + */ |
| 96 | + /** |
| 97 | + * Sample code: List Appliances by subscription. |
| 98 | + * |
| 99 | + * @param manager Entry point to AppliancesManager. |
| 100 | + */ |
| 101 | + public static void listAppliancesBySubscription( |
| 102 | + com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 103 | + manager.appliances().list(Context.NONE); |
| 104 | + } |
| 105 | +} |
| 106 | +``` |
| 107 | + |
| 108 | +### Appliances_ListByResourceGroup |
| 109 | + |
| 110 | +```java |
| 111 | +import com.azure.core.util.Context; |
| 112 | + |
| 113 | +/** Samples for Appliances ListByResourceGroup. */ |
| 114 | +public final class AppliancesListByResourceGroupSamples { |
| 115 | + /* |
| 116 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesListByResourceGroup.json |
| 117 | + */ |
| 118 | + /** |
| 119 | + * Sample code: List Appliances by resource group. |
| 120 | + * |
| 121 | + * @param manager Entry point to AppliancesManager. |
| 122 | + */ |
| 123 | + public static void listAppliancesByResourceGroup( |
| 124 | + com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 125 | + manager.appliances().listByResourceGroup("testresourcegroup", Context.NONE); |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +### Appliances_ListClusterUserCredential |
| 131 | + |
| 132 | +```java |
| 133 | +import com.azure.core.util.Context; |
| 134 | + |
| 135 | +/** Samples for Appliances ListClusterUserCredential. */ |
| 136 | +public final class AppliancesListClusterUserCredentialSamples { |
| 137 | + /* |
| 138 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesListClusterUserCredential.json |
| 139 | + */ |
| 140 | + /** |
| 141 | + * Sample code: ListClusterUserCredentialAppliance. |
| 142 | + * |
| 143 | + * @param manager Entry point to AppliancesManager. |
| 144 | + */ |
| 145 | + public static void listClusterUserCredentialAppliance( |
| 146 | + com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 147 | + manager |
| 148 | + .appliances() |
| 149 | + .listClusterUserCredentialWithResponse("testresourcegroup", "testresourcename", Context.NONE); |
| 150 | + } |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | +### Appliances_ListOperations |
| 155 | + |
| 156 | +```java |
| 157 | +import com.azure.core.util.Context; |
| 158 | + |
| 159 | +/** Samples for Appliances ListOperations. */ |
| 160 | +public final class AppliancesListOperationsSamples { |
| 161 | + /* |
| 162 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesListOperations.json |
| 163 | + */ |
| 164 | + /** |
| 165 | + * Sample code: List Appliances operations. |
| 166 | + * |
| 167 | + * @param manager Entry point to AppliancesManager. |
| 168 | + */ |
| 169 | + public static void listAppliancesOperations(com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 170 | + manager.appliances().listOperations(Context.NONE); |
| 171 | + } |
| 172 | +} |
| 173 | +``` |
| 174 | + |
| 175 | +### Appliances_Update |
| 176 | + |
| 177 | +```java |
| 178 | +import com.azure.core.util.Context; |
| 179 | +import com.azure.resourcemanager.resourceconnector.models.Appliance; |
| 180 | +import java.util.HashMap; |
| 181 | +import java.util.Map; |
| 182 | + |
| 183 | +/** Samples for Appliances Update. */ |
| 184 | +public final class AppliancesUpdateSamples { |
| 185 | + /* |
| 186 | + * x-ms-original-file: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/preview/2021-10-31-preview/examples/AppliancesPatch.json |
| 187 | + */ |
| 188 | + /** |
| 189 | + * Sample code: Update Appliance. |
| 190 | + * |
| 191 | + * @param manager Entry point to AppliancesManager. |
| 192 | + */ |
| 193 | + public static void updateAppliance(com.azure.resourcemanager.resourceconnector.AppliancesManager manager) { |
| 194 | + Appliance resource = |
| 195 | + manager |
| 196 | + .appliances() |
| 197 | + .getByResourceGroupWithResponse("testresourcegroup", "appliance01", Context.NONE) |
| 198 | + .getValue(); |
| 199 | + resource.update().withTags(mapOf("key", "value")).apply(); |
| 200 | + } |
| 201 | + |
| 202 | + @SuppressWarnings("unchecked") |
| 203 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 204 | + Map<String, T> map = new HashMap<>(); |
| 205 | + for (int i = 0; i < inputs.length; i += 2) { |
| 206 | + String key = (String) inputs[i]; |
| 207 | + T value = (T) inputs[i + 1]; |
| 208 | + map.put(key, value); |
| 209 | + } |
| 210 | + return map; |
| 211 | + } |
| 212 | +} |
| 213 | +``` |
| 214 | + |
0 commit comments