|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## GeoCatalogs |
| 5 | + |
| 6 | +- [Create](#geocatalogs_create) |
| 7 | +- [Delete](#geocatalogs_delete) |
| 8 | +- [GetByResourceGroup](#geocatalogs_getbyresourcegroup) |
| 9 | +- [List](#geocatalogs_list) |
| 10 | +- [ListByResourceGroup](#geocatalogs_listbyresourcegroup) |
| 11 | +- [Update](#geocatalogs_update) |
| 12 | +### GeoCatalogs_Create |
| 13 | + |
| 14 | +```java |
| 15 | +/** |
| 16 | + * Samples for GeoCatalogs List. |
| 17 | + */ |
| 18 | +public final class GeoCatalogsListSamples { |
| 19 | + /* |
| 20 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_ListBySubscription.json |
| 21 | + */ |
| 22 | + /** |
| 23 | + * Sample code: GeoCatalogs_ListBySubscription. |
| 24 | + * |
| 25 | + * @param manager Entry point to PlanetaryComputerManager. |
| 26 | + */ |
| 27 | + public static void |
| 28 | + geoCatalogsListBySubscription(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 29 | + manager.geoCatalogs().list(com.azure.core.util.Context.NONE); |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### GeoCatalogs_Delete |
| 35 | + |
| 36 | +```java |
| 37 | +/** |
| 38 | + * Samples for GeoCatalogs Delete. |
| 39 | + */ |
| 40 | +public final class GeoCatalogsDeleteSamples { |
| 41 | + /* |
| 42 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_Delete.json |
| 43 | + */ |
| 44 | + /** |
| 45 | + * Sample code: GeoCatalogs_Delete. |
| 46 | + * |
| 47 | + * @param manager Entry point to PlanetaryComputerManager. |
| 48 | + */ |
| 49 | + public static void geoCatalogsDelete(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 50 | + manager.geoCatalogs().delete("MyResourceGroup", "MyCatalog", com.azure.core.util.Context.NONE); |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +### GeoCatalogs_GetByResourceGroup |
| 56 | + |
| 57 | +```java |
| 58 | +/** |
| 59 | + * Samples for GeoCatalogs ListByResourceGroup. |
| 60 | + */ |
| 61 | +public final class GeoCatalogsListByResourceGroupSamples { |
| 62 | + /* |
| 63 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_ListByResourceGroup.json |
| 64 | + */ |
| 65 | + /** |
| 66 | + * Sample code: GeoCatalogs_ListByResourceGroup. |
| 67 | + * |
| 68 | + * @param manager Entry point to PlanetaryComputerManager. |
| 69 | + */ |
| 70 | + public static void |
| 71 | + geoCatalogsListByResourceGroup(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 72 | + manager.geoCatalogs().listByResourceGroup("MyResourceGroup", com.azure.core.util.Context.NONE); |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### GeoCatalogs_List |
| 78 | + |
| 79 | +```java |
| 80 | +import com.azure.resourcemanager.planetarycomputer.models.GeoCatalog; |
| 81 | +import com.azure.resourcemanager.planetarycomputer.models.ManagedServiceIdentityType; |
| 82 | +import com.azure.resourcemanager.planetarycomputer.models.ManagedServiceIdentityUpdate; |
| 83 | +import com.azure.resourcemanager.planetarycomputer.models.UserAssignedIdentity; |
| 84 | +import java.util.HashMap; |
| 85 | +import java.util.Map; |
| 86 | + |
| 87 | +/** |
| 88 | + * Samples for GeoCatalogs Update. |
| 89 | + */ |
| 90 | +public final class GeoCatalogsUpdateSamples { |
| 91 | + /* |
| 92 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_Update.json |
| 93 | + */ |
| 94 | + /** |
| 95 | + * Sample code: GeoCatalogs_Update. |
| 96 | + * |
| 97 | + * @param manager Entry point to PlanetaryComputerManager. |
| 98 | + */ |
| 99 | + public static void geoCatalogsUpdate(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 100 | + GeoCatalog resource = manager.geoCatalogs() |
| 101 | + .getByResourceGroupWithResponse("MyResourceGroup", "MyCatalog", com.azure.core.util.Context.NONE) |
| 102 | + .getValue(); |
| 103 | + resource.update() |
| 104 | + .withTags(mapOf("MyTag", "MyValue")) |
| 105 | + .withIdentity(new ManagedServiceIdentityUpdate().withType(ManagedServiceIdentityType.USER_ASSIGNED) |
| 106 | + .withUserAssignedIdentities(mapOf( |
| 107 | + "/subscriptions/cd9b6cdf-dcf0-4dca-ab19-82be07b74704/resourceGroups/MyResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyManagedIdentity", |
| 108 | + new UserAssignedIdentity()))) |
| 109 | + .apply(); |
| 110 | + } |
| 111 | + |
| 112 | + // Use "Map.of" if available |
| 113 | + @SuppressWarnings("unchecked") |
| 114 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 115 | + Map<String, T> map = new HashMap<>(); |
| 116 | + for (int i = 0; i < inputs.length; i += 2) { |
| 117 | + String key = (String) inputs[i]; |
| 118 | + T value = (T) inputs[i + 1]; |
| 119 | + map.put(key, value); |
| 120 | + } |
| 121 | + return map; |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +### GeoCatalogs_ListByResourceGroup |
| 127 | + |
| 128 | +```java |
| 129 | +/** |
| 130 | + * Samples for GeoCatalogs GetByResourceGroup. |
| 131 | + */ |
| 132 | +public final class GeoCatalogsGetByResourceGroupSamples { |
| 133 | + /* |
| 134 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_Get.json |
| 135 | + */ |
| 136 | + /** |
| 137 | + * Sample code: GeoCatalogs_Get. |
| 138 | + * |
| 139 | + * @param manager Entry point to PlanetaryComputerManager. |
| 140 | + */ |
| 141 | + public static void geoCatalogsGet(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 142 | + manager.geoCatalogs() |
| 143 | + .getByResourceGroupWithResponse("MyResourceGroup", "MyCatalog", com.azure.core.util.Context.NONE); |
| 144 | + } |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +### GeoCatalogs_Update |
| 149 | + |
| 150 | +```java |
| 151 | +import com.azure.resourcemanager.planetarycomputer.models.AutoGeneratedDomainNameLabelScope; |
| 152 | +import com.azure.resourcemanager.planetarycomputer.models.CatalogTier; |
| 153 | +import com.azure.resourcemanager.planetarycomputer.models.GeoCatalogProperties; |
| 154 | +import com.azure.resourcemanager.planetarycomputer.models.ManagedServiceIdentity; |
| 155 | +import com.azure.resourcemanager.planetarycomputer.models.ManagedServiceIdentityType; |
| 156 | +import com.azure.resourcemanager.planetarycomputer.models.UserAssignedIdentity; |
| 157 | +import java.util.HashMap; |
| 158 | +import java.util.Map; |
| 159 | + |
| 160 | +/** |
| 161 | + * Samples for GeoCatalogs Create. |
| 162 | + */ |
| 163 | +public final class GeoCatalogsCreateSamples { |
| 164 | + /* |
| 165 | + * x-ms-original-file: 2025-02-11-preview/GeoCatalogs_Create.json |
| 166 | + */ |
| 167 | + /** |
| 168 | + * Sample code: GeoCatalogs_Create. |
| 169 | + * |
| 170 | + * @param manager Entry point to PlanetaryComputerManager. |
| 171 | + */ |
| 172 | + public static void geoCatalogsCreate(com.azure.resourcemanager.planetarycomputer.PlanetaryComputerManager manager) { |
| 173 | + manager.geoCatalogs() |
| 174 | + .define("MyCatalog") |
| 175 | + .withRegion("eastus") |
| 176 | + .withExistingResourceGroup("MyResourceGroup") |
| 177 | + .withTags(mapOf("MyTag", "MyValue")) |
| 178 | + .withProperties(new GeoCatalogProperties().withTier(CatalogTier.BASIC) |
| 179 | + .withAutoGeneratedDomainNameLabelScope(AutoGeneratedDomainNameLabelScope.NO_REUSE)) |
| 180 | + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) |
| 181 | + .withUserAssignedIdentities(mapOf( |
| 182 | + "/subscriptions/cd9b6cdf-dcf0-4dca-ab19-82be07b74704/resourceGroups/MyResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyManagedIdentity", |
| 183 | + new UserAssignedIdentity()))) |
| 184 | + .create(); |
| 185 | + } |
| 186 | + |
| 187 | + // Use "Map.of" if available |
| 188 | + @SuppressWarnings("unchecked") |
| 189 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 190 | + Map<String, T> map = new HashMap<>(); |
| 191 | + for (int i = 0; i < inputs.length; i += 2) { |
| 192 | + String key = (String) inputs[i]; |
| 193 | + T value = (T) inputs[i + 1]; |
| 194 | + map.put(key, value); |
| 195 | + } |
| 196 | + return map; |
| 197 | + } |
| 198 | +} |
| 199 | +``` |
| 200 | + |
0 commit comments