| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Threading; |
| | 6 | | using Azure.Core; |
| | 7 | |
|
| | 8 | | namespace Azure.Search.Documents.Indexes.Models |
| | 9 | | { |
| | 10 | | [CodeGenModel("EncryptionKey")] |
| | 11 | | [CodeGenSuppress(nameof(SearchResourceEncryptionKey), typeof(string), typeof(string), typeof(string))] |
| | 12 | | public partial class SearchResourceEncryptionKey |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Creates a new instance of the <see cref="SearchResourceEncryptionKey"/> class. |
| | 16 | | /// </summary> |
| | 17 | | /// <param name="vaultUri">Required. The Azure Key Vault <see cref="Uri"/>.</param> |
| | 18 | | /// <param name="keyName">Required. The name of the Azure Key Vault key to encrypt resources at rest.</param> |
| | 19 | | /// <param name="keyVersion">Required. The version of the Azure Key Vault key to encrypt resources at rest.</par |
| | 20 | | /// <exception cref="ArgumentNullException"><paramref name="vaultUri"/>, <paramref name="keyName"/>, or <paramre |
| 0 | 21 | | public SearchResourceEncryptionKey(Uri vaultUri, string keyName, string keyVersion) |
| | 22 | | { |
| 0 | 23 | | VaultUri = vaultUri ?? throw new ArgumentNullException(nameof(vaultUri)); |
| 0 | 24 | | KeyName = keyName ?? throw new ArgumentNullException(nameof(keyName)); |
| 0 | 25 | | KeyVersion = keyVersion ?? throw new ArgumentNullException(nameof(keyVersion)); |
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | [CodeGenMember("vaultUri")] |
| | 29 | | private string _vaultUri; |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Gets the Azure Key Vault <see cref="Uri"/>. |
| | 33 | | /// </summary> |
| | 34 | | public Uri VaultUri |
| | 35 | | { |
| 0 | 36 | | get => new Uri(_vaultUri); |
| 0 | 37 | | private set => _vaultUri = value.ToString(); |
| | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Gets the name of the Azure Key Vault key to encrypt resources at rest. |
| | 42 | | /// </summary> |
| | 43 | | [CodeGenMember("keyVaultKeyName")] |
| 0 | 44 | | public string KeyName { get; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Gets the version of the Azure Key Vault key to encrypt resources at rest. |
| | 48 | | /// </summary> |
| | 49 | | /// <remarks> |
| | 50 | | /// A version is required in case the key rotates. |
| | 51 | | /// </remarks> |
| | 52 | | [CodeGenMember("keyVaultKeyVersion")] |
| 0 | 53 | | public string KeyVersion { get; } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Gets or sets the application ID to access the Azure Key Vault specified in the <see cref="VaultUri"/>. |
| | 57 | | /// The Azure Key Vault must be in the same tenant as the Azure Search service. |
| | 58 | | /// </summary> |
| 0 | 59 | | public string ApplicationId { get; set; } |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// Gets or sets the application secret to access the Azure Key Vault specified in the <see cref="VaultUri"/>. |
| | 63 | | /// The Azure Key Vault must be in the same tenant as the Azure Search service. |
| | 64 | | /// </summary> |
| 0 | 65 | | public string ApplicationSecret { get; set; } |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// Gets or sets an <see cref="AzureActiveDirectoryApplicationCredentials"/> for de/serialization purposes only. |
| | 69 | | /// </summary> |
| | 70 | | [CodeGenMember("accessCredentials")] |
| | 71 | | private AzureActiveDirectoryApplicationCredentials AccessCredentialsInternal |
| | 72 | | { |
| | 73 | | get |
| | 74 | | { |
| 0 | 75 | | if (ApplicationId != null || ApplicationSecret != null) |
| | 76 | | { |
| 0 | 77 | | return new AzureActiveDirectoryApplicationCredentials(ApplicationId, ApplicationSecret); |
| | 78 | | } |
| | 79 | |
|
| 0 | 80 | | return null; |
| | 81 | | } |
| | 82 | |
|
| | 83 | | set |
| | 84 | | { |
| 0 | 85 | | ApplicationId = value?.ApplicationId; |
| 0 | 86 | | ApplicationSecret = value?.ApplicationSecret; |
| 0 | 87 | | } |
| | 88 | | } |
| | 89 | | } |
| | 90 | | } |