|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## NetworkFunctions |
| 5 | + |
| 6 | +- [CreateOrUpdate](#networkfunctions_createorupdate) |
| 7 | +- [Delete](#networkfunctions_delete) |
| 8 | +- [GetByResourceGroup](#networkfunctions_getbyresourcegroup) |
| 9 | +- [List](#networkfunctions_list) |
| 10 | +- [ListByResourceGroup](#networkfunctions_listbyresourcegroup) |
| 11 | +- [UpdateTags](#networkfunctions_updatetags) |
| 12 | + |
| 13 | +## Operations |
| 14 | + |
| 15 | +- [List](#operations_list) |
| 16 | +### NetworkFunctions_CreateOrUpdate |
| 17 | + |
| 18 | +```java |
| 19 | +import com.azure.resourcemanager.mpcnetworkfunction.models.NetworkFunctionAdministrativeState; |
| 20 | +import com.azure.resourcemanager.mpcnetworkfunction.models.NetworkFunctionResourceProperties; |
| 21 | +import com.azure.resourcemanager.mpcnetworkfunction.models.NetworkFunctionType; |
| 22 | +import com.azure.resourcemanager.mpcnetworkfunction.models.SkuDefinitions; |
| 23 | + |
| 24 | +/** |
| 25 | + * Samples for NetworkFunctions CreateOrUpdate. |
| 26 | + */ |
| 27 | +public final class NetworkFunctionsCreateOrUpdateSamples { |
| 28 | + /* |
| 29 | + * x-ms-original-file: |
| 30 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 31 | + * NetworkFunctions_CreateOrUpdate.json |
| 32 | + */ |
| 33 | + /** |
| 34 | + * Sample code: NetworkFunctions_CreateOrUpdate. |
| 35 | + * |
| 36 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 37 | + */ |
| 38 | + public static void |
| 39 | + networkFunctionsCreateOrUpdate(com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 40 | + manager.networkFunctions() |
| 41 | + .define("nf1") |
| 42 | + .withRegion("eastus") |
| 43 | + .withExistingResourceGroup("rg1") |
| 44 | + .withProperties(new NetworkFunctionResourceProperties().withSku(SkuDefinitions.NEXUS_PRODUCTION) |
| 45 | + .withNetworkFunctionType(NetworkFunctionType.SMF) |
| 46 | + .withNetworkFunctionAdministrativeState(NetworkFunctionAdministrativeState.COMMISSIONED) |
| 47 | + .withCapacity(100000) |
| 48 | + .withUserDescription("string") |
| 49 | + .withDeploymentNotes("string")) |
| 50 | + .create(); |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +### NetworkFunctions_Delete |
| 56 | + |
| 57 | +```java |
| 58 | +/** |
| 59 | + * Samples for NetworkFunctions Delete. |
| 60 | + */ |
| 61 | +public final class NetworkFunctionsDeleteSamples { |
| 62 | + /* |
| 63 | + * x-ms-original-file: |
| 64 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 65 | + * NetworkFunctions_Delete.json |
| 66 | + */ |
| 67 | + /** |
| 68 | + * Sample code: NetworkFunctions_Delete. |
| 69 | + * |
| 70 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 71 | + */ |
| 72 | + public static void |
| 73 | + networkFunctionsDelete(com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 74 | + manager.networkFunctions().deleteByResourceGroupWithResponse("rg1", "nf1", com.azure.core.util.Context.NONE); |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +### NetworkFunctions_GetByResourceGroup |
| 80 | + |
| 81 | +```java |
| 82 | +/** |
| 83 | + * Samples for NetworkFunctions GetByResourceGroup. |
| 84 | + */ |
| 85 | +public final class NetworkFunctionsGetByResourceGroupSamples { |
| 86 | + /* |
| 87 | + * x-ms-original-file: |
| 88 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 89 | + * NetworkFunctions_Get.json |
| 90 | + */ |
| 91 | + /** |
| 92 | + * Sample code: NetworkFunctions_Get. |
| 93 | + * |
| 94 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 95 | + */ |
| 96 | + public static void |
| 97 | + networkFunctionsGet(com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 98 | + manager.networkFunctions().getByResourceGroupWithResponse("rg1", "nf1", com.azure.core.util.Context.NONE); |
| 99 | + } |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +### NetworkFunctions_List |
| 104 | + |
| 105 | +```java |
| 106 | +/** |
| 107 | + * Samples for NetworkFunctions List. |
| 108 | + */ |
| 109 | +public final class NetworkFunctionsListSamples { |
| 110 | + /* |
| 111 | + * x-ms-original-file: |
| 112 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 113 | + * NetworkFunctions_ListBySubscription.json |
| 114 | + */ |
| 115 | + /** |
| 116 | + * Sample code: NetworkFunctions_ListBySubscription. |
| 117 | + * |
| 118 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 119 | + */ |
| 120 | + public static void networkFunctionsListBySubscription( |
| 121 | + com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 122 | + manager.networkFunctions().list(com.azure.core.util.Context.NONE); |
| 123 | + } |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +### NetworkFunctions_ListByResourceGroup |
| 128 | + |
| 129 | +```java |
| 130 | +/** |
| 131 | + * Samples for NetworkFunctions ListByResourceGroup. |
| 132 | + */ |
| 133 | +public final class NetworkFunctionsListByResourceGroupSamples { |
| 134 | + /* |
| 135 | + * x-ms-original-file: |
| 136 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 137 | + * NetworkFunctions_ListByResourceGroup.json |
| 138 | + */ |
| 139 | + /** |
| 140 | + * Sample code: NetworkFunctions_ListByResourceGroup. |
| 141 | + * |
| 142 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 143 | + */ |
| 144 | + public static void networkFunctionsListByResourceGroup( |
| 145 | + com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 146 | + manager.networkFunctions().listByResourceGroup("rg1", com.azure.core.util.Context.NONE); |
| 147 | + } |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +### NetworkFunctions_UpdateTags |
| 152 | + |
| 153 | +```java |
| 154 | +import com.azure.resourcemanager.mpcnetworkfunction.models.NetworkFunctionResource; |
| 155 | +import java.util.HashMap; |
| 156 | +import java.util.Map; |
| 157 | + |
| 158 | +/** |
| 159 | + * Samples for NetworkFunctions UpdateTags. |
| 160 | + */ |
| 161 | +public final class NetworkFunctionsUpdateTagsSamples { |
| 162 | + /* |
| 163 | + * x-ms-original-file: |
| 164 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 165 | + * NetworkFunctions_UpdateTags.json |
| 166 | + */ |
| 167 | + /** |
| 168 | + * Sample code: NetworkFunctions_UpdateTags. |
| 169 | + * |
| 170 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 171 | + */ |
| 172 | + public static void |
| 173 | + networkFunctionsUpdateTags(com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 174 | + NetworkFunctionResource resource = manager.networkFunctions() |
| 175 | + .getByResourceGroupWithResponse("rg1", "nf1", com.azure.core.util.Context.NONE) |
| 176 | + .getValue(); |
| 177 | + resource.update().withTags(mapOf("tag1", "value1", "tag2", "value2")).apply(); |
| 178 | + } |
| 179 | + |
| 180 | + // Use "Map.of" if available |
| 181 | + @SuppressWarnings("unchecked") |
| 182 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 183 | + Map<String, T> map = new HashMap<>(); |
| 184 | + for (int i = 0; i < inputs.length; i += 2) { |
| 185 | + String key = (String) inputs[i]; |
| 186 | + T value = (T) inputs[i + 1]; |
| 187 | + map.put(key, value); |
| 188 | + } |
| 189 | + return map; |
| 190 | + } |
| 191 | +} |
| 192 | +``` |
| 193 | + |
| 194 | +### Operations_List |
| 195 | + |
| 196 | +```java |
| 197 | +/** |
| 198 | + * Samples for Operations List. |
| 199 | + */ |
| 200 | +public final class OperationsListSamples { |
| 201 | + /* |
| 202 | + * x-ms-original-file: |
| 203 | + * specification/mpcnetworkfunction/resource-manager/Microsoft.MobilePacketCore/preview/2023-05-15-preview/examples/ |
| 204 | + * OperationList.json |
| 205 | + */ |
| 206 | + /** |
| 207 | + * Sample code: OperationsList. |
| 208 | + * |
| 209 | + * @param manager Entry point to MpcnetworkfunctionManager. |
| 210 | + */ |
| 211 | + public static void operationsList(com.azure.resourcemanager.mpcnetworkfunction.MpcnetworkfunctionManager manager) { |
| 212 | + manager.operations().list(com.azure.core.util.Context.NONE); |
| 213 | + } |
| 214 | +} |
| 215 | +``` |
| 216 | + |
0 commit comments