|
| 1 | +# Code snippets and samples |
| 2 | + |
| 3 | + |
| 4 | +## Operations |
| 5 | + |
| 6 | +- [List](#operations_list) |
| 7 | + |
| 8 | +## Organizations |
| 9 | + |
| 10 | +- [CreateOrUpdate](#organizations_createorupdate) |
| 11 | +- [Delete](#organizations_delete) |
| 12 | +- [GetByResourceGroup](#organizations_getbyresourcegroup) |
| 13 | +- [List](#organizations_list) |
| 14 | +- [ListByResourceGroup](#organizations_listbyresourcegroup) |
| 15 | +- [Update](#organizations_update) |
| 16 | +### Operations_List |
| 17 | + |
| 18 | +```java |
| 19 | +/** |
| 20 | + * Samples for Operations List. |
| 21 | + */ |
| 22 | +public final class OperationsListSamples { |
| 23 | + /* |
| 24 | + * x-ms-original-file: 2024-10-22-preview/Operations_List_MinimumSet_Gen.json |
| 25 | + */ |
| 26 | + /** |
| 27 | + * Sample code: Operations_List_MinimumSet. |
| 28 | + * |
| 29 | + * @param manager Entry point to PineconeVectorDbManager. |
| 30 | + */ |
| 31 | + public static void |
| 32 | + operationsListMinimumSet(com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 33 | + manager.operations().list(com.azure.core.util.Context.NONE); |
| 34 | + } |
| 35 | + |
| 36 | + /* |
| 37 | + * x-ms-original-file: 2024-10-22-preview/Operations_List_MaximumSet_Gen.json |
| 38 | + */ |
| 39 | + /** |
| 40 | + * Sample code: Operations_List_MaximumSet. |
| 41 | + * |
| 42 | + * @param manager Entry point to PineconeVectorDbManager. |
| 43 | + */ |
| 44 | + public static void |
| 45 | + operationsListMaximumSet(com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 46 | + manager.operations().list(com.azure.core.util.Context.NONE); |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +### Organizations_CreateOrUpdate |
| 52 | + |
| 53 | +```java |
| 54 | +import com.azure.resourcemanager.pineconevectordb.models.ManagedServiceIdentity; |
| 55 | +import com.azure.resourcemanager.pineconevectordb.models.ManagedServiceIdentityType; |
| 56 | +import com.azure.resourcemanager.pineconevectordb.models.MarketplaceDetails; |
| 57 | +import com.azure.resourcemanager.pineconevectordb.models.OfferDetails; |
| 58 | +import com.azure.resourcemanager.pineconevectordb.models.OrganizationProperties; |
| 59 | +import com.azure.resourcemanager.pineconevectordb.models.PartnerProperties; |
| 60 | +import com.azure.resourcemanager.pineconevectordb.models.SingleSignOnPropertiesV2; |
| 61 | +import com.azure.resourcemanager.pineconevectordb.models.SingleSignOnStates; |
| 62 | +import com.azure.resourcemanager.pineconevectordb.models.SingleSignOnType; |
| 63 | +import com.azure.resourcemanager.pineconevectordb.models.UserAssignedIdentity; |
| 64 | +import com.azure.resourcemanager.pineconevectordb.models.UserDetails; |
| 65 | +import java.util.Arrays; |
| 66 | +import java.util.HashMap; |
| 67 | +import java.util.Map; |
| 68 | + |
| 69 | +/** |
| 70 | + * Samples for Organizations CreateOrUpdate. |
| 71 | + */ |
| 72 | +public final class OrganizationsCreateOrUpdateSamples { |
| 73 | + /* |
| 74 | + * x-ms-original-file: 2024-10-22-preview/Organizations_CreateOrUpdate_MaximumSet_Gen.json |
| 75 | + */ |
| 76 | + /** |
| 77 | + * Sample code: Organizations_CreateOrUpdate_MaximumSet. |
| 78 | + * |
| 79 | + * @param manager Entry point to PineconeVectorDbManager. |
| 80 | + */ |
| 81 | + public static void organizationsCreateOrUpdateMaximumSet( |
| 82 | + com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 83 | + manager.organizations() |
| 84 | + .define("example-organization-name") |
| 85 | + .withRegion("us-east") |
| 86 | + .withExistingResourceGroup("rgopenapi") |
| 87 | + .withTags(mapOf("my-tag", "tag.value")) |
| 88 | + .withProperties(new OrganizationProperties() |
| 89 | + .withMarketplace(new MarketplaceDetails().withSubscriptionId("76a38ef6-c8c1-4f0d-bfe0-00ec782c8077") |
| 90 | + .withOfferDetails(new OfferDetails().withPublisherId("4d194daf-fa20-46a8-bfb4-5b7d96cae009") |
| 91 | + .withOfferId("013124d0-bf05-4eab-a6bb-01fa83870642") |
| 92 | + .withPlanId("62dda065-5acd-4ac5-b418-8610beed92a2") |
| 93 | + .withPlanName("Freemium") |
| 94 | + .withTermUnit("der") |
| 95 | + .withTermId("a2b7ce01-f06d-4874-9f77-6ea4a4875c16"))) |
| 96 | + .withUser(new UserDetails().withFirstName("Jimmy") |
| 97 | + .withLastName("McExample") |
| 98 | + .withEmailAddress( "[email protected]") |
| 99 | + |
| 100 | + .withPhoneNumber("555-555-5555")) |
| 101 | + .withPartnerProperties(new PartnerProperties().withDisplayName("My Example Organization")) |
| 102 | + .withSingleSignOnProperties(new SingleSignOnPropertiesV2().withType(SingleSignOnType.SAML) |
| 103 | + .withState(SingleSignOnStates.INITIAL) |
| 104 | + .withEnterpriseAppId("44d3fb26-d8d5-41ff-9b9a-769737f22f13") |
| 105 | + .withUrl("https://login.pinecone.io/?sso=true&connection=dfwgsqzkbrjqrglcsa") |
| 106 | + .withAadDomains(Arrays.asList("exampledomain")))) |
| 107 | + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.NONE) |
| 108 | + .withUserAssignedIdentities(mapOf("ident904655400", new UserAssignedIdentity()))) |
| 109 | + .create(); |
| 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 | +### Organizations_Delete |
| 127 | + |
| 128 | +```java |
| 129 | +/** |
| 130 | + * Samples for Organizations Delete. |
| 131 | + */ |
| 132 | +public final class OrganizationsDeleteSamples { |
| 133 | + /* |
| 134 | + * x-ms-original-file: 2024-10-22-preview/Organizations_Delete_MaximumSet_Gen.json |
| 135 | + */ |
| 136 | + /** |
| 137 | + * Sample code: Organizations_Delete_MaximumSet. |
| 138 | + * |
| 139 | + * @param manager Entry point to PineconeVectorDbManager. |
| 140 | + */ |
| 141 | + public static void |
| 142 | + organizationsDeleteMaximumSet(com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 143 | + manager.organizations().delete("rgopenapi", "example-organization-name", com.azure.core.util.Context.NONE); |
| 144 | + } |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +### Organizations_GetByResourceGroup |
| 149 | + |
| 150 | +```java |
| 151 | +/** |
| 152 | + * Samples for Organizations GetByResourceGroup. |
| 153 | + */ |
| 154 | +public final class OrganizationsGetByResourceGroupSamples { |
| 155 | + /* |
| 156 | + * x-ms-original-file: 2024-10-22-preview/Organizations_Get_MaximumSet_Gen.json |
| 157 | + */ |
| 158 | + /** |
| 159 | + * Sample code: Organizations_Get_MaximumSet. |
| 160 | + * |
| 161 | + * @param manager Entry point to PineconeVectorDbManager. |
| 162 | + */ |
| 163 | + public static void |
| 164 | + organizationsGetMaximumSet(com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 165 | + manager.organizations() |
| 166 | + .getByResourceGroupWithResponse("rgopenapi", "example-organization-name", com.azure.core.util.Context.NONE); |
| 167 | + } |
| 168 | +} |
| 169 | +``` |
| 170 | + |
| 171 | +### Organizations_List |
| 172 | + |
| 173 | +```java |
| 174 | +/** |
| 175 | + * Samples for Organizations List. |
| 176 | + */ |
| 177 | +public final class OrganizationsListSamples { |
| 178 | + /* |
| 179 | + * x-ms-original-file: 2024-10-22-preview/Organizations_ListBySubscription_MaximumSet_Gen.json |
| 180 | + */ |
| 181 | + /** |
| 182 | + * Sample code: Organizations_ListBySubscription_MaximumSet. |
| 183 | + * |
| 184 | + * @param manager Entry point to PineconeVectorDbManager. |
| 185 | + */ |
| 186 | + public static void organizationsListBySubscriptionMaximumSet( |
| 187 | + com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 188 | + manager.organizations().list(com.azure.core.util.Context.NONE); |
| 189 | + } |
| 190 | +} |
| 191 | +``` |
| 192 | + |
| 193 | +### Organizations_ListByResourceGroup |
| 194 | + |
| 195 | +```java |
| 196 | +/** |
| 197 | + * Samples for Organizations ListByResourceGroup. |
| 198 | + */ |
| 199 | +public final class OrganizationsListByResourceGroupSamples { |
| 200 | + /* |
| 201 | + * x-ms-original-file: 2024-10-22-preview/Organizations_ListByResourceGroup_MaximumSet_Gen.json |
| 202 | + */ |
| 203 | + /** |
| 204 | + * Sample code: Organizations_ListByResourceGroup_MaximumSet. |
| 205 | + * |
| 206 | + * @param manager Entry point to PineconeVectorDbManager. |
| 207 | + */ |
| 208 | + public static void organizationsListByResourceGroupMaximumSet( |
| 209 | + com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 210 | + manager.organizations().listByResourceGroup("rgopenapi", com.azure.core.util.Context.NONE); |
| 211 | + } |
| 212 | +} |
| 213 | +``` |
| 214 | + |
| 215 | +### Organizations_Update |
| 216 | + |
| 217 | +```java |
| 218 | +import com.azure.resourcemanager.pineconevectordb.models.ManagedServiceIdentity; |
| 219 | +import com.azure.resourcemanager.pineconevectordb.models.ManagedServiceIdentityType; |
| 220 | +import com.azure.resourcemanager.pineconevectordb.models.OrganizationResource; |
| 221 | +import com.azure.resourcemanager.pineconevectordb.models.UserAssignedIdentity; |
| 222 | +import java.util.HashMap; |
| 223 | +import java.util.Map; |
| 224 | + |
| 225 | +/** |
| 226 | + * Samples for Organizations Update. |
| 227 | + */ |
| 228 | +public final class OrganizationsUpdateSamples { |
| 229 | + /* |
| 230 | + * x-ms-original-file: 2024-10-22-preview/Organizations_Update_MaximumSet_Gen.json |
| 231 | + */ |
| 232 | + /** |
| 233 | + * Sample code: Organizations_Update_MaximumSet. |
| 234 | + * |
| 235 | + * @param manager Entry point to PineconeVectorDbManager. |
| 236 | + */ |
| 237 | + public static void |
| 238 | + organizationsUpdateMaximumSet(com.azure.resourcemanager.pineconevectordb.PineconeVectorDbManager manager) { |
| 239 | + OrganizationResource resource = manager.organizations() |
| 240 | + .getByResourceGroupWithResponse("rgopenapi", "example-organization-name", com.azure.core.util.Context.NONE) |
| 241 | + .getValue(); |
| 242 | + resource.update() |
| 243 | + .withTags(mapOf("new-tag", "new.tag.value")) |
| 244 | + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.NONE) |
| 245 | + .withUserAssignedIdentities(mapOf("ident573739201", new UserAssignedIdentity()))) |
| 246 | + .apply(); |
| 247 | + } |
| 248 | + |
| 249 | + // Use "Map.of" if available |
| 250 | + @SuppressWarnings("unchecked") |
| 251 | + private static <T> Map<String, T> mapOf(Object... inputs) { |
| 252 | + Map<String, T> map = new HashMap<>(); |
| 253 | + for (int i = 0; i < inputs.length; i += 2) { |
| 254 | + String key = (String) inputs[i]; |
| 255 | + T value = (T) inputs[i + 1]; |
| 256 | + map.put(key, value); |
| 257 | + } |
| 258 | + return map; |
| 259 | + } |
| 260 | +} |
| 261 | +``` |
| 262 | + |
0 commit comments